Skip to content

Commit

Permalink
fix(webapp): remove year drop down on expense
Browse files Browse the repository at this point in the history
  • Loading branch information
JAMares committed Dec 28, 2022
1 parent e7c941e commit 4b4b505
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
29 changes: 4 additions & 25 deletions webapp/src/hooks/customHooks/useExpenseReportState.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import { useImperativeQuery } from '../../utils'

const useExpenseReportState = () => {
const [electionYearSelect, setElectionYearSelect] = useState('All')
const [electionRoundSelect, setElectionRoundSelect] = useState(0)
const [showElectionRadio, setShowElectionRadio] = useState('allElections')
const [electionsByYearList, setElectionsByYearList] = useState([])
Expand All @@ -28,16 +27,6 @@ const useExpenseReportState = () => {
const [categoryList, setCategoryList] = useState([])
const [percentExpenseList, setPercentExpenseList] = useState([])

const getListElectionYears = () => {
const yearsList = ['All']
const yearCurrent = new Date().getFullYear()
for (let index = 2021; index <= yearCurrent; index++) {
yearsList.push(index)
}

return yearsList
}

const loadExpenseByElections = useImperativeQuery(GET_EXPENSE_BY_ELECTIONS)
const loadTotalExpenseByDelegate = useImperativeQuery(
GET_TOTAL_EXPENSE_BY_DELEGATE
Expand All @@ -56,17 +45,10 @@ const useExpenseReportState = () => {

useEffect(async () => {
const expenseByElections = await loadExpenseByElections()
const electionsByYear = await loadElectionsByYear(
electionYearSelect === 'All' || electionYearSelect === 'Todos'
? {
minDate: `2021-01-01`,
maxDate: `${new Date().getFullYear()}-12-31`
}
: {
minDate: `${electionYearSelect}-01-01`,
maxDate: `${electionYearSelect}-12-31`
}
)
const electionsByYear = await loadElectionsByYear({
minDate: `2021-01-01`,
maxDate: `${new Date().getFullYear()}-12-31`
})

setExpenseByElectionsList(
newDataFormatByCategorizedElectionsExpense(expenseByElections.data || [])
Expand Down Expand Up @@ -137,13 +119,10 @@ const useExpenseReportState = () => {
delegatesList,
categoryList,
electionRoundSelect,
electionYearSelect,
showElectionRadio
},
{
setElectionRoundSelect,
setElectionYearSelect,
getListElectionYears,
setShowElectionRadio
}
]
Expand Down
16 changes: 1 addition & 15 deletions webapp/src/routes/ExpenseReport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ const ExpenseReport = () => {
delegatesList,
categoryList,
electionRoundSelect,
electionYearSelect,
showElectionRadio
},
{
setElectionRoundSelect,
setElectionYearSelect,
getListElectionYears,
setShowElectionRadio
}
{ setElectionRoundSelect, setShowElectionRadio }
] = useExpenseReportState()

const tableData =
Expand Down Expand Up @@ -146,14 +140,6 @@ const ExpenseReport = () => {
</div>
{showElectionRadio === 'oneElection' && (
<div id="id-radio-election-container">
<SelectComponent
onChangeFunction={setElectionYearSelect}
labelSelect={t('textYearSelect', { ns: 'generalForm' })}
values={getListElectionYears()}
actualValue={electionYearSelect}
width={100}
size="small"
/>
<SelectComponent
onChangeFunction={setElectionRoundSelect}
labelSelect={t('textElectionSelect', { ns: 'generalForm' })}
Expand Down

0 comments on commit 4b4b505

Please sign in to comment.