30 lines
913 B
TypeScript
30 lines
913 B
TypeScript
import axios from 'axios';
|
|
import { API_URL_TRANSACTION } from '@/shared/api/api-url-transaction';
|
|
import { resultify } from '@/shared/lib/resultify';
|
|
import { CBDCAxiosError } from '@/shared/@types/error';
|
|
import {
|
|
CashReceiptDetailParams,
|
|
DetailResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
|
|
export const cashReceiptDetail = (params: CashReceiptDetailParams) => {
|
|
return resultify(
|
|
axios.post<DetailResponse>(API_URL_TRANSACTION.cashReceiptDetail(), params),
|
|
);
|
|
};
|
|
|
|
export const useCashReceiptDetailMutation = (options?: UseMutationOptions<DetailResponse, CBDCAxiosError, CashReceiptDetailParams>) => {
|
|
const mutation = useMutation<DetailResponse, CBDCAxiosError, CashReceiptDetailParams>({
|
|
...options,
|
|
mutationFn: (params: CashReceiptDetailParams) => cashReceiptDetail(params),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|