mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 13:38:51 +00:00
Fix format code style
This commit is contained in:
@@ -10,6 +10,7 @@ const ADD_SUCCESS = 'Add success';
|
|||||||
const EDIT_SUCCESS = 'Edit success';
|
const EDIT_SUCCESS = 'Edit success';
|
||||||
const CONFIRM_DELETE = 'Are you sure to delete it?';
|
const CONFIRM_DELETE = 'Are you sure to delete it?';
|
||||||
const DELETE_SUCCESS = 'Delete success';
|
const DELETE_SUCCESS = 'Delete success';
|
||||||
|
const REQUIRED_FIELD_ERROR = 'This is required field';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
invalidFormatMsg,
|
invalidFormatMsg,
|
||||||
@@ -18,4 +19,5 @@ export {
|
|||||||
EDIT_SUCCESS,
|
EDIT_SUCCESS,
|
||||||
CONFIRM_DELETE,
|
CONFIRM_DELETE,
|
||||||
DELETE_SUCCESS,
|
DELETE_SUCCESS,
|
||||||
|
REQUIRED_FIELD_ERROR,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -74,4 +74,7 @@ const ROOM_PAGE = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
export { USER_PAGE, ROOM_PAGE };
|
const VALUE = 'value';
|
||||||
|
const ERROR = 'error';
|
||||||
|
|
||||||
|
export { USER_PAGE, ROOM_PAGE, VALUE, ERROR };
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ type TStateSchema = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type TKeyValue = {
|
type TKeyValue = {
|
||||||
[key: string]: string | undefined | boolean | number;
|
[key: string]: boolean | undefined | string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Test = {
|
type TKeyString = {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ export type {
|
|||||||
TRoom,
|
TRoom,
|
||||||
TStateSchema,
|
TStateSchema,
|
||||||
TKeyValue,
|
TKeyValue,
|
||||||
|
TKeyString,
|
||||||
TPropValues,
|
TPropValues,
|
||||||
TValidator,
|
TValidator,
|
||||||
TResponse,
|
TResponse,
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
// Constants
|
// Constants
|
||||||
import { invalidFormatMsg } from '../constants/messages';
|
import { REQUIRED_FIELD_ERROR, invalidFormatMsg } from '../constants/messages';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { TKeyValue, TPropValues, TStateSchema, Test } from '../globals/types';
|
import {
|
||||||
|
TKeyString,
|
||||||
const VALUE = 'value';
|
TKeyValue,
|
||||||
const ERROR = 'error';
|
TPropValues,
|
||||||
const REQUIRED_FIELD_ERROR = 'This is required field';
|
TStateSchema,
|
||||||
|
} from '../globals/types';
|
||||||
|
|
||||||
const isBool = (value: unknown) => {
|
const isBool = (value: unknown) => {
|
||||||
return typeof value === 'boolean';
|
return typeof value === 'boolean';
|
||||||
@@ -47,20 +48,18 @@ const addValidator = ({ validatorFunc, prop, required = true }: TValidator) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getValueFromObj = <T>(obj: T | null = null): Test => {
|
const getValueFromObj = <T>(obj: T | null = null): TKeyString => {
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
for (const key of Object.keys(obj)) {
|
for (const key of Object.keys(obj)) {
|
||||||
const tempValue = obj[key as keyof typeof obj];
|
const tempValue = obj[key as keyof typeof obj];
|
||||||
const value: string | boolean | number =
|
const value: string | boolean | number =
|
||||||
typeof tempValue === 'boolean' ||
|
typeof tempValue === 'boolean' || typeof tempValue === 'string'
|
||||||
typeof tempValue === 'string' ||
|
|
||||||
typeof tempValue === 'number'
|
|
||||||
? tempValue
|
? tempValue
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
result = { ...result, [`${key}Value`]: value };
|
result = { ...result, [`${key}Value`]: value as string };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +111,5 @@ export {
|
|||||||
getValueFromObj,
|
getValueFromObj,
|
||||||
addValidator,
|
addValidator,
|
||||||
searchQuery,
|
searchQuery,
|
||||||
VALUE,
|
|
||||||
ERROR,
|
|
||||||
REQUIRED_FIELD_ERROR,
|
REQUIRED_FIELD_ERROR,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user