import { FC, useState } from "react"; import { observer } from "mobx-react"; import useSWR from "swr"; // plane imports import { useTranslation } from "@plane/i18n"; // hooks import { useProjectEstimates } from "@/hooks/store/estimates"; import { useProject } from "@/hooks/store/use-project"; // plane web components import { UpdateEstimateModal } from "@/plane-web/components/estimates"; // local imports import { SettingsHeading } from "../settings/heading"; import { CreateEstimateModal } from "./create/modal"; import { DeleteEstimateModal } from "./delete/modal"; import { EstimateEmptyScreen } from "./empty-screen"; import { EstimateDisableSwitch } from "./estimate-disable-switch"; import { EstimateList } from "./estimate-list"; import { EstimateLoaderScreen } from "./loader-screen"; type TEstimateRoot = { workspaceSlug: string; projectId: string; isAdmin: boolean; }; export const EstimateRoot: FC = observer((props) => { const { workspaceSlug, projectId, isAdmin } = props; // hooks const { currentProjectDetails } = useProject(); const { loader, currentActiveEstimateId, archivedEstimateIds, getProjectEstimates } = useProjectEstimates(); // states const [isEstimateCreateModalOpen, setIsEstimateCreateModalOpen] = useState(false); const [estimateToUpdate, setEstimateToUpdate] = useState(); const [estimateToDelete, setEstimateToDelete] = useState(); const { t } = useTranslation(); const { isLoading: isSWRLoading } = useSWR( workspaceSlug && projectId ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` : null, async () => workspaceSlug && projectId && getProjectEstimates(workspaceSlug, projectId) ); return (
{loader === "init-loader" || isSWRLoading ? ( ) : (
{/* header */} {/* current active estimate section */} {currentActiveEstimateId ? (
{/* estimates activated deactivated section */}

{t("project_settings.estimates.title")}

{t("project_settings.estimates.enable_description")}

{/* active estimates section */} setEstimateToUpdate(estimateId)} onDeleteClick={(estimateId: string) => setEstimateToDelete(estimateId)} />
) : ( setIsEstimateCreateModalOpen(true)} /> )} {/* archived estimates section */} {archivedEstimateIds && archivedEstimateIds.length > 0 && (

Archived estimates

Estimates have gone through a change, these are the estimates you had in your older versions which were not in use. Read more about them  here.

)}
)} {/* CRUD modals */} setIsEstimateCreateModalOpen(false)} /> setEstimateToUpdate(undefined)} /> setEstimateToDelete(undefined)} />
); });