30 lines
840 B
TypeScript
30 lines
840 B
TypeScript
import axios from 'axios';
|
|
import { API_URL } from '@/shared/api/urls';
|
|
import { resultify } from '@/shared/lib/resultify';
|
|
import { CBDCAxiosError } from '@/shared/@types/error';
|
|
import {
|
|
CounselListParams,
|
|
CounselListResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
|
|
export const counselList = (params: CounselListParams) => {
|
|
return resultify(
|
|
axios.post<CounselListResponse>(API_URL.counselList(), params),
|
|
);
|
|
};
|
|
|
|
export const useCounselListMutation = (options?: UseMutationOptions<CounselListResponse, CBDCAxiosError, CounselListParams>) => {
|
|
const mutation = useMutation<CounselListResponse, CBDCAxiosError, CounselListParams>({
|
|
...options,
|
|
mutationFn: (params: CounselListParams) => counselList(params),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|