From 705b33377cfcdf7a2bfbb0fe6ddcbe34794e25af Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:11:13 +0530 Subject: [PATCH] fix: members list endpoint authorization (#2571) * fix: members list endpoint authorization * chore: update user types --- web/layouts/auth-layout/project-wrapper.tsx | 8 +++----- web/layouts/auth-layout/workspace-wrapper.tsx | 10 +++------- web/types/users.d.ts | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/web/layouts/auth-layout/project-wrapper.tsx b/web/layouts/auth-layout/project-wrapper.tsx index 688d97129..91645222e 100644 --- a/web/layouts/auth-layout/project-wrapper.tsx +++ b/web/layouts/auth-layout/project-wrapper.tsx @@ -38,7 +38,7 @@ export const ProjectAuthWrapper: FC = observer((props) => { : null ); // fetching user project member information - const { data: projectMemberInfo } = useSWR( + useSWR( workspaceSlug && projectId ? `PROJECT_MEMBERS_ME_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId ? () => userStore.fetchUserProjectInfo(workspaceSlug.toString(), projectId.toString()) @@ -53,10 +53,8 @@ export const ProjectAuthWrapper: FC = observer((props) => { ); // fetching project members useSWR( - workspaceSlug && projectId && projectMemberInfo && [20, 15].includes(projectMemberInfo.role) - ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` - : null, - workspaceSlug && projectId && projectMemberInfo && [20, 15].includes(projectMemberInfo.role) + workspaceSlug && projectId ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId ? () => projectStore.fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) : null ); diff --git a/web/layouts/auth-layout/workspace-wrapper.tsx b/web/layouts/auth-layout/workspace-wrapper.tsx index d218bf68c..e1ae8e4db 100644 --- a/web/layouts/auth-layout/workspace-wrapper.tsx +++ b/web/layouts/auth-layout/workspace-wrapper.tsx @@ -22,7 +22,7 @@ export const WorkspaceAuthWrapper: FC = observer((props) // fetching all workspaces useSWR(`USER_WORKSPACES_LIST`, () => workspaceStore.fetchWorkspaces()); // fetching user workspace information - const { data: workspaceMemberInfo } = useSWR( + useSWR( workspaceSlug ? `WORKSPACE_MEMBERS_ME_${workspaceSlug}` : null, workspaceSlug ? () => userStore.fetchUserWorkspaceInfo(workspaceSlug.toString()) : null ); @@ -33,12 +33,8 @@ export const WorkspaceAuthWrapper: FC = observer((props) ); // fetch workspace members useSWR( - workspaceSlug && workspaceMemberInfo && [20, 15].includes(workspaceMemberInfo.role) - ? `WORKSPACE_MEMBERS_${workspaceSlug}` - : null, - workspaceSlug && workspaceMemberInfo && [20, 15].includes(workspaceMemberInfo.role) - ? () => workspaceStore.fetchWorkspaceMembers(workspaceSlug.toString()) - : null + workspaceSlug ? `WORKSPACE_MEMBERS_${workspaceSlug}` : null, + workspaceSlug ? () => workspaceStore.fetchWorkspaceMembers(workspaceSlug.toString()) : null ); // fetch workspace labels useSWR( diff --git a/web/types/users.d.ts b/web/types/users.d.ts index 252f4fe80..2c93ff764 100644 --- a/web/types/users.d.ts +++ b/web/types/users.d.ts @@ -64,7 +64,7 @@ export interface IUserLite { } export interface IUserMemberLite extends IUserLite { - email: string; + email?: string; } export interface IUserActivity {