mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: workspace accepted invitation redirects to the workspace (#1971)
* fix: workspace accepted invitation redirects to the workspace * chore: removing logs * fix: updating user last workspace id with newly joined one * adding error toast
This commit is contained in:
parent
9f420a00d7
commit
a61e8370b5
@ -33,6 +33,7 @@ import type { IWorkspaceMemberInvitation } from "types";
|
|||||||
import { USER_WORKSPACE_INVITATIONS } from "constants/fetch-keys";
|
import { USER_WORKSPACE_INVITATIONS } from "constants/fetch-keys";
|
||||||
// constants
|
// constants
|
||||||
import { ROLE } from "constants/workspace";
|
import { ROLE } from "constants/workspace";
|
||||||
|
import userService from "services/user.service";
|
||||||
|
|
||||||
const OnBoard: NextPage = () => {
|
const OnBoard: NextPage = () => {
|
||||||
const [invitationsRespond, setInvitationsRespond] = useState<string[]>([]);
|
const [invitationsRespond, setInvitationsRespond] = useState<string[]>([]);
|
||||||
@ -78,12 +79,32 @@ const OnBoard: NextPage = () => {
|
|||||||
workspaceService
|
workspaceService
|
||||||
.joinWorkspaces({ invitations: invitationsRespond })
|
.joinWorkspaces({ invitations: invitationsRespond })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
mutateInvitations();
|
|
||||||
mutate("USER_WORKSPACES");
|
mutate("USER_WORKSPACES");
|
||||||
|
const firstInviteId = invitationsRespond[0];
|
||||||
setIsJoiningWorkspaces(false);
|
const redirectWorkspace = invitations?.find((i) => i.id === firstInviteId)?.workspace;
|
||||||
|
userService
|
||||||
|
.updateUser({ last_workspace_id: redirectWorkspace?.id })
|
||||||
|
.then(() => {
|
||||||
|
setIsJoiningWorkspaces(false);
|
||||||
|
router.push(`/${redirectWorkspace?.slug}`);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error!",
|
||||||
|
message: "Something went wrong, Please try again.",
|
||||||
|
});
|
||||||
|
setIsJoiningWorkspaces(false);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(() => setIsJoiningWorkspaces(false));
|
.catch(() => {
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error!",
|
||||||
|
message: "Something went wrong, Please try again.",
|
||||||
|
});
|
||||||
|
setIsJoiningWorkspaces(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -167,6 +188,7 @@ const OnBoard: NextPage = () => {
|
|||||||
size="md"
|
size="md"
|
||||||
onClick={submitInvitations}
|
onClick={submitInvitations}
|
||||||
disabled={isJoiningWorkspaces || invitationsRespond.length === 0}
|
disabled={isJoiningWorkspaces || invitationsRespond.length === 0}
|
||||||
|
loading={isJoiningWorkspaces}
|
||||||
>
|
>
|
||||||
Accept & Join
|
Accept & Join
|
||||||
</PrimaryButton>
|
</PrimaryButton>
|
||||||
|
Loading…
Reference in New Issue
Block a user