From 77db93905d39190db89f742f0af5f1fc43afbb42 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Mon, 8 Apr 2024 17:11:25 +0800 Subject: [PATCH] fix(console): should stop requesting invitations api for collaborator role (#5650) --- .../console/src/pages/TenantSettings/TenantMembers/hooks.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/console/src/pages/TenantSettings/TenantMembers/hooks.ts b/packages/console/src/pages/TenantSettings/TenantMembers/hooks.ts index 980268115..b154f551f 100644 --- a/packages/console/src/pages/TenantSettings/TenantMembers/hooks.ts +++ b/packages/console/src/pages/TenantSettings/TenantMembers/hooks.ts @@ -7,11 +7,13 @@ import { type TenantInvitationResponse, type TenantMemberResponse } from '@/clou import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider'; import { TenantsContext } from '@/contexts/TenantsProvider'; import { type RequestError } from '@/hooks/use-api'; +import useCurrentTenantScopes from '@/hooks/use-current-tenant-scopes'; import { hasReachedQuotaLimit, hasSurpassedQuotaLimit } from '@/utils/quota'; const useTenantMembersUsage = () => { const { currentPlan } = useContext(SubscriptionDataContext); const { currentTenantId } = useContext(TenantsContext); + const { canInviteMember } = useCurrentTenantScopes(); const cloudApi = useAuthedCloudApi(); @@ -21,7 +23,7 @@ const useTenantMembersUsage = () => { cloudApi.get('/api/tenants/:tenantId/members', { params: { tenantId: currentTenantId } }) ); const { data: invitations } = useSWR( - 'api/tenants/:tenantId/invitations', + canInviteMember && 'api/tenants/:tenantId/invitations', async () => cloudApi.get('/api/tenants/:tenantId/invitations', { params: { tenantId: currentTenantId } }) );