import React, { useEffect, useState } from "react"; import { observer } from "mobx-react"; import Image from "next/image"; // icons import { useTheme } from "next-themes"; // types import { IWorkspaceMemberInvitation, TOnboardingSteps } from "@plane/types"; // components import { Invitations, OnboardingHeader, SwitchOrDeleteAccountDropdown, CreateWorkspace } from "@/components/onboarding"; // hooks import { useUser } from "@/hooks/store"; // assets import CreateJoinWorkspaceDark from "public/onboarding/create-join-workspace-dark.svg"; import CreateJoinWorkspace from "public/onboarding/create-join-workspace.svg"; import { LogoSpinner } from "../common"; export enum ECreateOrJoinWorkspaceViews { WORKSPACE_CREATE = "WORKSPACE_CREATE", WORKSPACE_JOIN = "WORKSPACE_JOIN", } type Props = { invitations: IWorkspaceMemberInvitation[]; totalSteps: number; stepChange: (steps: Partial) => Promise; finishOnboarding: () => Promise; }; export const CreateOrJoinWorkspaces: React.FC = observer((props) => { const { invitations, totalSteps, stepChange, finishOnboarding } = props; // states const [currentView, setCurrentView] = useState(null); // store hooks const { data: user } = useUser(); // hooks const { resolvedTheme } = useTheme(); useEffect(() => { if (invitations.length > 0) { setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN); } else { setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE); } }, [invitations]); const handleNextStep = async () => { if (!user) return; await finishOnboarding(); }; return (
{currentView === ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN ? ( setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE)} /> ) : currentView === ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE ? ( setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN)} /> ) : (
)}
Profile setup
); });