fix: workspace invitations response updated (#3321)

This commit is contained in:
Anmol Singh Bhatia 2024-01-05 23:42:52 +05:30 committed by GitHub
parent 2f10f35191
commit 81f6557908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 14 deletions

View File

@ -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;

View File

@ -86,7 +86,7 @@ export const Invitations: React.FC<Props> = (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 (
<div
key={invitation.id}

View File

@ -83,7 +83,7 @@ const UserInvitationsPage: NextPageWithLayout = observer(() => {
.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(() => {
>
<div className="flex-shrink-0">
<div className="grid h-9 w-9 place-items-center rounded">
{invitation.workspace_detail.logo && invitation.workspace_detail.logo.trim() !== "" ? (
{invitation.workspace.logo && invitation.workspace.logo.trim() !== "" ? (
<img
src={invitation.workspace_detail.logo}
src={invitation.workspace.logo}
height="100%"
width="100%"
className="rounded"
alt={invitation.workspace_detail.name}
alt={invitation.workspace.name}
/>
) : (
<span className="grid h-9 w-9 place-items-center rounded bg-gray-700 px-3 py-1.5 uppercase text-white">
{invitation.workspace_detail.name[0]}
{invitation.workspace.name[0]}
</span>
)}
</div>
</div>
<div className="min-w-0 flex-1">
<div className="text-sm font-medium">{truncateText(invitation.workspace_detail.name, 30)}</div>
<div className="text-sm font-medium">{truncateText(invitation.workspace.name, 30)}</div>
<p className="text-xs text-custom-text-200">{ROLE[invitation.role]}</p>
</div>
<span

View File

@ -38,7 +38,7 @@ const WorkspaceInvitationPage: NextPageWithLayout = observer(() => {
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 ? (
<>
<EmptySpace
title={`You are already a member of ${invitationDetail.workspace_detail.name}`}
title={`You are already a member of ${invitationDetail.workspace.name}`}
description="Your workspace is where you'll create projects, collaborate on your issues, and organize different streams of work in your Plane account."
>
<EmptySpaceItem Icon={Boxes} title="Continue to Dashboard" action={() => router.push("/")} />
@ -86,7 +86,7 @@ const WorkspaceInvitationPage: NextPageWithLayout = observer(() => {
</>
) : (
<EmptySpace
title={`You have been invited to ${invitationDetail.workspace_detail.name}`}
title={`You have been invited to ${invitationDetail.workspace.name}`}
description="Your workspace is where you'll create projects, collaborate on your issues, and organize different streams of work in your Plane account."
>
<EmptySpaceItem Icon={Check} title="Accept" action={handleAccept} />