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 { user } = useUserAuth("onboarding");
|
||||
const { user, mutateUser } = useUserAuth("onboarding");
|
||||
|
||||
return (
|
||||
<UserAuthorizationLayout>
|
||||
@ -99,16 +99,24 @@ const Onboarding: NextPage = () => {
|
||||
);
|
||||
const userWorkspaces = await workspaceService.userWorkspaces();
|
||||
|
||||
const lastActiveWorkspace = userWorkspaces.find(
|
||||
(workspace) => workspace.id === user?.last_workspace_id
|
||||
);
|
||||
const lastActiveWorkspace =
|
||||
userWorkspaces.find(
|
||||
(workspace) => workspace.id === user?.last_workspace_id
|
||||
) ?? userWorkspaces[0];
|
||||
|
||||
if (lastActiveWorkspace) {
|
||||
userService
|
||||
.updateUser({
|
||||
last_workspace_id: lastActiveWorkspace.id,
|
||||
})
|
||||
.then((res) => {
|
||||
mutateUser();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
Router.push(`/${lastActiveWorkspace.slug}`);
|
||||
return;
|
||||
} else if (userWorkspaces.length > 0) {
|
||||
Router.push(`/${userWorkspaces[0].slug}`);
|
||||
return;
|
||||
} else {
|
||||
const invitations = await workspaceService.userWorkspaceInvitations();
|
||||
if (invitations.length > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user