Files
nice-app-web/src/entities/payment/api/use-payment-card-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_PAYMENT } from '@/shared/api/api-url-payment';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
PaymentCardParams,
PaymentCardResponse
} from '../model/types';
import {
useMutation,
UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';
export const paymentCard = (params: PaymentCardParams) => {
let headerOptions = {
menuId: 42,
apiType: 'SELECT'
};
let options = {
headers: {
'X-User-Agent': getHeaderUserAgent(headerOptions)
}
};
return resultify(
axios.post<PaymentCardResponse>(API_URL_PAYMENT.paymentCard(), params),
);
};
export const usePaymentCardMutation = (options?: UseMutationOptions<PaymentCardResponse, NiceAxiosError, PaymentCardParams>) => {
const mutation = useMutation<PaymentCardResponse, NiceAxiosError, PaymentCardParams>({
...options,
mutationFn: (params: PaymentCardParams) => paymentCard(params),
});
return {
...mutation,
};
};