From 3deaaa4b305ee4de1610e64ced40c35603a9e620 Mon Sep 17 00:00:00 2001 From: rax7389 Date: Thu, 6 Aug 2026 00:42:26 +0530 Subject: [PATCH 1/2] feat: filter invitaions list with memeber acess level --- .../__tests__/use-member-management-service.test.ts | 11 +++++++---- .../shared/services/use-member-management-service.ts | 12 ++++++++---- .../member-management/member-management-constants.ts | 5 +++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/react/src/hooks/my-organization/__tests__/use-member-management-service.test.ts b/packages/react/src/hooks/my-organization/__tests__/use-member-management-service.test.ts index a5247b11a..a162263f0 100644 --- a/packages/react/src/hooks/my-organization/__tests__/use-member-management-service.test.ts +++ b/packages/react/src/hooks/my-organization/__tests__/use-member-management-service.test.ts @@ -74,7 +74,7 @@ describe('useMemberManagementService', () => { }); describe('providersQuery', () => { - it('should fetch identity providers when invitations tab is active', async () => { + it('should fetch identity providers with invitable member access levels filter', async () => { const options = createDefaultOptions({ activeTab: 'invitations' }); const { result } = renderService(options); @@ -84,7 +84,7 @@ describe('useMemberManagementService', () => { expect( mockCoreClient.getMyOrganizationApiClient().organization.identityProviders.list, - ).toHaveBeenCalled(); + ).toHaveBeenCalledWith({ member_access_level: ['limited', 'full'] }); }); it('should not fetch identity providers when members tab is active', async () => { @@ -128,7 +128,7 @@ describe('useMemberManagementService', () => { const userStoresGetMock = () => mockCoreClient.getMyOrganizationApiClient().organization.userStores.list; - it('should fetch user stores when a tab is active', async () => { + it('should fetch user stores with enabled and invitable member access levels filter', async () => { const options = createDefaultOptions({ activeTab: 'invitations' }); const { result } = renderService(options); @@ -136,7 +136,10 @@ describe('useMemberManagementService', () => { expect(result.current.userStoresQuery.isSuccess).toBe(true); }); - expect(userStoresGetMock()).toHaveBeenCalled(); + expect(userStoresGetMock()).toHaveBeenCalledWith({ + is_enabled: true, + member_access_level: ['limited', 'full'], + }); }); it('should not fetch user stores when no active tab is provided', async () => { diff --git a/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts b/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts index f1847b531..d66a52330 100644 --- a/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts +++ b/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts @@ -22,6 +22,7 @@ import { useErrorHandler } from '@/hooks/shared/use-error-handler'; import { useTranslator } from '@/hooks/shared/use-translator'; import { DEFAULT_ROLES_PAGE_SIZE, + INVITABLE_MEMBER_ACCESS_LEVELS, MAX_ROLES_AVAILABLE_FOR_ASSIGNMENT, } from '@/lib/constants/my-organization/member-management/member-management-constants'; import { validateRequestRoleForMember } from '@/lib/utils/my-organization/member-management/member-management-utils'; @@ -93,7 +94,9 @@ export function useMemberManagementService( queryFn: async () => { const response: ListIdentityProvidersResponseContent = await coreClient! .getMyOrganizationApiClient() - .organization.identityProviders.list(); + .organization.identityProviders.list({ + member_access_level: [...INVITABLE_MEMBER_ACCESS_LEVELS], + }); const providers = response.identity_providers ?? []; return providers .filter((p) => !!p.id) @@ -109,9 +112,10 @@ export function useMemberManagementService( const userStoresQuery = useQuery({ queryKey: memberManagementQueryKeys.userStores(), queryFn: async () => { - const page = await coreClient! - .getMyOrganizationApiClient() - .organization.userStores.list({ is_enabled: true }); + const page = await coreClient!.getMyOrganizationApiClient().organization.userStores.list({ + is_enabled: true, + member_access_level: [...INVITABLE_MEMBER_ACCESS_LEVELS], + }); const userStores = page.user_stores ?? []; return userStores .filter((store) => !!store.id) diff --git a/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts b/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts index f20a2fdf0..171a5b267 100644 --- a/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts +++ b/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts @@ -24,3 +24,8 @@ export const MAX_ROLES_AVAILABLE_FOR_ASSIGNMENT = 100; * Default page size for the role selector when no search term is active. */ export const DEFAULT_ROLES_PAGE_SIZE = 10; + +/** + * Member access levels that allow invitation creation. + */ +export const INVITABLE_MEMBER_ACCESS_LEVELS = ['limited', 'full'] as const; From a44b34e391b9abc5dee17eddaff0504d058a82a3 Mon Sep 17 00:00:00 2001 From: rax7389 Date: Thu, 6 Aug 2026 16:51:09 +0530 Subject: [PATCH 2/2] chore: reused const --- .../shared/services/use-member-management-service.ts | 7 +++---- .../member-management/member-management-constants.ts | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts b/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts index 08b3e8c5f..c4675df07 100644 --- a/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts +++ b/packages/react/src/hooks/my-organization/shared/services/use-member-management-service.ts @@ -23,7 +23,6 @@ import { useTranslator } from '@/hooks/shared/use-translator'; import { MEMBER_ACCESS_LEVELS } from '@/lib/constants/common-constants'; import { DEFAULT_ROLES_PAGE_SIZE, - INVITABLE_MEMBER_ACCESS_LEVELS, MAX_ROLES_AVAILABLE_FOR_ASSIGNMENT, } from '@/lib/constants/my-organization/member-management/member-management-constants'; import { isIdpKnownResponse } from '@/lib/utils/my-organization/idp-management/idp-management-utils'; @@ -97,9 +96,9 @@ export function useMemberManagementService( const response: ListIdentityProvidersResponseContent = await coreClient! .getMyOrganizationApiClient() .organization.identityProviders.list({ - member_access_level: [...INVITABLE_MEMBER_ACCESS_LEVELS], + member_access_level: [...MEMBER_ACCESS_LEVELS], }); - const providers = response.identity_providers ?? []; + const providers = response.identity_providers?.filter(isIdpKnownResponse) ?? []; return providers .filter((p) => !!p.id) .map((p) => ({ @@ -116,7 +115,7 @@ export function useMemberManagementService( queryFn: async () => { const page = await coreClient!.getMyOrganizationApiClient().organization.userStores.list({ is_enabled: true, - member_access_level: [...INVITABLE_MEMBER_ACCESS_LEVELS], + member_access_level: [...MEMBER_ACCESS_LEVELS], }); const userStores = page.user_stores ?? []; return userStores diff --git a/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts b/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts index 171a5b267..f20a2fdf0 100644 --- a/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts +++ b/packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts @@ -24,8 +24,3 @@ export const MAX_ROLES_AVAILABLE_FOR_ASSIGNMENT = 100; * Default page size for the role selector when no search term is active. */ export const DEFAULT_ROLES_PAGE_SIZE = 10; - -/** - * Member access levels that allow invitation creation. - */ -export const INVITABLE_MEMBER_ACCESS_LEVELS = ['limited', 'full'] as const;