add payment page
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import * as api from '../service/PaymentService';
|
||||
import type { GetPaymentsParams } from '../types/Types';
|
||||
|
||||
export const useGetPayments = (params: GetPaymentsParams) => {
|
||||
return useQuery({
|
||||
queryKey: ['payments', params],
|
||||
queryFn: () => api.getPayments(params),
|
||||
});
|
||||
};
|
||||
|
||||
export const useConfirmCashPayment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (paymentId: string) => api.confirmCashPayment(paymentId),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['payments'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const useDenyCashPayment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (paymentId: string) => api.denyCashPayment(paymentId),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['payments'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const useVerifyOnlinePayment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (token: string) => api.verifyOnlinePayment(token),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['payments'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user