Skip to content

Commit 0533f9b

Browse files
added button for showing deleted events only (#177)
* added button for showing deleted events only * slo-only view added to deletedEvents button * fixed typo
1 parent 29566d5 commit 0533f9b

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

src/app/manage/events/page.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async function getalleventsquery(querystring) {
2323
clubid: querystring["targetClub"],
2424
public: false,
2525
pastEventsLimit: querystring["pastEventsLimit"],
26+
deletedEvents: querystring["deletedEvents"],
2627
});
2728

2829
if (error) {
@@ -86,6 +87,7 @@ export default async function ManageEvents() {
8687
clubid={userMeta?.role === "club" ? userMeta.uid : null}
8788
scheduleSort="desc"
8889
hideClub={userMeta?.role === "club"} // hide club column if accessed by a club
90+
canViewDeletedEvents={userMeta?.role === "slo"}
8991
/>
9092
</Container>
9193
);

src/components/events/EventsTable.jsx

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ export default function EventsTable({
5555
clubid,
5656
scheduleSort = "asc",
5757
hideClub = false,
58+
canViewDeletedEvents = false,
5859
}) {
5960
const router = useRouter();
6061
const theme = useTheme();
6162
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
6263

6364
// Toggle state for Last 4 Months
65+
const [deleteToggle, setDeleteToggle] = useState([]);
6466
const [filterMonth, setFilterMonth] = useState(["pastEventsLimit"]);
6567
const [events, setEvents] = useState(initialEvents || []);
6668
const [dialog, setDialog] = useState(false);
@@ -77,12 +79,13 @@ export default function EventsTable({
7779
let params = {
7880
targetClub: clubid,
7981
pastEventsLimit: filterMonth.includes("pastEventsLimit") ? 4 : null,
82+
deletedEvents: deleteToggle.includes("toggleDeletedEvents"),
8083
};
8184
const result = await query(params);
8285
setEvents(result || []);
8386
}
8487
fetchEvents();
85-
}, [query, clubid, filterMonth, initialEvents]);
88+
}, [query, clubid, filterMonth, deleteToggle, initialEvents]);
8689

8790
const columns = [
8891
...(isMobile
@@ -369,29 +372,48 @@ export default function EventsTable({
369372
{query ? "All Events" : "Pending Events"}
370373
</Typography>
371374
{query && (
372-
<FormControlLabel
373-
control={
374-
<Switch
375-
checked={filterMonth.includes("pastEventsLimit")}
376-
onChange={(e) => {
377-
// Only show dialog when switching from ON to OFF
378-
if (
379-
filterMonth.includes("pastEventsLimit") &&
380-
!e.target.checked
381-
) {
382-
setDialog(true);
383-
} else {
384-
setFilterMonth(
385-
e.target.checked ? ["pastEventsLimit"] : [],
386-
);
387-
}
388-
}}
389-
color="primary"
375+
<Box sx={{ display: "flex", alignItems: "center" }}>
376+
<FormControlLabel
377+
control={
378+
<Switch
379+
checked={filterMonth.includes("pastEventsLimit")}
380+
onChange={(e) => {
381+
// Only show dialog when switching from ON to OFF
382+
if (
383+
filterMonth.includes("pastEventsLimit") &&
384+
!e.target.checked
385+
) {
386+
setDialog(true);
387+
} else {
388+
setFilterMonth(
389+
e.target.checked ? ["pastEventsLimit"] : [],
390+
);
391+
}
392+
}}
393+
color="primary"
394+
/>
395+
}
396+
label="Last 4 Months"
397+
sx={{ marginLeft: 1 }}
398+
/>
399+
{canViewDeletedEvents && (
400+
<FormControlLabel
401+
control={
402+
<Switch
403+
checked={deleteToggle.includes("toggleDeletedEvents")}
404+
onChange={(e) => {
405+
setDeleteToggle(
406+
e.target.checked ? ["toggleDeletedEvents"] : [],
407+
);
408+
}}
409+
color="primary"
410+
/>
411+
}
412+
label="Show Only Deleted Events"
413+
sx={{ marginLeft: 1 }}
390414
/>
391-
}
392-
label="Last 4 Months"
393-
sx={{ marginLeft: 1 }}
394-
/>
415+
)}
416+
</Box>
395417
)}
396418
<ConfirmDialog
397419
open={dialog}

src/gql/queries/events.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const GET_ALL_EVENTS = gql`
4141
$public: Boolean
4242
$timings: [DateTime!]
4343
$pastEventsLimit: Int
44+
$deletedEvents: Boolean
4445
) {
4546
events(
4647
clubid: $clubid
@@ -51,6 +52,7 @@ export const GET_ALL_EVENTS = gql`
5152
public: $public
5253
timings: $timings
5354
pastEventsLimit: $pastEventsLimit
55+
deletedEvents: $deletedEvents
5456
) {
5557
_id
5658
name

0 commit comments

Comments
 (0)