import { FC, useState } from "react"; import { observer } from "mobx-react"; import useSWR from "swr"; // components import { EstimateLoaderScreen, EstimateEmptyScreen, EstimateDisableSwitch, CreateEstimateModal, UpdateEstimateModal, EstimateList, } from "@/components/estimates"; // hooks import { useProjectEstimates } from "@/hooks/store"; type TEstimateRoot = { workspaceSlug: string; projectId: string; isAdmin: boolean; }; export const EstimateRoot: FC = observer((props) => { const { workspaceSlug, projectId, isAdmin } = props; // hooks const { loader, currentActiveEstimateId, archivedEstimateIds, getProjectEstimates } = useProjectEstimates(); // states const [isEstimateCreateModalOpen, setIsEstimateCreateModalOpen] = useState(false); const [estimateToUpdate, setEstimateToUpdate] = useState(); const { isLoading: isSWRLoading } = useSWR( workspaceSlug && projectId ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` : null, async () => workspaceSlug && projectId && getProjectEstimates(workspaceSlug, projectId) ); return (
{loader === "init-loader" || isSWRLoading ? ( ) : (
{/* header */}
Estimates
{currentActiveEstimateId ? (
{/* estimates activated deactivated section */}

Enable estimates for my project

They help you in communicating complexity and workload of the team.

{/* active estimates section */} setEstimateToUpdate(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.

)}
)} {/* modals for create and update */} { setIsEstimateCreateModalOpen(false); setEstimateToUpdate(undefined); }} /> { setIsEstimateCreateModalOpen(false); setEstimateToUpdate(undefined); }} />
); });