@@ -2,25 +2,17 @@ import {
22 useMutation , useQuery , useQueryClient , useSuspenseQuery ,
33} from '@tanstack/react-query' ;
44import { appId } from '@src/constants' ;
5- import { LibraryMetadata , TeamMember } from '@src/types' ;
5+ import { LibraryMetadata } from '@src/types' ;
66import {
7- assignTeamMembersRole ,
8- AssignTeamMembersRoleRequest ,
9- getLibrary , getPermissionsByRole , getTeamMembers , PermissionsByRole , QuerySettings ,
7+ assignTeamMembersRole , AssignTeamMembersRoleRequest , getLibrary , getPermissionsByRole , getTeamMembers ,
8+ GetTeamMembersResponse , PermissionsByRole , QuerySettings ,
109} from './api' ;
1110
1211const authzQueryKeys = {
1312 all : [ appId , 'authz' ] as const ,
14- teamMembers : ( object : string , querySettings ?: QuerySettings ) => [
15- ...authzQueryKeys . all ,
16- 'teamMembers' ,
17- object ,
18- querySettings ?. roles ?? null ,
19- querySettings ?. search ?? null ,
20- querySettings ?. ordering ?? null ,
21- querySettings ?. pageSize ?? 10 ,
22- querySettings ?. pageIndex ?? 0 ,
23- ] as const ,
13+ teamMembersAll : ( scope : string ) => [ ...authzQueryKeys . all , 'teamMembers' , scope ] as const ,
14+ teamMembers : ( scope : string , querySettings ?: QuerySettings ) => [
15+ ...authzQueryKeys . teamMembersAll ( scope ) , querySettings ] as const ,
2416 permissionsByRole : ( scope : string ) => [ ...authzQueryKeys . all , 'permissionsByRole' , scope ] as const ,
2517 library : ( libraryId : string ) => [ ...authzQueryKeys . all , 'library' , libraryId ] as const ,
2618} ;
@@ -29,24 +21,20 @@ const authzQueryKeys = {
2921 * React Query hook to fetch all team members for a specific object/scope.
3022 * It retrieves the full list of members who have access to the given scope.
3123 *
32- * @param object - The unique identifier of the object/scope
24+ * @param scope - The unique identifier of the object/scope
3325 * @param querySettings - Optional query parameters for filtering, sorting, and pagination
3426 *
3527 * @example
3628 * ```tsx
3729 * const { data: teamMembers, isLoading, isError } = useTeamMembers('lib:123', querySettings);
3830 * ```
3931 */
40- export const useTeamMembers = ( object : string , querySettings : QuerySettings ) => {
41- const queryKey = authzQueryKeys . teamMembers ( object , querySettings ) ;
42-
43- return useQuery < TeamMember [ ] , Error > ( {
44- queryKey,
45- queryFn : ( ) => getTeamMembers ( object , querySettings ) ,
46- staleTime : 1000 * 60 * 30 , // refetch after 30 minutes
47- refetchOnWindowFocus : false ,
48- } ) ;
49- } ;
32+ export const useTeamMembers = ( scope : string , querySettings : QuerySettings ) => useQuery < GetTeamMembersResponse , Error > ( {
33+ queryKey : authzQueryKeys . teamMembers ( scope , querySettings ) ,
34+ queryFn : ( ) => getTeamMembers ( scope , querySettings ) ,
35+ staleTime : 1000 * 60 * 30 , // refetch after 30 minutes
36+ refetchOnWindowFocus : false ,
37+ } ) ;
5038
5139/**
5240 * React Query hook to fetch all the roles for the specific object/scope.
0 commit comments