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 CONFIRM_DELETE = 'Are you sure to delete it?';
|
||||
const DELETE_SUCCESS = 'Delete success';
|
||||
const REQUIRED_FIELD_ERROR = 'This is required field';
|
||||
|
||||
export {
|
||||
invalidFormatMsg,
|
||||
@@ -18,4 +19,5 @@ export {
|
||||
EDIT_SUCCESS,
|
||||
CONFIRM_DELETE,
|
||||
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 = {
|
||||
[key: string]: string | undefined | boolean | number;
|
||||
[key: string]: boolean | undefined | string;
|
||||
};
|
||||
|
||||
export type Test = {
|
||||
type TKeyString = {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
@@ -54,6 +54,7 @@ export type {
|
||||
TRoom,
|
||||
TStateSchema,
|
||||
TKeyValue,
|
||||
TKeyString,
|
||||
TPropValues,
|
||||
TValidator,
|
||||
TResponse,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Constants
|
||||
import { invalidFormatMsg } from '../constants/messages';
|
||||
import { REQUIRED_FIELD_ERROR, invalidFormatMsg } from '../constants/messages';
|
||||
|
||||
// Types
|
||||
import { TKeyValue, TPropValues, TStateSchema, Test } from '../globals/types';
|
||||
|
||||
const VALUE = 'value';
|
||||
const ERROR = 'error';
|
||||
const REQUIRED_FIELD_ERROR = 'This is required field';
|
||||
import {
|
||||
TKeyString,
|
||||
TKeyValue,
|
||||
TPropValues,
|
||||
TStateSchema,
|
||||
} from '../globals/types';
|
||||
|
||||
const isBool = (value: unknown) => {
|
||||
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 = {};
|
||||
|
||||
if (obj) {
|
||||
for (const key of Object.keys(obj)) {
|
||||
const tempValue = obj[key as keyof typeof obj];
|
||||
const value: string | boolean | number =
|
||||
typeof tempValue === 'boolean' ||
|
||||
typeof tempValue === 'string' ||
|
||||
typeof tempValue === 'number'
|
||||
typeof tempValue === 'boolean' || typeof tempValue === 'string'
|
||||
? tempValue
|
||||
: '';
|
||||
|
||||
result = { ...result, [`${key}Value`]: value };
|
||||
result = { ...result, [`${key}Value`]: value as string };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +111,5 @@ export {
|
||||
getValueFromObj,
|
||||
addValidator,
|
||||
searchQuery,
|
||||
VALUE,
|
||||
ERROR,
|
||||
REQUIRED_FIELD_ERROR,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user