Implement edit, delete user

This commit is contained in:
2023-10-29 21:33:49 +07:00
parent 2d936a9fdf
commit b45130c151
13 changed files with 254 additions and 81 deletions
@@ -8,9 +8,6 @@ export const sendRequest = async (
body: BodyInit | null | undefined,
method: TMethodRequest = 'GET',
): Promise<TResponse> => {
const controller = new AbortController();
const signal = controller.signal;
const response = await fetch(BASE_URL + path, {
method,
body,
@@ -19,7 +16,6 @@ export const sendRequest = async (
'Accept': 'application/json',
'Content-Type': 'application/json',
},
signal,
});
return {
+10 -1
View File
@@ -1,5 +1,5 @@
import { INVALID_FORMAT_MSG } from '../constants/messages';
import { TKeyValue, TPropValues, TStateSchema } from '../globals/types';
import { TKeyValue, TPropValues, TStateSchema, TUser } from '../globals/types';
const VALUE = 'value';
const ERROR = 'error';
@@ -44,10 +44,19 @@ const addValidator = ({ validatorFunc, prop, required = true }: TValidator) => {
};
};
const getValueUser = (user: TUser | null = null, prop: string): string => {
if (user) {
return user[prop as keyof TUser];
}
return '';
};
export {
isObject,
isRequired,
getPropValues,
getValueUser,
addValidator,
VALUE,
ERROR,