Merge pull request #1726 from automatisch/AUT-839

refactor: rewrite usePermissionCatalog with RQ
This commit is contained in:
Ali BARIN
2024-03-15 15:28:33 +01:00
committed by GitHub
6 changed files with 29 additions and 47 deletions

View File

@@ -1,6 +1,18 @@
import { useQuery } from '@apollo/client';
import { GET_PERMISSION_CATALOG } from 'graphql/queries/get-permission-catalog.ee';
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function usePermissionCatalog() {
const { data, loading } = useQuery(GET_PERMISSION_CATALOG);
return { permissionCatalog: data?.getPermissionCatalog, loading };
const query = useQuery({
queryKey: ['permissionCatalog'],
queryFn: async ({ signal }) => {
const { data } = await api.get('/v1/admin/permissions/catalog', {
signal,
});
return data;
},
});
return query;
}