refactor: rewrite useAppConfig with RQ
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { GET_APP_CONFIG } from 'graphql/queries/get-app-config.ee';
|
||||
export default function useAppConfig(key) {
|
||||
const { data, loading } = useQuery(GET_APP_CONFIG, {
|
||||
variables: { key },
|
||||
context: { autoSnackbar: false },
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useAppConfig(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['appConfig', appKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
const { data } = await api.get(`/v1/app-configs/${appKey}`, {
|
||||
signal,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
const appConfig = data?.getAppConfig;
|
||||
return {
|
||||
appConfig,
|
||||
loading,
|
||||
};
|
||||
|
||||
return query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user