From bf6492426c1620a3e329a9f54f457f7d800ecdcd Mon Sep 17 00:00:00 2001 From: Josh Heng Date: Tue, 28 May 2024 18:46:41 +0100 Subject: [PATCH] :sparkles: Make venue page pretty --- src/app/venues/[slug]/page.tsx | 2 +- src/app/venues/page.tsx | 21 +++++++++------------ src/lib/venues.ts | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/app/venues/[slug]/page.tsx b/src/app/venues/[slug]/page.tsx index ebd4516..a11b9df 100644 --- a/src/app/venues/[slug]/page.tsx +++ b/src/app/venues/[slug]/page.tsx @@ -56,7 +56,7 @@ export default async function Venue({

{venue.description}

{venue.campus_map_url && ( - Campus Map + View on Campus Map )} diff --git a/src/app/venues/page.tsx b/src/app/venues/page.tsx index 6712bb8..21edbc5 100644 --- a/src/app/venues/page.tsx +++ b/src/app/venues/page.tsx @@ -35,14 +35,6 @@ export default async function Venues() { {' '} across our {venues.length} venues.

-

- You can find our full weekend's schedule here or in our printed - programmes - simply head to one of our{' '} - - venues - {' '} - to pick one up! -

-
+
{venues.map((venue) => ( -
-

{venue.name}

+
+

{venue.name}

+

+ {venue._count.schedule_eventinstance} Event + {venue._count.schedule_eventinstance === 1 ? '' : 's'} +

+

{venue.description}

))} diff --git a/src/lib/venues.ts b/src/lib/venues.ts index 50be503..cd39961 100644 --- a/src/lib/venues.ts +++ b/src/lib/venues.ts @@ -1,7 +1,20 @@ import prisma from '@/lib/prisma'; export function getVenues() { - return prisma.schedule_venue.findMany(); + return prisma.schedule_venue.findMany({ + include: { + _count: { + select: { + schedule_eventinstance: { + where: { + published: true, + parent_id: null, + }, + }, + }, + }, + }, + }); } export function getVenueCount() {