refactor: rewrite useApps with RQ
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { GET_APPS } from 'graphql/queries/get-apps';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useApps(variables) {
|
||||
const { data, loading } = useQuery(GET_APPS, {
|
||||
variables,
|
||||
const query = useQuery({
|
||||
queryKey: ['apps', variables],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
const { data } = await api.get('/v1/apps', {
|
||||
params: variables,
|
||||
signal,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
const apps = data?.getApps;
|
||||
return {
|
||||
apps,
|
||||
loading,
|
||||
};
|
||||
|
||||
return query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user