40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import axios from 'axios';
|
|
import { API_URL_TRANSACTION } from '@/shared/api/api-url-transaction';
|
|
import { resultify } from '@/shared/lib/resultify';
|
|
import { NiceAxiosError } from '@/shared/@types/error';
|
|
import {
|
|
CashReceiptSummaryParams,
|
|
CashReceiptSummaryResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
import { getHeaderUserAgent } from '@/shared/constants/url';
|
|
|
|
export const cashReceiptSummary = (params: CashReceiptSummaryParams) => {
|
|
let headerOptions = {
|
|
menuId: 32,
|
|
apiType: 'SELECT'
|
|
};
|
|
let options = {
|
|
headers: {
|
|
'X-User-Agent': getHeaderUserAgent(headerOptions)
|
|
}
|
|
};
|
|
return resultify(
|
|
axios.post<CashReceiptSummaryResponse>(API_URL_TRANSACTION.cashReceiptSummary(), params, options),
|
|
);
|
|
};
|
|
|
|
export const useCashReceiptSummaryMutation = (options?: UseMutationOptions<CashReceiptSummaryResponse, NiceAxiosError, CashReceiptSummaryParams>) => {
|
|
const mutation = useMutation<CashReceiptSummaryResponse, NiceAxiosError, CashReceiptSummaryParams>({
|
|
...options,
|
|
mutationFn: (params: CashReceiptSummaryParams) => cashReceiptSummary(params),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|