| @@ -36,7 +36,7 @@ const FinancialSummaryPage: React.FC<Props> = ({ | |||||
| // currYear = 2024 | // currYear = 2024 | ||||
| const startDate = "10-01" | const startDate = "10-01" | ||||
| const endDate = "09-30" | const endDate = "09-30" | ||||
| const lengthOfYear = 5 | |||||
| const lengthOfCombo = 6 | |||||
| const currFinancialYear = useMemo(() => currDate > `${currYear}-${startDate}` ? currYear + 1 : currYear, [currYear]) | const currFinancialYear = useMemo(() => currDate > `${currYear}-${startDate}` ? currYear + 1 : currYear, [currYear]) | ||||
| const [mainData, setMainData] = useState<FinancialByProject[]>(financialSummByProject) | const [mainData, setMainData] = useState<FinancialByProject[]>(financialSummByProject) | ||||
| const [byTeam, setByTeam] = useState<SumOfByTeam[]>(() => sumUpByTeam(mainData)) // do fetch to set | const [byTeam, setByTeam] = useState<SumOfByTeam[]>(() => sumUpByTeam(mainData)) // do fetch to set | ||||
| @@ -80,16 +80,16 @@ const FinancialSummaryPage: React.FC<Props> = ({ | |||||
| const map: DateParams = { | const map: DateParams = { | ||||
| 0: {startDate: "", endDate: ""}, | 0: {startDate: "", endDate: ""}, | ||||
| 1: thisYear, | 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] = { | map[i] = { | ||||
| startDate: `${currFinancialYear-i}-${startDate}`, | startDate: `${currFinancialYear-i}-${startDate}`, | ||||
| endDate: `${currFinancialYear-(i - 1)}-${endDate}` | endDate: `${currFinancialYear-(i - 1)}-${endDate}` | ||||
| } | } | ||||
| } | } | ||||
| return map | return map | ||||
| }, [currDate, currYear, currFinancialYear, startDate, endDate, lengthOfYear]) | |||||
| }, [currDate, currYear, currFinancialYear, startDate, endDate, lengthOfCombo]) | |||||
| // const comboList: string[] = useMemo(() => { | // const comboList: string[] = useMemo(() => { | ||||
| // const list = ["All"] | // const list = ["All"] | ||||
| @@ -108,15 +108,15 @@ const FinancialSummaryPage: React.FC<Props> = ({ | |||||
| const comboList: string[] = useMemo(() => { | const comboList: string[] = useMemo(() => { | ||||
| const list = ["All"]; | 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 yearRange = `${currFinancialYear - i} - ${currFinancialYear - i + 1}`; | ||||
| const label = i === 1 ? `${yearRange} ${t("(current year)")}` : yearRange; | const label = i === 1 ? `${yearRange} ${t("(current year)")}` : yearRange; | ||||
| list.push(label); | list.push(label); | ||||
| } | } | ||||
| const oldestYear = currFinancialYear - (lengthOfYear - 2); | |||||
| const oldestYear = currFinancialYear - (lengthOfCombo - 2); | |||||
| list.push(`< ${oldestYear}`); | list.push(`< ${oldestYear}`); | ||||
| return list; | return list; | ||||
| }, [currFinancialYear, lengthOfYear, t]); | |||||
| }, [currFinancialYear, lengthOfCombo, t]); | |||||
| const fetchFinancialSummaryByProject = useCallback(async (endDate: string, startDate: string) => { | const fetchFinancialSummaryByProject = useCallback(async (endDate: string, startDate: string) => { | ||||
| setIsLoading(true) | setIsLoading(true) | ||||