refactor: rewrite usePaddleInfo with RQ

This commit is contained in:
Rıdvan Akca
2024-03-12 17:21:44 +03:00
parent f07b6d105a
commit 7a8e8c1f3e
6 changed files with 36 additions and 40 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;
}