Skip to content

Commit

Permalink
Add (de)select all option to ticket filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ansonjwhe committed Sep 17, 2024
1 parent 40f330b commit 4cc03b8
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions frontend/src/components/FilterDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Button,
Menu,
MenuButton,
MenuItem,
MenuList,
MenuItemOption,
MenuOptionGroup,
Expand All @@ -26,10 +27,30 @@ const FilterDropdown = ({ filter, setFilter }) => {
>
Filter Tickets
</MenuButton>
<MenuList minWidth="240px">
<MenuList>
<MenuItem
onClick={() => {
if (
filter.length ===
Object.keys(TICKET_TYPES).length
) {
setFilter([])
setSearchParams({
tickettypes: '',
})
} else {
setFilter(Object.keys(TICKET_TYPES))
searchParams.delete('tickettypes')
setSearchParams(searchParams)
}
}}
>
{filter.length === Object.keys(TICKET_TYPES).length
? 'Deselect All'
: 'Select All'}
</MenuItem>
<MenuOptionGroup
defaultValue={filter}
title="Ticket Type"
value={filter}
type="checkbox"
onChange={(value) => {
setFilter(value)
Expand All @@ -47,16 +68,16 @@ const FilterDropdown = ({ filter, setFilter }) => {
}
}}
>
<MenuItemOption value={`${TICKET_TYPES.SF}`}>
<MenuItemOption value={TICKET_TYPES.SF}>
Sponsorship Funds
</MenuItemOption>
<MenuItemOption value={`${TICKET_TYPES.FI}`}>
<MenuItemOption value={TICKET_TYPES.FI}>
Funding Items
</MenuItemOption>
<MenuItemOption value={`${TICKET_TYPES.PPR}`}>
<MenuItemOption value={TICKET_TYPES.PPR}>
Personal Purchase Requests
</MenuItemOption>
<MenuItemOption value={`${TICKET_TYPES.UPR}`}>
<MenuItemOption value={TICKET_TYPES.UPR}>
UW Finance Purchase Requests
</MenuItemOption>
</MenuOptionGroup>
Expand Down

0 comments on commit 4cc03b8

Please sign in to comment.