Files
nice-app-web/src/entities/transaction/api/use-billing-charge-mutation.ts
focp212@naver.com f4963143aa log 관련
2025-10-29 17:11:48 +09:00

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,
};
};