Change variable name

This commit is contained in:
2023-10-29 22:26:21 +07:00
parent 2b04fdb191
commit 5f051c4fa2
3 changed files with 8 additions and 8 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
const INVALID_FORMAT_MSG = (field: string) => { const invalidFormatMsg = (field: string) => {
return `Invalid ${field} format`; return `Invalid ${field} format`;
}; };
const ADD_SUCCESS = 'Add success'; const ADD_SUCCESS = 'Add success';
const ERROR_MSG = (errorCode: number, msg: string) => { const errorMsg = (errorCode: number, msg: string) => {
return `Error code: ${errorCode}. Message: ${msg}`; return `Error code: ${errorCode}. Message: ${msg}`;
}; };
export { INVALID_FORMAT_MSG, ADD_SUCCESS, ERROR_MSG }; export { invalidFormatMsg, ADD_SUCCESS, errorMsg };
+2 -2
View File
@@ -1,4 +1,4 @@
import { INVALID_FORMAT_MSG } from '../constants/messages'; import { invalidFormatMsg } from '../constants/messages';
import { TKeyValue, TPropValues, TStateSchema } from '../globals/types'; import { TKeyValue, TPropValues, TStateSchema } from '../globals/types';
const VALUE = 'value'; const VALUE = 'value';
@@ -39,7 +39,7 @@ const addValidator = ({ validatorFunc, prop, required = true }: TValidator) => {
required, required,
validator: { validator: {
func: validatorFunc, func: validatorFunc,
error: INVALID_FORMAT_MSG(prop), error: invalidFormatMsg(prop),
}, },
}; };
}; };
+3 -3
View File
@@ -34,7 +34,7 @@ import { sendRequest } from '../../helpers/sendRequest.ts';
// Constants // Constants
import { STATUS_CODE } from '../../constants/statusCode.ts'; import { STATUS_CODE } from '../../constants/statusCode.ts';
import { ADD_SUCCESS, ERROR_MSG } from '../../constants/messages.ts'; import { ADD_SUCCESS, errorMsg } from '../../constants/messages.ts';
const FormBtn = styled(Button)` const FormBtn = styled(Button)`
width: 100%; width: 100%;
@@ -102,13 +102,13 @@ const UserForm = ({ onClose, reload, setReload }: IUserFormProp) => {
// Reload table data // Reload table data
setReload(!reload); setReload(!reload);
} else { } else {
toast.error(ERROR_MSG(response.statusCode, response.msg)); toast.error(errorMsg(response.statusCode, response.msg));
} }
onResetForm(); onResetForm();
} catch (error) { } catch (error) {
toast.error( toast.error(
ERROR_MSG((error as TResponse).statusCode, (error as TResponse).msg), errorMsg((error as TResponse).statusCode, (error as TResponse).msg),
); );
} }