2024-04-29 06:42:33 +00:00
|
|
|
|
import React from "react";
|
2023-09-01 11:12:30 +00:00
|
|
|
|
import { observer } from "mobx-react-lite";
|
2024-04-29 06:42:33 +00:00
|
|
|
|
import Image from "next/image";
|
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
import { useTheme } from "next-themes";
|
|
|
|
|
// ui
|
|
|
|
|
import { Avatar } from "@plane/ui";
|
|
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
|
import { OnBoardingForm } from "@/components/accounts/onboarding-form";
|
2024-04-29 06:42:33 +00:00
|
|
|
|
// mobx
|
2024-03-19 14:38:35 +00:00
|
|
|
|
import { useMobxStore } from "@/lib/mobx/store-provider";
|
2024-04-29 06:42:33 +00:00
|
|
|
|
// assets
|
|
|
|
|
import ProfileSetupDark from "public/onboarding/profile-setup-dark.svg";
|
|
|
|
|
import ProfileSetup from "public/onboarding/profile-setup.svg";
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
2023-09-14 06:56:07 +00:00
|
|
|
|
const imagePrefix = Boolean(parseInt(process.env.NEXT_PUBLIC_DEPLOY_WITH_NGINX || "0")) ? "/spaces" : "";
|
2023-09-12 15:02:26 +00:00
|
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
|
const OnBoardingPage = () => {
|
2024-04-29 06:42:33 +00:00
|
|
|
|
// router
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const { next_path } = router.query;
|
|
|
|
|
|
|
|
|
|
// hooks
|
|
|
|
|
const { resolvedTheme } = useTheme();
|
|
|
|
|
const {
|
|
|
|
|
user: userStore,
|
|
|
|
|
profile: { currentUserProfile, updateUserProfile },
|
|
|
|
|
} = useMobxStore();
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
|
|
const user = userStore?.currentUser;
|
2024-04-29 06:42:33 +00:00
|
|
|
|
if (!user) {
|
|
|
|
|
router.push("/");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// complete onboarding
|
|
|
|
|
const finishOnboarding = async () => {
|
|
|
|
|
if (!user) return;
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
2024-04-29 06:42:33 +00:00
|
|
|
|
await updateUserProfile({
|
|
|
|
|
onboarding_step: {
|
|
|
|
|
...currentUserProfile?.onboarding_step,
|
|
|
|
|
profile_complete: true,
|
|
|
|
|
},
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
console.log("Failed to update onboarding status");
|
|
|
|
|
});
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
2024-04-29 06:42:33 +00:00
|
|
|
|
if (next_path) router.replace(next_path.toString());
|
|
|
|
|
router.replace("/");
|
|
|
|
|
};
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
|
|
return (
|
2024-04-29 06:42:33 +00:00
|
|
|
|
<div className="flex h-full w-full">
|
|
|
|
|
<div className="w-full h-full overflow-auto px-6 py-10 sm:px-7 sm:py-14 md:px-14 lg:px-28">
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex w-full items-center justify-between font-semibold ">
|
|
|
|
|
<div className="flex items-center gap-x-2">
|
|
|
|
|
<Image src={`${imagePrefix}/plane-logos/blue-without-text.png`} height={30} width={30} alt="Plane Logo" />
|
2023-09-01 11:12:30 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-29 06:42:33 +00:00
|
|
|
|
<div className="shrink-0 lg:hidden">
|
|
|
|
|
<div className="flex w-full shrink-0 justify-end">
|
|
|
|
|
<div className="flex items-center gap-x-2 pr-4">
|
|
|
|
|
{user?.avatar && (
|
|
|
|
|
<Avatar
|
|
|
|
|
name={user?.first_name ? `${user?.first_name} ${user?.last_name ?? ""}` : user?.email}
|
|
|
|
|
src={user?.avatar}
|
|
|
|
|
size={24}
|
|
|
|
|
shape="square"
|
|
|
|
|
fallbackBackgroundColor="#FCBE1D"
|
|
|
|
|
className="!text-base capitalize"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<span className="text-sm font-medium text-custom-text-200">
|
|
|
|
|
{user?.first_name ? `${user?.first_name} ${user?.last_name ?? ""}` : user?.email}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-col w-full items-center justify-center p-8 mt-14">
|
|
|
|
|
<div className="text-center space-y-1 py-4 mx-auto">
|
|
|
|
|
<h3 className="text-3xl font-bold text-onboarding-text-100">Welcome to Plane!</h3>
|
|
|
|
|
<p className="font-medium text-onboarding-text-400">
|
|
|
|
|
Let’s setup your profile, tell us a bit about yourself.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<OnBoardingForm user={user} finishOnboarding={finishOnboarding} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="hidden lg:block relative w-2/5 h-screen overflow-hidden px-6 py-10 sm:px-7 sm:py-14 md:px-14 lg:px-28">
|
|
|
|
|
<div className="flex w-full shrink-0 justify-end">
|
|
|
|
|
<div className="flex items-center gap-x-2 pr-4 z-10">
|
|
|
|
|
{user?.avatar && (
|
|
|
|
|
<Avatar
|
|
|
|
|
name={user?.first_name ? `${user?.first_name} ${user?.last_name ?? ""}` : user?.email}
|
|
|
|
|
src={user?.avatar}
|
|
|
|
|
size={24}
|
|
|
|
|
shape="square"
|
|
|
|
|
fallbackBackgroundColor="#FCBE1D"
|
|
|
|
|
className="!text-base capitalize"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<span className="text-sm font-medium text-custom-text-200">
|
|
|
|
|
{user?.first_name ? `${user?.first_name} ${user?.last_name ?? ""}` : user?.email}
|
|
|
|
|
</span>
|
2023-09-01 11:12:30 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-29 06:42:33 +00:00
|
|
|
|
<div className="absolute inset-0 z-0">
|
|
|
|
|
<Image
|
|
|
|
|
src={resolvedTheme === "dark" ? ProfileSetupDark : ProfileSetup}
|
|
|
|
|
className="h-screen w-auto float-end object-cover"
|
|
|
|
|
alt="Profile setup"
|
|
|
|
|
/>
|
2023-09-01 11:12:30 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default observer(OnBoardingPage);
|