mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
13b2a6fd53
* fix: persist data on tab switch in workspace * fix: build fail
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
import Image from "next/image";
|
|
|
|
// constants
|
|
import { requiredAuth } from "lib/auth";
|
|
// layouts
|
|
import DefaultLayout from "layouts/default-layout";
|
|
// images
|
|
import Logo from "public/onboarding/logo.svg";
|
|
// types
|
|
import type { NextPage, NextPageContext } from "next";
|
|
// constants
|
|
import { CreateWorkspaceForm } from "components/workspace";
|
|
|
|
const CreateWorkspace: NextPage = () => {
|
|
const router = useRouter();
|
|
const defaultValues = {
|
|
name: "",
|
|
slug: "",
|
|
company_size: null,
|
|
};
|
|
|
|
return (
|
|
<DefaultLayout>
|
|
<div className="grid h-full place-items-center p-5">
|
|
<div className="w-full space-y-4">
|
|
<div className="mb-8 text-center">
|
|
<Image src={Logo} height="50" alt="Plane Logo" />
|
|
</div>
|
|
<CreateWorkspaceForm
|
|
defaultValues={defaultValues}
|
|
setDefaultValues={() => {}}
|
|
onSubmit={(res) => router.push(`/${res.slug}`)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</DefaultLayout>
|
|
);
|
|
};
|
|
|
|
export const getServerSideProps = async (ctx: NextPageContext) => {
|
|
const user = await requiredAuth(ctx.req?.headers.cookie);
|
|
|
|
const redirectAfterSignIn = ctx.req?.url;
|
|
|
|
if (!user) {
|
|
return {
|
|
redirect: {
|
|
destination: `/signin?next=${redirectAfterSignIn}`,
|
|
permanent: false,
|
|
},
|
|
};
|
|
}
|
|
|
|
return {
|
|
props: {
|
|
user,
|
|
},
|
|
};
|
|
};
|
|
|
|
export default CreateWorkspace;
|