| @@ -33,29 +33,19 @@ const ResourceOverconsumptionReport: React.FC<Props> = ({ team, customer, subsid | |||||
| const { t } = useTranslation("report"); | const { t } = useTranslation("report"); | ||||
| const statusCombo = ["Potential Overconsumption"] | const statusCombo = ["Potential Overconsumption"] | ||||
| const sortedTeam = team.sort((a, b) => a.code.localeCompare(b.code)); | const sortedTeam = team.sort((a, b) => a.code.localeCompare(b.code)); | ||||
| const sortedCust = customer.sort((a, b) => a.code.localeCompare(b.code)); | |||||
| const sortedSubs = subsidiaries.sort((a, b) => a.code.localeCompare(b.code)); | |||||
| const teamCombo = sortedTeam.map(t => `${t.code} - ${t.name}`) | const teamCombo = sortedTeam.map(t => `${t.code} - ${t.name}`) | ||||
| const custCombo: combo[] = customer.map(c => ({ | |||||
| const custCombo: combo[] = sortedCust.map(c => ({ | |||||
| value: `custId-${c.id}`, | value: `custId-${c.id}`, | ||||
| label: `${c.code} - ${c.name}`, | label: `${c.code} - ${c.name}`, | ||||
| group: t("Client") | group: t("Client") | ||||
| })) | })) | ||||
| .sort((a: combo, b: combo) => { | |||||
| const [_custType_A, id_A] = readIntFromString(a.value) as [string, number] | |||||
| const [_custType_B, id_B] = readIntFromString(b.value) as [string, number] | |||||
| return (id_A - id_B) | |||||
| }); | |||||
| console.log(custCombo) | |||||
| const subsidiariesCombo: combo[] = subsidiaries.map(sub => ({ | |||||
| const subsidiariesCombo: combo[] = sortedSubs.map(sub => ({ | |||||
| value: `subsidiaryId-${sub.id}`, | value: `subsidiaryId-${sub.id}`, | ||||
| label: `${sub.code} - ${sub.name}`, | label: `${sub.code} - ${sub.name}`, | ||||
| group: t("Subsidiary") | group: t("Subsidiary") | ||||
| })) | })) | ||||
| .sort((a: combo, b: combo) => { | |||||
| const [_custType_A, id_A] = readIntFromString(a.value) as [string, number] | |||||
| const [_custType_B, id_B] = readIntFromString(b.value) as [string, number] | |||||
| return (id_A - id_B) | |||||
| }); | |||||
| console.log(subsidiariesCombo) | |||||
| const searchCriteria: Criterion<SearchParamNames>[] = useMemo( | const searchCriteria: Criterion<SearchParamNames>[] = useMemo( | ||||
| () => [ | () => [ | ||||
| @@ -102,7 +92,7 @@ return ( | |||||
| } | } | ||||
| if (query.team.length > 0 && query.team.toLocaleLowerCase() !== "all") { | if (query.team.length > 0 && query.team.toLocaleLowerCase() !== "all") { | ||||
| const index = teamCombo.findIndex(team => team === query.team) | const index = teamCombo.findIndex(team => team === query.team) | ||||
| const teamId = team[index].id | |||||
| const teamId = sortedTeam[index].id | |||||
| postData.teamId = teamId | postData.teamId = teamId | ||||
| } | } | ||||
| if (Boolean(query.lowerLimit)) { | if (Boolean(query.lowerLimit)) { | ||||