import { useEffect, Fragment, FC, useState } from "react"; import { observer } from "mobx-react-lite"; import { Dialog, Transition } from "@headlessui/react"; // ui import { setToast, TOAST_TYPE } from "@plane/ui"; // components import { CreateProjectForm } from "./create-project-form"; import { ProjectFeatureUpdate } from "./project-feature-update"; // constants import { EUserWorkspaceRoles } from "constants/workspace"; // hooks import { useUser } from "hooks/store"; type Props = { isOpen: boolean; onClose: () => void; setToFavorite?: boolean; workspaceSlug: string; }; enum EProjectCreationSteps { CREATE_PROJECT = "CREATE_PROJECT", FEATURE_SELECTION = "FEATURE_SELECTION", } interface IIsGuestCondition { onClose: () => void; } const IsGuestCondition: FC = ({ onClose }) => { useEffect(() => { onClose(); setToast({ title: "Error", type: TOAST_TYPE.ERROR, message: "You don't have permission to create project.", }); }, [onClose]); return null; }; export const CreateProjectModal: FC = observer((props) => { const { isOpen, onClose, setToFavorite = false, workspaceSlug } = props; // states const [currentStep, setCurrentStep] = useState(EProjectCreationSteps.CREATE_PROJECT); const [createdProjectId, setCreatedProjectId] = useState(null); // hooks const { membership: { currentWorkspaceRole }, } = useUser(); useEffect(() => { if (isOpen) { setCurrentStep(EProjectCreationSteps.CREATE_PROJECT); setCreatedProjectId(null); } }, [isOpen]); if (currentWorkspaceRole && isOpen) if (currentWorkspaceRole < EUserWorkspaceRoles.MEMBER) return ; const handleNextStep = (projectId: string) => { if (!projectId) return; setCreatedProjectId(projectId); setCurrentStep(EProjectCreationSteps.FEATURE_SELECTION); }; return (
{currentStep === EProjectCreationSteps.CREATE_PROJECT && ( )} {currentStep === EProjectCreationSteps.FEATURE_SELECTION && ( )}
); });