/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useState } from "react"; import { observer } from "mobx-react"; import useSWR from "swr"; // plane imports import { useTranslation } from "@plane/i18n"; // components import { SettingsBoxedControlItem } from "@/components/settings/boxed-control-item"; import { SettingsHeading } from "@/components/settings/heading"; // hooks import { EmptyStateCompact } from "@plane/propel/empty-state"; import { useProjectEstimates } from "@/hooks/store/estimates"; import { useProject } from "@/hooks/store/use-project"; // local imports import { CreateEstimateModal } from "./create/modal"; import { DeleteEstimateModal } from "./delete/modal"; 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 = observer(function EstimateRoot(props: TEstimateRoot) { const { workspaceSlug, projectId, isAdmin } = props; // hooks const { currentProjectDetails } = useProject(); const { loader, currentActiveEstimateId, archivedEstimateIds, getProjectEstimates } = useProjectEstimates(); // states const [isEstimateCreateModalOpen, setIsEstimateCreateModalOpen] = useState(false); // oxlint-disable-next-line no-unused-vars 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) ); if (loader === "init-loader" || isSWRLoading) { return ; } return ( <>
{/* header */}
{/* current active estimate section */} {currentActiveEstimateId ? ( <> {/* estimates activated deactivated section */} } /> {/* active estimates section */}
setEstimateToUpdate(estimateId)} onDeleteClick={(estimateId: string) => setEstimateToDelete(estimateId)} />
) : ( setIsEstimateCreateModalOpen(true), }, ]} align="start" rootClassName="py-20" /> )} {/* archived estimates section */} {archivedEstimateIds && archivedEstimateIds.length > 0 && (
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. } variant="h6" />
)}
{/* CRUD modals */} setIsEstimateCreateModalOpen(false)} /> setEstimateToDelete(undefined)} /> ); });