forked from github/plane
fix: showing alert on error while deleting workspace member or invited member (#1746)
style: showing 'Leave' for current user
This commit is contained in:
parent
98c7453741
commit
a66a0680df
@ -115,30 +115,48 @@ const MembersSettings: NextPage = () => {
|
|||||||
handleDelete={async () => {
|
handleDelete={async () => {
|
||||||
if (!workspaceSlug) return;
|
if (!workspaceSlug) return;
|
||||||
if (selectedRemoveMember) {
|
if (selectedRemoveMember) {
|
||||||
await workspaceService.deleteWorkspaceMember(
|
workspaceService
|
||||||
workspaceSlug as string,
|
.deleteWorkspaceMember(workspaceSlug as string, selectedRemoveMember)
|
||||||
selectedRemoveMember
|
.catch((err) => {
|
||||||
);
|
const error = err?.error;
|
||||||
mutateMembers(
|
setToastAlert({
|
||||||
(prevData) => prevData?.filter((item) => item.id !== selectedRemoveMember),
|
type: "error",
|
||||||
false
|
title: "Error",
|
||||||
|
message: error || "Something went wrong",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
mutateMembers((prevData) =>
|
||||||
|
prevData?.filter((item) => item.id !== selectedRemoveMember)
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (selectedInviteRemoveMember) {
|
if (selectedInviteRemoveMember) {
|
||||||
await workspaceService.deleteWorkspaceInvitations(
|
|
||||||
workspaceSlug as string,
|
|
||||||
selectedInviteRemoveMember
|
|
||||||
);
|
|
||||||
mutateInvitations(
|
mutateInvitations(
|
||||||
(prevData) => prevData?.filter((item) => item.id !== selectedInviteRemoveMember),
|
(prevData) => prevData?.filter((item) => item.id !== selectedInviteRemoveMember),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
workspaceService
|
||||||
|
.deleteWorkspaceInvitations(workspaceSlug as string, selectedInviteRemoveMember)
|
||||||
|
.then(() => {
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
type: "success",
|
type: "success",
|
||||||
title: "Success",
|
title: "Success",
|
||||||
message: "Member removed successfully",
|
message: "Member removed successfully",
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
const error = err?.error;
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error",
|
||||||
|
message: error || "Something went wrong",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
mutateInvitations();
|
||||||
|
});
|
||||||
|
}
|
||||||
setSelectedRemoveMember(null);
|
setSelectedRemoveMember(null);
|
||||||
setSelectedInviteRemoveMember(null);
|
setSelectedInviteRemoveMember(null);
|
||||||
}}
|
}}
|
||||||
@ -276,7 +294,7 @@ const MembersSettings: NextPage = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Remove member
|
{user?.id === member.memberId ? "Leave" : "Remove member"}
|
||||||
</CustomMenu.MenuItem>
|
</CustomMenu.MenuItem>
|
||||||
</CustomMenu>
|
</CustomMenu>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user