diff --git a/src/components/ProjectFinancialSummaryV2/FinancialSummary.tsx b/src/components/ProjectFinancialSummaryV2/FinancialSummary.tsx index 5462ad7..08dc47b 100644 --- a/src/components/ProjectFinancialSummaryV2/FinancialSummary.tsx +++ b/src/components/ProjectFinancialSummaryV2/FinancialSummary.tsx @@ -36,7 +36,7 @@ const FinancialSummaryPage: React.FC = ({ // currYear = 2024 const startDate = "10-01" const endDate = "09-30" - const lengthOfYear = 5 + const lengthOfCombo = 6 const currFinancialYear = useMemo(() => currDate > `${currYear}-${startDate}` ? currYear + 1 : currYear, [currYear]) const [mainData, setMainData] = useState(financialSummByProject) const [byTeam, setByTeam] = useState(() => sumUpByTeam(mainData)) // do fetch to set @@ -80,16 +80,16 @@ const FinancialSummaryPage: React.FC = ({ const map: DateParams = { 0: {startDate: "", endDate: ""}, 1: thisYear, - [lengthOfYear - 1]: {startDate: "", endDate: `${currFinancialYear-(lengthOfYear - 2)}-${endDate}`} + [lengthOfCombo - 1]: {startDate: "", endDate: `${currFinancialYear-(lengthOfCombo - 2)}-${endDate}`} } - for (let i = 2; i < lengthOfYear - 1; i++) { + for (let i = 2; i < lengthOfCombo - 1; i++) { map[i] = { startDate: `${currFinancialYear-i}-${startDate}`, endDate: `${currFinancialYear-(i - 1)}-${endDate}` } } return map - }, [currDate, currYear, currFinancialYear, startDate, endDate, lengthOfYear]) + }, [currDate, currYear, currFinancialYear, startDate, endDate, lengthOfCombo]) // const comboList: string[] = useMemo(() => { // const list = ["All"] @@ -108,15 +108,15 @@ const FinancialSummaryPage: React.FC = ({ const comboList: string[] = useMemo(() => { const list = ["All"]; - for (let i = 1; i < lengthOfYear - 1; i++) { + for (let i = 1; i < lengthOfCombo - 1; i++) { const yearRange = `${currFinancialYear - i} - ${currFinancialYear - i + 1}`; const label = i === 1 ? `${yearRange} ${t("(current year)")}` : yearRange; list.push(label); } - const oldestYear = currFinancialYear - (lengthOfYear - 2); + const oldestYear = currFinancialYear - (lengthOfCombo - 2); list.push(`< ${oldestYear}`); return list; - }, [currFinancialYear, lengthOfYear, t]); + }, [currFinancialYear, lengthOfCombo, t]); const fetchFinancialSummaryByProject = useCallback(async (endDate: string, startDate: string) => { setIsLoading(true)