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