test
This commit is contained in:
29
src/entities/payment/api/use-payment-card-mutation.ts
Normal file
29
src/entities/payment/api/use-payment-card-mutation.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL_PAYMENT } from '@/shared/api/api-url-payment';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
PaymentCardParams,
|
||||
PaymentCardResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
export const paymentCard = (params: PaymentCardParams) => {
|
||||
return resultify(
|
||||
axios.post<PaymentCardResponse>(API_URL_PAYMENT.paymentCard(), params),
|
||||
);
|
||||
};
|
||||
|
||||
export const usePaymentCardMutation = (options?: UseMutationOptions<PaymentCardResponse, CBDCAxiosError, PaymentCardParams>) => {
|
||||
const mutation = useMutation<PaymentCardResponse, CBDCAxiosError, PaymentCardParams>({
|
||||
...options,
|
||||
mutationFn: (params: PaymentCardParams) => paymentCard(params),
|
||||
});
|
||||
|
||||
return {
|
||||
...mutation,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user