Skip to content

Commit e081854

Browse files
committed
show all events toggle outside of filter modal
1 parent ef4874b commit e081854

2 files changed

Lines changed: 40 additions & 59 deletions

File tree

src/frontend/src/pages/CalendarPage/CalendarPage.tsx

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
Alert,
1515
Checkbox,
1616
FormControlLabel,
17-
FormGroup
17+
FormGroup,
18+
Switch
1819
} from '@mui/material';
1920
import PageLayout from '../../components/PageLayout';
2021
import { Calendar, ConflictStatus, DayOfWeek, EventType, Event } from 'shared';
@@ -709,28 +710,42 @@ const NewCalendarPage: React.FC<NewCalendarPageProps> = ({
709710
Calendars:
710711
</Typography>
711712

712-
<Button
713-
size="small"
714-
variant="outlined"
715-
id="filter-events-button"
716-
onClick={() => setOpenFilterModal(true)}
717-
sx={{
718-
px: 1,
719-
py: 0,
720-
color: 'white',
721-
borderColor: 'white',
722-
backgroundColor: 'transparent',
723-
textTransform: 'none',
724-
fontSize: 14,
725-
fontFamily: (t) => t.typography.h4.fontFamily,
726-
'&:hover': {
727-
borderColor: 'white',
728-
backgroundColor: 'rgba(255, 255, 255, 0.1)'
713+
<Stack direction="row" spacing={1} alignItems="center">
714+
<FormControlLabel
715+
control={
716+
<Switch size="small" checked={allEventsMode} onChange={(e) => setAllEventsMode(e.target.checked)} />
729717
}
730-
}}
731-
>
732-
Filters
733-
</Button>
718+
label={<Typography sx={{ fontSize: 12, color: 'white', whiteSpace: 'nowrap' }}>All Events</Typography>}
719+
sx={{ mr: 0 }}
720+
/>
721+
<Button
722+
size="small"
723+
variant="outlined"
724+
id="filter-events-button"
725+
disabled={allEventsMode}
726+
onClick={() => setOpenFilterModal(true)}
727+
sx={{
728+
px: 1,
729+
py: 0,
730+
color: 'white',
731+
borderColor: 'white',
732+
backgroundColor: 'transparent',
733+
textTransform: 'none',
734+
fontSize: 14,
735+
fontFamily: (t) => t.typography.h4.fontFamily,
736+
'&:hover': {
737+
borderColor: 'white',
738+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
739+
},
740+
'&.Mui-disabled': {
741+
color: 'rgba(255, 255, 255, 0.3)',
742+
borderColor: 'rgba(255, 255, 255, 0.3)'
743+
}
744+
}}
745+
>
746+
Filters
747+
</Button>
748+
</Stack>
734749
</Stack>
735750

736751
{calendars.length > 0 && (
@@ -810,7 +825,6 @@ const NewCalendarPage: React.FC<NewCalendarPageProps> = ({
810825
setTeamIds={(ids: string[]) => setTeamIds(ids)}
811826
setShowInvited={(changed: boolean) => updateAdditionalMemberIds(changed)}
812827
setShowTeam={(changed: boolean) => updateAdditionalTeamIds(changed)}
813-
setAllEventsMode={(enabled: boolean) => setAllEventsMode(enabled)}
814828
/>
815829
</PageLayout>
816830
</>

src/frontend/src/pages/CalendarPage/FilterModal.tsx

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import React, { useState } from 'react';
2-
import {
3-
Autocomplete,
4-
Box,
5-
Button,
6-
Checkbox,
7-
FormControlLabel,
8-
Switch,
9-
TextField,
10-
Typography,
11-
useTheme
12-
} from '@mui/material';
2+
import { Autocomplete, Box, Button, Checkbox, TextField, Typography } from '@mui/material';
133
import NERModal from '../../components/NERModal';
144
import PeopleIcon from '@mui/icons-material/People';
155
import { useAllUsers, useCurrentUser } from '../../hooks/users.hooks';
@@ -32,7 +22,6 @@ export interface BaseFilterModalProps {
3222
setTeamIds: (ids: string[]) => void;
3323
setShowInvited: (changed: boolean) => void;
3424
setShowTeam: (changed: boolean) => void;
35-
setAllEventsMode: (enabled: boolean) => void;
3625
}
3726

3827
const FilterModal: React.FC<BaseFilterModalProps> = ({
@@ -42,14 +31,11 @@ const FilterModal: React.FC<BaseFilterModalProps> = ({
4231
setMemberIds,
4332
setTeamIds,
4433
setShowInvited,
45-
setShowTeam,
46-
setAllEventsMode
34+
setShowTeam
4735
}) => {
4836
const [dropDownMembersOpen, setDropDownMembersOpen] = useState(false);
4937
const [dropDownTeamOpen, setDropDownTeamOpen] = useState(false);
5038
const currUser = useCurrentUser();
51-
const theme = useTheme();
52-
const allEventsMode = filterValues?.allEventsMode ?? false;
5339

5440
const MemberDropdown = () => {
5541
const memberIds = filterValues?.memberIds ?? [];
@@ -284,26 +270,7 @@ const FilterModal: React.FC<BaseFilterModalProps> = ({
284270
formId="shop-form"
285271
showCloseButton
286272
>
287-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 2 }}>
288-
<FormControlLabel
289-
control={
290-
<Switch
291-
checked={allEventsMode}
292-
onChange={(e) => setAllEventsMode(e.target.checked)}
293-
sx={{
294-
'& .MuiSwitch-switchBase.Mui-checked': {
295-
color: theme.palette.primary.main
296-
},
297-
'& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track': {
298-
backgroundColor: theme.palette.primary.main
299-
}
300-
}}
301-
/>
302-
}
303-
label={<Typography sx={{ fontSize: 16, color: 'white' }}>Show All Events</Typography>}
304-
/>
305-
</Box>
306-
<Box sx={{ opacity: allEventsMode ? 0.5 : 1, pointerEvents: allEventsMode ? 'none' : 'auto' }}>
273+
<Box>
307274
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
308275
<PeopleIcon sx={{ color: 'white', mr: 1 }} />
309276
<Typography variant="h6">Attendees</Typography>

0 commit comments

Comments
 (0)