|
@@ -32,7 +32,8 @@ type SearchParamNames = keyof SearchQuery; |
|
|
const ResourceOverconsumptionReport: React.FC<Props> = ({ team, customer, subsidiaries, needAll }) => { |
|
|
const ResourceOverconsumptionReport: React.FC<Props> = ({ team, customer, subsidiaries, needAll }) => { |
|
|
const { t } = useTranslation("report"); |
|
|
const { t } = useTranslation("report"); |
|
|
const statusCombo = ["Potential Overconsumption"] |
|
|
const statusCombo = ["Potential Overconsumption"] |
|
|
const teamCombo = team.map(t => `${t.code} - ${t.name}`).sort() |
|
|
|
|
|
|
|
|
const sortedTeam = team.sort((a, b) => a.code.localeCompare(b.code)); |
|
|
|
|
|
const teamCombo = sortedTeam.map(t => `${t.code} - ${t.name}`) |
|
|
const custCombo: combo[] = customer.map(c => ({ |
|
|
const custCombo: combo[] = customer.map(c => ({ |
|
|
value: `custId-${c.id}`, |
|
|
value: `custId-${c.id}`, |
|
|
label: `${c.code} - ${c.name}`, |
|
|
label: `${c.code} - ${c.name}`, |
|
@@ -101,20 +102,9 @@ return ( |
|
|
lowerLimit: 0.9 |
|
|
lowerLimit: 0.9 |
|
|
} |
|
|
} |
|
|
if (query.team.length > 0 && query.team.toLocaleLowerCase() !== "all") { |
|
|
if (query.team.length > 0 && query.team.toLocaleLowerCase() !== "all") { |
|
|
console.log(team) |
|
|
|
|
|
console.log(query.team) |
|
|
|
|
|
console.log(teamCombo) |
|
|
|
|
|
index = teamCombo.findIndex(team => team === query.team) |
|
|
index = teamCombo.findIndex(team => team === query.team) |
|
|
const teamId1 = team[index].id |
|
|
|
|
|
console.log(teamId1) |
|
|
|
|
|
const sortedTeam = team.sort((a, b) => a.code.localeCompare(b.code)) |
|
|
|
|
|
const sortedId = sortedTeam[index].id |
|
|
|
|
|
console.log(sortedId) |
|
|
|
|
|
// console.log(sortedId) |
|
|
|
|
|
// console.log(team.find(team => query.team === `${team.code} - Team ${team.staffName}`)?.id) |
|
|
|
|
|
// const teamId = team.find(team => query.team === `${team.code} - Team ${team.staffName}`)?.id |
|
|
|
|
|
postData.teamId = sortedId |
|
|
|
|
|
// postData.teamId = teamId |
|
|
|
|
|
|
|
|
const teamId = team[index].id |
|
|
|
|
|
postData.teamId = teamId |
|
|
} |
|
|
} |
|
|
if (Boolean(query.lowerLimit)) { |
|
|
if (Boolean(query.lowerLimit)) { |
|
|
postData.lowerLimit = query.lowerLimit/100 |
|
|
postData.lowerLimit = query.lowerLimit/100 |
|
@@ -124,7 +114,6 @@ return ( |
|
|
} |
|
|
} |
|
|
postData.status = query.status |
|
|
postData.status = query.status |
|
|
console.log(postData) |
|
|
console.log(postData) |
|
|
return |
|
|
|
|
|
const response = await fetchProjectResourceOverconsumptionReport(postData) |
|
|
const response = await fetchProjectResourceOverconsumptionReport(postData) |
|
|
if (response) { |
|
|
if (response) { |
|
|
downloadFile(new Uint8Array(response.blobValue), response.filename!!) |
|
|
downloadFile(new Uint8Array(response.blobValue), response.filename!!) |
|
|