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 useUser from "hooks/use-user"; // layouts import DefaultLayout from "layouts/default-layout"; import { UserAuthorizationLayout } from "layouts/auth-layout-legacy/user-authorization-wrapper"; // 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 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({ name: "", slug: "", organization_size: "", }); const router = useRouter(); 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}`)); }; return (
{theme === "light" ? ( Plane black logo ) : ( Plane white logo )}
{user?.email}

Create your workspace

); }; export default CreateWorkspace;