Merge pull request #1718 from automatisch/AUT-830

refactor: rewrite useInvoices with RQ
This commit is contained in:
Ali BARIN
2024-03-15 13:22:21 +01:00
committed by GitHub
6 changed files with 24 additions and 52 deletions

View File

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