import { useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; import { mutate } from "swr"; // 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/user-authorization-wrapper"; // components import { InviteMembers, OnboardingCard, UserDetails, Workspace } from "components/onboarding"; // ui import { PrimaryButton } from "components/ui"; // constant import { ONBOARDING_CARDS } from "constants/workspace"; // images import Logo from "public/onboarding/logo.svg"; // types import type { NextPage } from "next"; import { ICurrentUserResponse } from "types"; // fetch-keys import { CURRENT_USER } from "constants/fetch-keys"; const Onboarding: NextPage = () => { const [step, setStep] = useState(1); const [userRole, setUserRole] = useState(null); const [workspace, setWorkspace] = useState(); const router = useRouter(); const { user } = useUser(); return (
{step <= 3 ? (
Plane Logo
{step === 1 ? ( ) : step === 2 ? ( ) : ( )}
) : (
{step === 4 ? ( ) : step === 5 ? ( ) : step === 6 ? ( ) : step === 7 ? ( ) : ( )}
{ if (step === 8) { userService .updateUserOnBoard({ userRole }) .then(() => { mutate( CURRENT_USER, (prevData) => { if (!prevData) return prevData; return { ...prevData, user: { ...prevData.user, is_onboarded: true, }, }; }, false ); router.push("/"); }) .catch((err) => { console.log(err); }); } else setStep((prevData) => prevData + 1); }} > {step === 4 || step === 8 ? "Get Started" : "Next"}
)}
); }; export default Onboarding;