Merge pull request #1715 from automatisch/AUT-698

refactor: rewrite usePaddleInfo and usePaymentPlans with RQ
This commit is contained in:
Ali BARIN
2024-03-13 09:20:39 +01:00
committed by GitHub
10 changed files with 59 additions and 78 deletions

View File

@@ -1,10 +1,17 @@
import { useQuery } from '@apollo/client';
import { GET_PADDLE_INFO } from 'graphql/queries/get-paddle-info.ee';
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function usePaddleInfo() {
const { data, loading } = useQuery(GET_PADDLE_INFO);
return {
sandbox: data?.getPaddleInfo?.sandbox,
vendorId: data?.getPaddleInfo?.vendorId,
loading,
};
const query = useQuery({
queryKey: ['paddleInfo'],
queryFn: async ({ signal }) => {
const { data } = await api.get('/v1/payment/paddle-info', {
signal,
});
return data;
},
});
return query;
}

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