fix venue filtering bug, hide venues with no upcoming events, show message if no upcoming events

This commit is contained in:
ponas committed 2024-08-18 02:09:34 +02:00
1 parent 2830e0a2e8
commit 852882d392
3 files changed
+25 -13

No files matched your search

+16 -10
View File
@@ -82,18 +82,19 @@ export const EventContainer = ({
Filtering on a venue with no upcoming events will work,
and in that case it's included in the dropdown
*/
const venueSlugsWithUpcomingEvents = events
.map((x) => x.occurrences)
.flat()
.filter((x) => x.venue?.__typename === "VenuePage")
.map((x) => x.venue?.slug)
.filter((x) => typeof x === "string");
const venueSlugsWithUpcomingEvents = unique(
events
.map((x) => x.occurrences)
.flat()
.filter((x) => x.venue?.__typename === "VenuePage")
.map((x) => x.venue?.slug)
.filter((x) => typeof x === "string")
);
const filterableVenues = venues
.map((x) =>
venues.find(
(haystack) => haystack.slug === x.slug || haystack.slug === venue
)
.filter(
(x) => venueSlugsWithUpcomingEvents.includes(x.slug) || x.slug === venue
)
.map((x) => venues.find((haystack) => haystack.slug === x.slug))
.filter((x) => x !== undefined) as VenueFragment[];
const filteredEvents = events
@@ -186,6 +187,11 @@ export const EventContainer = ({
};
const EventList = ({ events }: { events: EventFragment[] }) => {
if (events.length === 0) {
return (
<div className={styles.noEvents}>Ingen kommende arrangementer.</div>
);
}
return (
<ul className={styles.eventList}>
{events.map((event) => (