refactor: rewrite useAppConfig with RQ

This commit is contained in:
Rıdvan Akca
2024-03-07 18:13:18 +03:00
parent bd5aedd83f
commit 63b9943203
9 changed files with 72 additions and 71 deletions

View File

@@ -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;
}