feat(auth): add loading state for user and role management (#1188)
This commit is contained in:
@@ -3,8 +3,13 @@ import { IPermissionCatalog } from '@automatisch/types';
|
||||
|
||||
import { GET_PERMISSION_CATALOG } from 'graphql/queries/get-permission-catalog.ee';
|
||||
|
||||
export default function usePermissionCatalog(): IPermissionCatalog {
|
||||
const { data } = useQuery(GET_PERMISSION_CATALOG);
|
||||
type UsePermissionCatalogReturn = {
|
||||
permissionCatalog: IPermissionCatalog;
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
return data?.getPermissionCatalog;
|
||||
export default function usePermissionCatalog(): UsePermissionCatalogReturn {
|
||||
const { data, loading } = useQuery(GET_PERMISSION_CATALOG);
|
||||
|
||||
return { permissionCatalog: data?.getPermissionCatalog, loading };
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import { GET_ROLE } from 'graphql/queries/get-role.ee';
|
||||
|
||||
type QueryResponse = {
|
||||
getRole: IRole;
|
||||
}
|
||||
};
|
||||
|
||||
export default function useRole(roleId?: string) {
|
||||
const [getRole, { data, loading }] = useLazyQuery<QueryResponse>(GET_ROLE);
|
||||
@@ -15,14 +15,14 @@ export default function useRole(roleId?: string) {
|
||||
if (roleId) {
|
||||
getRole({
|
||||
variables: {
|
||||
id: roleId
|
||||
}
|
||||
id: roleId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}, [roleId]);
|
||||
|
||||
return {
|
||||
role: data?.getRole,
|
||||
loading
|
||||
loading,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user