Skip to content

Commit

Permalink
fix(webapp): show elections with data on expense
Browse files Browse the repository at this point in the history
  • Loading branch information
JAMares committed Dec 28, 2022
1 parent 4b4b505 commit 3ce6ce0
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions webapp/src/hooks/customHooks/useExpenseReportState.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,36 @@ const useExpenseReportState = () => {
maxDate: `${new Date().getFullYear()}-12-31`
})

setExpenseByElectionsList(
newDataFormatByCategorizedElectionsExpense(expenseByElections.data || [])
)
setElectionsByYearList([
...electionsByYear?.data?.eden_historic_election,
electionsByYearList
])
// setElectionsByYearList([
// ...electionsByYear?.data?.eden_historic_election,
// electionsByYearList
// ])
setElectionRoundSelect(
electionsByYear?.data?.eden_historic_election[0]?.election
)
setElectionsByYearList(electionsByYear?.data?.eden_historic_election || [])
setExpenseByElectionsList(
newDataFormatByCategorizedElectionsExpense(expenseByElections.data || [])
)
}, [])

useEffect(() => {
const rounds = []
for (let pos = 0; pos < expenseByElectionsList.length; pos++) {
const election = Number(
expenseByElectionsList[pos].election.charAt(
expenseByElectionsList[pos].election.length - 1
)
)
const newElections = electionsByYearList.filter(
elec => elec.election === election - 1
)
rounds.push(newElections[0])
}
setElectionsByYearList(rounds)
setElectionRoundSelect(rounds[0]?.election)
}, [expenseByElectionsList])

useEffect(async () => {
if (showElectionRadio === 'allElections') {
const totalExpenseByDelegate = await loadTotalExpenseByDelegate()
Expand Down

0 comments on commit 3ce6ce0

Please sign in to comment.