refactor: rewrite usePaymentPlans with RQ

This commit is contained in:
Rıdvan Akca
2024-03-12 18:03:14 +03:00
parent 7a8e8c1f3e
commit 2ebe71ddd0
7 changed files with 31 additions and 46 deletions

View File

@@ -1,9 +1,18 @@
import { useQuery } from '@apollo/client';
import { GET_PAYMENT_PLANS } from 'graphql/queries/get-payment-plans.ee';
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function usePaymentPlans() {
const { data, loading } = useQuery(GET_PAYMENT_PLANS);
return {
plans: data?.getPaymentPlans || [],
loading,
};
const query = useQuery({
queryKey: ['paymentPlans'],
queryFn: async ({ signal }) => {
const { data } = await api.get('/v1/payment/plans', {
signal,
});
return data;
},
});
return query;
}