Files
nice-app-web/src/entities/user/api/use-business-property-mutation.ts
2025-10-24 10:28:34 +09:00

30 lines
923 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 {
BusinessPropertyParams,
BusinessPropertyResponse
} from '../model/types';
import {
useMutation,
UseMutationOptions
} from '@tanstack/react-query';
export const businessProperty = (params: BusinessPropertyParams) => {
return resultify(
axios.post<BusinessPropertyResponse>(API_URL_USER.businessProperty(), params),
);
};
export const useBusinessPropertyMutation = (options?: UseMutationOptions<BusinessPropertyResponse, NiceAxiosError, BusinessPropertyParams>) => {
const mutation = useMutation<BusinessPropertyResponse, NiceAxiosError, BusinessPropertyParams>({
...options,
mutationFn: (params: BusinessPropertyParams) => businessProperty(params),
});
return {
...mutation,
};
};