forked from github/plane
fix: workspace invitation status fixes (#3279)
This commit is contained in:
parent
f132fe59ae
commit
5de94c575a
@ -28,7 +28,8 @@ type Props = {
|
|||||||
display_name: string;
|
display_name: string;
|
||||||
role: TUserWorkspaceRole;
|
role: TUserWorkspaceRole;
|
||||||
status: boolean;
|
status: boolean;
|
||||||
member: boolean;
|
is_member: boolean;
|
||||||
|
responded_at: string | null;
|
||||||
accountCreated: boolean;
|
accountCreated: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -102,9 +103,8 @@ export const WorkspaceMembersListItem: FC<Props> = observer((props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRemove = async () => {
|
const handleRemove = async () => {
|
||||||
if (member.member) {
|
if (member.is_member) {
|
||||||
const memberId = member.memberId;
|
const memberId = member.memberId;
|
||||||
|
|
||||||
if (memberId === currentUser?.id) await handleLeaveWorkspace();
|
if (memberId === currentUser?.id) await handleLeaveWorkspace();
|
||||||
else await handleRemoveMember();
|
else await handleRemoveMember();
|
||||||
} else await handleRemoveInvitation();
|
} else await handleRemoveInvitation();
|
||||||
@ -154,7 +154,7 @@ export const WorkspaceMembersListItem: FC<Props> = observer((props) => {
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
{member.member ? (
|
{member.is_member ? (
|
||||||
<Link href={`/${workspaceSlug}/profile/${member.memberId}`}>
|
<Link href={`/${workspaceSlug}/profile/${member.memberId}`}>
|
||||||
<span className="text-sm font-medium">
|
<span className="text-sm font-medium">
|
||||||
{member.first_name} {member.last_name}
|
{member.first_name} {member.last_name}
|
||||||
@ -175,16 +175,21 @@ export const WorkspaceMembersListItem: FC<Props> = observer((props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 text-xs">
|
<div className="flex items-center gap-2 text-xs">
|
||||||
{!member?.status && (
|
{!member?.status && !member.responded_at && (
|
||||||
<div className="flex items-center justify-center rounded bg-yellow-500/20 px-2.5 py-1 text-center text-xs font-medium text-yellow-500">
|
<div className="flex items-center justify-center rounded bg-yellow-500/20 px-2.5 py-1 text-center text-xs font-medium text-yellow-500">
|
||||||
<p>Pending</p>
|
<p>Pending</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{member?.status && !member?.accountCreated && (
|
{member?.status && !member.is_member && (
|
||||||
<div className="flex items-center justify-center rounded bg-blue-500/20 px-2.5 py-1 text-center text-xs font-medium text-blue-500">
|
<div className="flex items-center justify-center rounded bg-blue-500/20 px-2.5 py-1 text-center text-xs font-medium text-blue-500">
|
||||||
<p>Account not created</p>
|
<p>Account not created</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{!member?.status && member.responded_at && (
|
||||||
|
<div className="flex items-center justify-center rounded bg-red-500/20 px-2.5 py-1 text-center text-xs font-medium text-red-500">
|
||||||
|
<p>Rejected</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<CustomSelect
|
<CustomSelect
|
||||||
customButton={
|
customButton={
|
||||||
<div className="item-center flex gap-1 rounded px-2 py-0.5">
|
<div className="item-center flex gap-1 rounded px-2 py-0.5">
|
||||||
|
@ -52,6 +52,19 @@ const WorkspaceInvitationPage: NextPageWithLayout = () => {
|
|||||||
.catch((err) => console.error(err));
|
.catch((err) => console.error(err));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleReject = () => {
|
||||||
|
if (!invitationDetail) return;
|
||||||
|
workspaceService
|
||||||
|
.joinWorkspace(invitationDetail.workspace.slug, invitationDetail.id, {
|
||||||
|
accepted: false,
|
||||||
|
email: invitationDetail.email,
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
router.push("/");
|
||||||
|
})
|
||||||
|
.catch((err) => console.error(err));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col items-center justify-center px-3">
|
<div className="flex h-full w-full flex-col items-center justify-center px-3">
|
||||||
{invitationDetail ? (
|
{invitationDetail ? (
|
||||||
@ -77,13 +90,7 @@ const WorkspaceInvitationPage: NextPageWithLayout = () => {
|
|||||||
description="Your workspace is where you'll create projects, collaborate on your issues, and organize different streams of work in your Plane account."
|
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} />
|
<EmptySpaceItem Icon={Check} title="Accept" action={handleAccept} />
|
||||||
<EmptySpaceItem
|
<EmptySpaceItem Icon={X} title="Ignore" action={handleReject} />
|
||||||
Icon={X}
|
|
||||||
title="Ignore"
|
|
||||||
action={() => {
|
|
||||||
router.push("/");
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</EmptySpace>
|
</EmptySpace>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -114,8 +114,8 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
|
|||||||
display_name: item.email,
|
display_name: item.email,
|
||||||
role: item.role,
|
role: item.role,
|
||||||
status: item.accepted,
|
status: item.accepted,
|
||||||
member: false,
|
is_member: false,
|
||||||
accountCreated: item.accepted,
|
responded_at: item.responded_at,
|
||||||
})) || []),
|
})) || []),
|
||||||
...(this.workspaceMembers?.map((item) => ({
|
...(this.workspaceMembers?.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@ -127,8 +127,8 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
|
|||||||
display_name: item.member?.display_name,
|
display_name: item.member?.display_name,
|
||||||
role: item.role,
|
role: item.role,
|
||||||
status: true,
|
status: true,
|
||||||
member: true,
|
is_member: true,
|
||||||
accountCreated: true,
|
responded_at: "accepted",
|
||||||
})) || []),
|
})) || []),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user