mirror of
https://github.com/makeplane/plane.git
synced 2025-12-23 15:19:37 +01:00
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { useEffect, FC, useState } from "react";
|
|
// ui
|
|
import { EModalPosition, EModalWidth, ModalCore } from "@plane/ui";
|
|
// components
|
|
import { CreateProjectForm } from "@/plane-web/components/projects/create/root";
|
|
import { TProject } from "@/plane-web/types/projects";
|
|
import { ProjectFeatureUpdate } from "./project-feature-update";
|
|
|
|
type Props = {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
setToFavorite?: boolean;
|
|
workspaceSlug: string;
|
|
data?: Partial<TProject>;
|
|
};
|
|
|
|
enum EProjectCreationSteps {
|
|
CREATE_PROJECT = "CREATE_PROJECT",
|
|
FEATURE_SELECTION = "FEATURE_SELECTION",
|
|
}
|
|
|
|
export const CreateProjectModal: FC<Props> = (props) => {
|
|
const { isOpen, onClose, setToFavorite = false, workspaceSlug, data } = props;
|
|
// states
|
|
const [currentStep, setCurrentStep] = useState<EProjectCreationSteps>(EProjectCreationSteps.CREATE_PROJECT);
|
|
const [createdProjectId, setCreatedProjectId] = useState<string | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (isOpen) {
|
|
setCurrentStep(EProjectCreationSteps.CREATE_PROJECT);
|
|
setCreatedProjectId(null);
|
|
}
|
|
}, [isOpen]);
|
|
|
|
const handleNextStep = (projectId: string) => {
|
|
if (!projectId) return;
|
|
setCreatedProjectId(projectId);
|
|
setCurrentStep(EProjectCreationSteps.FEATURE_SELECTION);
|
|
};
|
|
|
|
return (
|
|
<ModalCore isOpen={isOpen} handleClose={onClose} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
|
{currentStep === EProjectCreationSteps.CREATE_PROJECT && (
|
|
<CreateProjectForm
|
|
setToFavorite={setToFavorite}
|
|
workspaceSlug={workspaceSlug}
|
|
onClose={onClose}
|
|
handleNextStep={handleNextStep}
|
|
data={data}
|
|
/>
|
|
)}
|
|
{currentStep === EProjectCreationSteps.FEATURE_SELECTION && (
|
|
<ProjectFeatureUpdate projectId={createdProjectId} workspaceSlug={workspaceSlug} onClose={onClose} />
|
|
)}
|
|
</ModalCore>
|
|
);
|
|
};
|