29 lines
827 B
TypeScript
29 lines
827 B
TypeScript
import axios from 'axios';
|
|
import { API_URL_USER } from '@/shared/api/api-url-user';
|
|
import { resultify } from '@/shared/lib/resultify';
|
|
import { NiceAxiosError } from '@/shared/@types/error';
|
|
import {
|
|
UserExistsUseridResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
|
|
export const userExistsUserid = (usrId: string) => {
|
|
return resultify(
|
|
axios.post<UserExistsUseridResponse>(API_URL_USER.userExistsUserid(usrId)),
|
|
);
|
|
};
|
|
|
|
export const useUserExistsUseridMutation = (options?: UseMutationOptions<UserExistsUseridResponse, NiceAxiosError, string>) => {
|
|
const mutation = useMutation<UserExistsUseridResponse, NiceAxiosError, string>({
|
|
...options,
|
|
mutationFn: (usrId: string) => userExistsUserid(usrId),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|