mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: updating last_workspace_id under user (#1289)
* chore: onboarding steps workflow verification * chore: onboarding onboarding variable update * chore: role check in onboarding * chore: updated last_workspace_id under user
This commit is contained in:
parent
4083f623a0
commit
be7706e62e
@ -6,6 +6,7 @@ import { mutate } from "swr";
|
|||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
// services
|
// services
|
||||||
import workspaceService from "services/workspace.service";
|
import workspaceService from "services/workspace.service";
|
||||||
|
import userService from "services/user.service";
|
||||||
// hooks
|
// hooks
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// ui
|
// ui
|
||||||
@ -77,7 +78,7 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
|
|||||||
message: "Workspace created successfully.",
|
message: "Workspace created successfully.",
|
||||||
});
|
});
|
||||||
mutate<IWorkspace[]>(USER_WORKSPACES, (prevData) => [res, ...(prevData ?? [])]);
|
mutate<IWorkspace[]>(USER_WORKSPACES, (prevData) => [res, ...(prevData ?? [])]);
|
||||||
onSubmit(res);
|
updateLastWorkspaceIdUnderUSer(res);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@ -93,6 +94,18 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// update last_workspace_id
|
||||||
|
const updateLastWorkspaceIdUnderUSer = (workspace: any) => {
|
||||||
|
userService
|
||||||
|
.updateUser({ last_workspace_id: workspace.id })
|
||||||
|
.then((res) => {
|
||||||
|
onSubmit(workspace);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
// when the component unmounts set the default values to whatever user typed in
|
// when the component unmounts set the default values to whatever user typed in
|
||||||
|
@ -96,16 +96,7 @@ const Onboarding: NextPage = () => {
|
|||||||
) ?? userWorkspaces[0];
|
) ?? userWorkspaces[0];
|
||||||
|
|
||||||
if (lastActiveWorkspace) {
|
if (lastActiveWorkspace) {
|
||||||
userService
|
|
||||||
.updateUser({
|
|
||||||
last_workspace_id: lastActiveWorkspace.id,
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
mutateUser();
|
mutateUser();
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
Router.push(`/${lastActiveWorkspace.slug}`);
|
Router.push(`/${lastActiveWorkspace.slug}`);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user