Merge pull request #1715 from automatisch/AUT-698
refactor: rewrite usePaddleInfo and usePaymentPlans with RQ
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user