첫 커밋
This commit is contained in:
29
src/entities/user/api/use-login-mutation.ts
Normal file
29
src/entities/user/api/use-login-mutation.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '@/shared/api/urls';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
LoginParams,
|
||||
LoginResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
export const login = (params: LoginParams) => {
|
||||
return resultify(
|
||||
axios.post<LoginResponse>(API_URL.login(), params),
|
||||
);
|
||||
};
|
||||
|
||||
export const useLoginMutation = (options?: UseMutationOptions<LoginResponse, CBDCAxiosError, LoginParams>) => {
|
||||
const mutation = useMutation<LoginResponse, CBDCAxiosError, LoginParams>({
|
||||
...options,
|
||||
mutationFn: (params: LoginParams) => login(params),
|
||||
});
|
||||
|
||||
return {
|
||||
...mutation,
|
||||
};
|
||||
};
|
||||
29
src/entities/user/api/use-user-create-mutation.ts
Normal file
29
src/entities/user/api/use-user-create-mutation.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '@/shared/api/urls';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
UserCreateParams,
|
||||
UserCreateResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
export const userCreate = (params: UserCreateParams) => {
|
||||
return resultify(
|
||||
axios.post<UserCreateResponse>(API_URL.userCreate(), params),
|
||||
);
|
||||
};
|
||||
|
||||
export const useUserCreateMutation = (options?: UseMutationOptions<UserCreateResponse, CBDCAxiosError, UserCreateParams>) => {
|
||||
const mutation = useMutation<UserCreateResponse, CBDCAxiosError, UserCreateParams>({
|
||||
...options,
|
||||
mutationFn: (params: UserCreateParams) => userCreate(params),
|
||||
});
|
||||
|
||||
return {
|
||||
...mutation,
|
||||
};
|
||||
};
|
||||
29
src/entities/user/api/use-user-exists-userid-mutation.ts
Normal file
29
src/entities/user/api/use-user-exists-userid-mutation.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '@/shared/api/urls';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
UserExistsUseridParams,
|
||||
UserExistsUseridResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
export const userExistsUserid = (params: UserExistsUseridParams) => {
|
||||
return resultify(
|
||||
axios.post<UserExistsUseridResponse>(API_URL.userExistsUserid(), params),
|
||||
);
|
||||
};
|
||||
|
||||
export const useUserExistsUseridMutation = (options?: UseMutationOptions<UserExistsUseridResponse, CBDCAxiosError, UserExistsUseridParams>) => {
|
||||
const mutation = useMutation<UserExistsUseridResponse, CBDCAxiosError, UserExistsUseridParams>({
|
||||
...options,
|
||||
mutationFn: (params: UserExistsUseridParams) => userExistsUserid(params),
|
||||
});
|
||||
|
||||
return {
|
||||
...mutation,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user