mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-23 04:19:48 +00:00
Implement edit, delete user
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user