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,
"address": "Da Nang"
},
{
"id": 2,
"name": "Phan Huu Loi",
"identifiedCode": "123",
"phone": "0937425123",
"roomId": 246,
"address": "Ho Chi Minh"
},
{
"id": 3,
"name": "Nezumi",
@@ -81,12 +73,12 @@
"id": 13
},
{
"id": 16,
"id": 17,
"name": "Phan Huu Loi",
"identifiedCode": "3213123212312",
"phone": "0327768321",
"roomId": "3123",
"address": "32131312332131"
"identifiedCode": "123",
"phone": "0937425123",
"roomId": "246",
"address": "233123132131321"
}
]
}
+4 -4
View File
@@ -1,8 +1,8 @@
const INVALID_FORMAT_MSG = (field: string) => {
const invalidFormatMsg = (field: string) => {
return `Invalid ${field} format`;
};
const ERROR_MSG = (errorCode: number, msg: string) => {
const errorMsg = (errorCode: number, msg: string) => {
return `Error code: ${errorCode}. Message: ${msg}`;
};
@@ -12,9 +12,9 @@ const CONFIRM_DELETE = 'Are you sure to delete it?';
const DELETE_SUCCESS = 'Delete success';
export {
INVALID_FORMAT_MSG,
invalidFormatMsg,
ADD_SUCCESS,
ERROR_MSG,
errorMsg,
EDIT_SUCCESS,
CONFIRM_DELETE,
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';
const VALUE = 'value';
@@ -39,7 +39,7 @@ const addValidator = ({ validatorFunc, prop, required = true }: TValidator) => {
required,
validator: {
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 {
ADD_SUCCESS,
EDIT_SUCCESS,
ERROR_MSG,
errorMsg,
} from '../../constants/messages.ts';
import { USER_PATH } from '../../constants/path.ts';
@@ -122,7 +122,7 @@ const UserForm = ({
if (response.statusCode === STATUS_CODE.CREATE) {
toast.success(ADD_SUCCESS);
} else {
throw new Error(ERROR_MSG(response.statusCode, response.msg));
throw new Error(errorMsg(response.statusCode, response.msg));
}
} else {
// Edit request
@@ -135,7 +135,7 @@ const UserForm = ({
if (response.statusCode == STATUS_CODE.OK) {
toast.success(EDIT_SUCCESS);
} else {
throw new Error(ERROR_MSG(response.statusCode, response.msg));
throw new Error(errorMsg(response.statusCode, response.msg));
}
}
// Reload table data