diff --git a/web/components/workspace/create-workspace-form.tsx b/web/components/workspace/create-workspace-form.tsx index 051802638..7ff520bef 100644 --- a/web/components/workspace/create-workspace-form.tsx +++ b/web/components/workspace/create-workspace-form.tsx @@ -1,5 +1,6 @@ import { Dispatch, SetStateAction, useEffect, useState, FC } from "react"; import { mutate } from "swr"; +import { useRouter } from "next/router"; import { Controller, useForm } from "react-hook-form"; // services import { WorkspaceService } from "services/workspace.service"; @@ -63,6 +64,7 @@ export const CreateWorkspaceForm: FC = ({ const [invalidSlug, setInvalidSlug] = useState(false); const { setToastAlert } = useToast(); + const router = useRouter(); const { handleSubmit, @@ -171,7 +173,7 @@ export const CreateWorkspaceForm: FC = ({ ref={ref} hasError={Boolean(errors.slug)} placeholder="Enter workspace name..." - className="block rounded-md bg-transparent py-2 !px-0 text-sm w-full" + className="block rounded-md bg-transparent py-2 !px-0 text-sm w-full border-none" /> )} /> @@ -220,6 +222,9 @@ export const CreateWorkspaceForm: FC = ({ + ); diff --git a/web/pages/create-workspace/index.tsx b/web/pages/create-workspace/index.tsx index c6db0bd76..81048940b 100644 --- a/web/pages/create-workspace/index.tsx +++ b/web/pages/create-workspace/index.tsx @@ -1,28 +1,21 @@ import React, { useState } from "react"; import { useRouter } from "next/router"; import Image from "next/image"; -import { mutate } from "swr"; import { useTheme } from "next-themes"; -// services -import { UserService } from "services/user.service"; // hooks +import { useMobxStore } from "lib/mobx/store-provider"; import useUser from "hooks/use-user"; // layouts import DefaultLayout from "layouts/default-layout"; -import { UserAuthorizationLayout } from "layouts/auth-layout-legacy/user-authorization-wrapper"; +import { UserAuthWrapper } from "layouts/auth-layout"; // components import { CreateWorkspaceForm } from "components/workspace"; // images import BlackHorizontalLogo from "public/plane-logos/black-horizontal-with-blue-logo.svg"; import WhiteHorizontalLogo from "public/plane-logos/white-horizontal-with-blue-logo.svg"; // types -import { IUser, IWorkspace } from "types"; +import { IWorkspace } from "types"; import type { NextPage } from "next"; -// fetch-keys -import { CURRENT_USER } from "constants/fetch-keys"; - -// services -const userService = new UserService(); const CreateWorkspace: NextPage = () => { const [defaultValues, setDefaultValues] = useState({ @@ -33,41 +26,28 @@ const CreateWorkspace: NextPage = () => { const router = useRouter(); + const { user: userStore } = useMobxStore(); + const { theme } = useTheme(); const { user } = useUser(); const onSubmit = async (workspace: IWorkspace) => { - mutate( - CURRENT_USER, - (prevData) => { - if (!prevData) return prevData; - - return { - ...prevData, - last_workspace_id: workspace.id, - // workspace: { - // ...prevData.workspace, - // fallback_workspace_id: workspace.id, - // fallback_workspace_slug: workspace.slug, - // last_workspace_id: workspace.id, - // last_workspace_slug: workspace.slug, - // }, - }; - }, - false - ); - - await userService.updateUser({ last_workspace_id: workspace.id }).then(() => router.push(`/${workspace.slug}`)); + await userStore + .updateCurrentUser({ last_workspace_id: workspace.id }) + .then(() => router.push(`/${workspace.slug}`)); }; return ( - +
-
+
+
{user?.email}
@@ -95,7 +75,7 @@ const CreateWorkspace: NextPage = () => {
- + ); };