From 0a05aef046ba02788072c0d41b3e918b51abac2f Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Fri, 5 Jan 2024 23:42:52 +0530 Subject: [PATCH] fix: workspace invitations response updated (#3321) --- packages/types/src/workspace.d.ts | 10 +++++++--- web/components/onboarding/invitations.tsx | 2 +- web/pages/invitations/index.tsx | 12 ++++++------ web/pages/workspace-invitations/index.tsx | 8 ++++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/types/src/workspace.d.ts b/packages/types/src/workspace.d.ts index 2fc8d6912..2d7e94d95 100644 --- a/packages/types/src/workspace.d.ts +++ b/packages/types/src/workspace.d.ts @@ -1,5 +1,10 @@ import { EUserWorkspaceRoles } from "constants/workspace"; -import type { IProjectMember, IUser, IUserLite, IWorkspaceViewProps } from "@plane/types"; +import type { + IProjectMember, + IUser, + IUserLite, + IWorkspaceViewProps, +} from "@plane/types"; export interface IWorkspace { readonly id: string; @@ -32,8 +37,7 @@ export interface IWorkspaceMemberInvitation { responded_at: Date; role: EUserWorkspaceRoles; token: string; - workspace: string; - workspace_detail: { + workspace: { id: string; logo: string; name: string; diff --git a/web/components/onboarding/invitations.tsx b/web/components/onboarding/invitations.tsx index 65cf3d7c7..f4f23373d 100644 --- a/web/components/onboarding/invitations.tsx +++ b/web/components/onboarding/invitations.tsx @@ -86,7 +86,7 @@ export const Invitations: React.FC = (props) => { invitations.length > 0 && invitations.map((invitation) => { const isSelected = invitationsRespond.includes(invitation.id); - const invitedWorkspace = workspaces[invitation.workspace]; + const invitedWorkspace = workspaces[invitation.workspace.id]; return (
{ .then((res) => { mutate("USER_WORKSPACES"); const firstInviteId = invitationsRespond[0]; - const redirectWorkspace = invitations?.find((i) => i.id === firstInviteId)?.workspace_detail; + const redirectWorkspace = invitations?.find((i) => i.id === firstInviteId)?.workspace; postHogEventTracker("MEMBER_ACCEPTED", { ...res, state: "SUCCESS", @@ -153,23 +153,23 @@ const UserInvitationsPage: NextPageWithLayout = observer(() => { >
- {invitation.workspace_detail.logo && invitation.workspace_detail.logo.trim() !== "" ? ( + {invitation.workspace.logo && invitation.workspace.logo.trim() !== "" ? ( {invitation.workspace_detail.name} ) : ( - {invitation.workspace_detail.name[0]} + {invitation.workspace.name[0]} )}
-
{truncateText(invitation.workspace_detail.name, 30)}
+
{truncateText(invitation.workspace.name, 30)}

{ROLE[invitation.role]}

{ const handleAccept = () => { if (!invitationDetail) return; workspaceService - .joinWorkspace(invitationDetail.workspace_detail.slug, invitationDetail.id, { + .joinWorkspace(invitationDetail.workspace.slug, invitationDetail.id, { accepted: true, email: invitationDetail.email, }) @@ -55,7 +55,7 @@ const WorkspaceInvitationPage: NextPageWithLayout = observer(() => { const handleReject = () => { if (!invitationDetail) return; workspaceService - .joinWorkspace(invitationDetail.workspace_detail.slug, invitationDetail.id, { + .joinWorkspace(invitationDetail.workspace.slug, invitationDetail.id, { accepted: false, email: invitationDetail.email, }) @@ -78,7 +78,7 @@ const WorkspaceInvitationPage: NextPageWithLayout = observer(() => { {invitationDetail.accepted ? ( <> router.push("/")} /> @@ -86,7 +86,7 @@ const WorkspaceInvitationPage: NextPageWithLayout = observer(() => { ) : (