forked from github/plane
fix: last workspace id (#1237)
This commit is contained in:
parent
18f66805cb
commit
f9cd1b1352
@ -39,7 +39,7 @@ const Onboarding: NextPage = () => {
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { user } = useUserAuth("onboarding");
|
const { user, mutateUser } = useUserAuth("onboarding");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UserAuthorizationLayout>
|
<UserAuthorizationLayout>
|
||||||
@ -99,16 +99,24 @@ const Onboarding: NextPage = () => {
|
|||||||
);
|
);
|
||||||
const userWorkspaces = await workspaceService.userWorkspaces();
|
const userWorkspaces = await workspaceService.userWorkspaces();
|
||||||
|
|
||||||
const lastActiveWorkspace = userWorkspaces.find(
|
const lastActiveWorkspace =
|
||||||
(workspace) => workspace.id === user?.last_workspace_id
|
userWorkspaces.find(
|
||||||
);
|
(workspace) => workspace.id === user?.last_workspace_id
|
||||||
|
) ?? userWorkspaces[0];
|
||||||
|
|
||||||
if (lastActiveWorkspace) {
|
if (lastActiveWorkspace) {
|
||||||
|
userService
|
||||||
|
.updateUser({
|
||||||
|
last_workspace_id: lastActiveWorkspace.id,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
mutateUser();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
Router.push(`/${lastActiveWorkspace.slug}`);
|
Router.push(`/${lastActiveWorkspace.slug}`);
|
||||||
return;
|
return;
|
||||||
} else if (userWorkspaces.length > 0) {
|
|
||||||
Router.push(`/${userWorkspaces[0].slug}`);
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
const invitations = await workspaceService.userWorkspaceInvitations();
|
const invitations = await workspaceService.userWorkspaceInvitations();
|
||||||
if (invitations.length > 0) {
|
if (invitations.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user