40 lines
1.1 KiB
TypeScript
40 lines
1.1 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 {
|
|
BillingChargeParams,
|
|
BillingChargeResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
import { getHeaderUserAgent } from '@/shared/constants/url';
|
|
|
|
export const billingCharge = (params: BillingChargeParams) => {
|
|
let headerOptions = {
|
|
menuId: 34,
|
|
apiType: 'INSERT'
|
|
};
|
|
let options = {
|
|
headers: {
|
|
'X-User-Agent': getHeaderUserAgent(headerOptions)
|
|
}
|
|
};
|
|
return resultify(
|
|
axios.post<BillingChargeResponse>(API_URL_TRANSACTION.billingCharge(), params, options),
|
|
);
|
|
};
|
|
|
|
export const useBillingChargeMutation = (options?: UseMutationOptions<BillingChargeResponse, NiceAxiosError, BillingChargeParams>) => {
|
|
const mutation = useMutation<BillingChargeResponse, NiceAxiosError, BillingChargeParams>({
|
|
...options,
|
|
mutationFn: (params: BillingChargeParams) => billingCharge(params),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|