Merge from react-practice branch

This commit is contained in:
2023-10-30 09:16:16 +07:00
4 changed files with 14 additions and 22 deletions
+5 -13
View File
@@ -8,14 +8,6 @@
"roomId": 246, "roomId": 246,
"address": "Da Nang" "address": "Da Nang"
}, },
{
"id": 2,
"name": "Phan Huu Loi",
"identifiedCode": "123",
"phone": "0937425123",
"roomId": 246,
"address": "Ho Chi Minh"
},
{ {
"id": 3, "id": 3,
"name": "Nezumi", "name": "Nezumi",
@@ -81,12 +73,12 @@
"id": 13 "id": 13
}, },
{ {
"id": 16, "id": 17,
"name": "Phan Huu Loi", "name": "Phan Huu Loi",
"identifiedCode": "3213123212312", "identifiedCode": "123",
"phone": "0327768321", "phone": "0937425123",
"roomId": "3123", "roomId": "246",
"address": "32131312332131" "address": "233123132131321"
} }
] ]
} }
+4 -4
View File
@@ -1,8 +1,8 @@
const INVALID_FORMAT_MSG = (field: string) => { const invalidFormatMsg = (field: string) => {
return `Invalid ${field} format`; return `Invalid ${field} format`;
}; };
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}`;
}; };
@@ -12,9 +12,9 @@ const CONFIRM_DELETE = 'Are you sure to delete it?';
const DELETE_SUCCESS = 'Delete success'; const DELETE_SUCCESS = 'Delete success';
export { export {
INVALID_FORMAT_MSG, invalidFormatMsg,
ADD_SUCCESS, ADD_SUCCESS,
ERROR_MSG, errorMsg,
EDIT_SUCCESS, EDIT_SUCCESS,
CONFIRM_DELETE, CONFIRM_DELETE,
DELETE_SUCCESS, DELETE_SUCCESS,
+2 -2
View File
@@ -1,4 +1,4 @@
import { INVALID_FORMAT_MSG } from '../constants/messages'; import { invalidFormatMsg } from '../constants/messages';
import { TKeyValue, TPropValues, TStateSchema, TUser } from '../globals/types'; import { TKeyValue, TPropValues, TStateSchema, TUser } 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
@@ -37,7 +37,7 @@ import { STATUS_CODE } from '../../constants/statusCode.ts';
import { import {
ADD_SUCCESS, ADD_SUCCESS,
EDIT_SUCCESS, EDIT_SUCCESS,
ERROR_MSG, errorMsg,
} from '../../constants/messages.ts'; } from '../../constants/messages.ts';
import { USER_PATH } from '../../constants/path.ts'; import { USER_PATH } from '../../constants/path.ts';
@@ -122,7 +122,7 @@ const UserForm = ({
if (response.statusCode === STATUS_CODE.CREATE) { if (response.statusCode === STATUS_CODE.CREATE) {
toast.success(ADD_SUCCESS); toast.success(ADD_SUCCESS);
} else { } else {
throw new Error(ERROR_MSG(response.statusCode, response.msg)); throw new Error(errorMsg(response.statusCode, response.msg));
} }
} else { } else {
// Edit request // Edit request
@@ -135,7 +135,7 @@ const UserForm = ({
if (response.statusCode == STATUS_CODE.OK) { if (response.statusCode == STATUS_CODE.OK) {
toast.success(EDIT_SUCCESS); toast.success(EDIT_SUCCESS);
} else { } else {
throw new Error(ERROR_MSG(response.statusCode, response.msg)); throw new Error(errorMsg(response.statusCode, response.msg));
} }
} }
// Reload table data // Reload table data