From 240633177cc646e6662f27e1334b5e83d962170d Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Fri, 6 Sep 2024 01:22:10 -0400 Subject: Update MyChore to have filter button instead of chips --- src/views/Chores/MyChores.jsx | 169 +++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 83 deletions(-) (limited to 'src/views/Chores') diff --git a/src/views/Chores/MyChores.jsx b/src/views/Chores/MyChores.jsx index d4eed5a..f7b27da 100644 --- a/src/views/Chores/MyChores.jsx +++ b/src/views/Chores/MyChores.jsx @@ -1,13 +1,17 @@ -import { Add, CancelRounded, EditCalendar } from '@mui/icons-material' import { - Badge, + Add, + CancelRounded, + EditCalendar, + FilterAlt, + FilterAltOff, +} from '@mui/icons-material' +import { Box, - Checkbox, + Chip, Container, IconButton, Input, List, - ListItem, Menu, MenuItem, Snackbar, @@ -192,95 +196,27 @@ const MyChores = () => { My Chores */} {/* */} - - {['All', 'Overdue', 'Due today', 'Due in week'].map(filter => ( - - - handleSelectedFilter(filter)} - checked={filter === selectedFilter} - disableIcon - overlay - size='sm' - /> - - - ))} - - - - - - { - setFilteredChores( - FILTERS['Assigned To Me'](chores, userProfile.id), - ) - setSelectedFilter('Assigned To Me') - handleFilterMenuClose() - }} - > - Assigned to me - - { - setFilteredChores( - FILTERS['Created By Me'](chores, userProfile.id), - ) - setSelectedFilter('Created By Me') - handleFilterMenuClose() - }} - > - Created by me - - { - setFilteredChores(FILTERS['No Due Date'](chores, userProfile.id)) - setSelectedFilter('No Due Date') - handleFilterMenuClose() - }} - > - No Due Date - - - - {/* Search box to filter */} - { ) } /> + + {selectedFilter && selectedFilter != 'All' ? ( + + ) : ( + + )} + + + {/* */} + + + {Object.keys(FILTERS).map(filter => ( + { + const filterFunction = FILTERS[filter] + const filteredChores = + filterFunction.length === 2 + ? filterFunction(chores, userProfile.id) + : filterFunction(chores) + setFilteredChores(filteredChores) + setSelectedFilter(filter) + handleFilterMenuClose() + }} + > + {filter} + + {FILTERS[filter].length === 2 + ? FILTERS[filter](chores, userProfile.id).length + : FILTERS[filter](chores).length} + + + ))} + + {/* */} -- cgit