30 lines
833 B
TypeScript
30 lines
833 B
TypeScript
import axios from 'axios';
|
|
import { API_URL_HOME } from '@/shared/api/api-url-home';
|
|
import { resultify } from '@/shared/lib/resultify';
|
|
import { NiceAxiosError } from '@/shared/@types/error';
|
|
import {
|
|
HomeMonthParams,
|
|
HomeMonthResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
|
|
export const homeMonth = (params: HomeMonthParams) => {
|
|
return resultify(
|
|
axios.post<HomeMonthResponse>(API_URL_HOME.homeMonth(), params),
|
|
);
|
|
};
|
|
|
|
export const useHomeMonthwMutation = (options?: UseMutationOptions<HomeMonthResponse, NiceAxiosError, HomeMonthParams>) => {
|
|
const mutation = useMutation<HomeMonthResponse, NiceAxiosError, HomeMonthParams>({
|
|
...options,
|
|
mutationFn: (params: HomeMonthParams) => homeMonth(params),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|