import React, { useEffect, useState } from "react"; import { observer } from "mobx-react"; import Image from "next/image"; // icons import { Sparkles } from "lucide-react"; // types import { IWorkspaceMemberInvitation, TOnboardingSteps } from "@plane/types"; // ui import { Spinner } from "@plane/ui"; // components import { Invitations, OnboardingHeader, SwitchOrDeleteAccountDropdown, CreateWorkspace } from "@/components/onboarding"; // hooks import { useUser } from "@/hooks/store"; // assets import createJoinWorkspace from "public/onboarding/create-join-workspace.png"; export enum ECreateOrJoinWorkspaceViews { WORKSPACE_CREATE = "WORKSPACE_CREATE", WORKSPACE_JOIN = "WORKSPACE_JOIN", } type Props = { invitations: IWorkspaceMemberInvitation[]; totalSteps: number; stepChange: (steps: Partial) => Promise; }; export const CreateOrJoinWorkspaces: React.FC = observer((props) => { const { invitations, totalSteps, stepChange } = props; // states const [currentView, setCurrentView] = useState(null); // store hooks const { data: user } = useUser(); useEffect(() => { if (invitations.length > 0) { setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN); } else { setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE); } }, [invitations]); const handleNextStep = async () => { if (!user) return; await stepChange({ workspace_join: true, workspace_create: true }); }; return (
{currentView === ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN ? ( setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE)} /> ) : currentView === ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE ? ( setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN)} /> ) : (
)}
Workspace is the hub for all work happening in your company.
create-join-workspace
); });