import { FC, useState } from "react"; import { CustomSelect } from "@plane/ui"; // components import ProgressChart from "@/components/core/sidebar/progress-chart"; // constants import { EEstimateSystem } from "@/constants/estimates"; // hooks import { useAppRouter, useModule, useProjectEstimates } from "@/hooks/store"; type TModuleIssuesBurnDownChart = { moduleId: string; }; const moduleBurnDownChartOptions = [ { value: "issue_count", label: "Issues" }, { value: "estimate", label: "Points" }, ]; export const ModuleIssuesBurnDownChart: FC = (props) => { const { moduleId } = props; // hooks const { getModuleById } = useModule(); // state const [value, setValue] = useState("issue_count"); // handlers const onChange = (value: string) => { setValue(value); // refetch the module details }; // derived values const moduleDetails = getModuleById(moduleId); const { projectId } = useAppRouter(); const { currentActiveEstimateId, areEstimateEnabledByProjectId, estimateById } = useProjectEstimates(); const isEstimateEnabled = (analyticsOption: string) => { if (analyticsOption === "estimate") { if ( projectId && currentActiveEstimateId && areEstimateEnabledByProjectId(projectId) && estimateById(currentActiveEstimateId)?.type === EEstimateSystem.POINTS ) { return true; } else { return false; } } return true; }; if (!moduleDetails || !moduleDetails.start_date || !moduleDetails.target_date) return <>; return (
Ideal
Current
{moduleBurnDownChartOptions.find((v) => v.value === value)?.label ?? "None"}} onChange={onChange} maxHeight="lg" > {moduleBurnDownChartOptions.map( (item) => isEstimateEnabled(item.value) && ( {item.label} ) )}
); };