From c84d9a34c3b4c8e63646e4eb2a0de5eb918a35b4 Mon Sep 17 00:00:00 2001 From: Nicolay Bennett Rennemo Date: Mon, 9 Nov 2026 14:03:25 +0100 Subject: [PATCH] added real venues and support for non-applicable opening times (varying) --- apps/backend/src/schema/schema.ts | 22 +- .../src/components/ClientVenueMap.tsx | 2 +- apps/frontend/src/components/SearchBox.tsx | 4 + apps/frontend/src/components/VenueCard.tsx | 1 + apps/frontend/src/components/VenueMap.tsx | 2 +- apps/frontend/src/components/ViewVenue.tsx | 17 +- .../components/__tests__/ViewVenue.test.tsx | 20 + apps/frontend/src/graphql/venues.ts | 4 + apps/frontend/src/lib/format-opening-hours.ts | 5 + apps/frontend/src/routes/index.tsx | 5 + apps/frontend/src/test/fixtures.ts | 2 + apps/frontend/src/types/search.ts | 6 + apps/frontend/src/types/venue.ts | 7 + .../migration.sql | 3 + .../migration.sql | 16 + packages/db/prisma/schema.prisma | 28 +- packages/db/prisma/seed.ts | 375 ++++++++++++++---- packages/db/src/index.ts | 6 +- 18 files changed, 425 insertions(+), 100 deletions(-) create mode 100644 packages/db/prisma/migrations/20261109120000_add_opening_hours_note/migration.sql create mode 100644 packages/db/prisma/migrations/20261109130000_opening_hours_note_table/migration.sql diff --git a/apps/backend/src/schema/schema.ts b/apps/backend/src/schema/schema.ts index 4a55898..aad9ca5 100644 --- a/apps/backend/src/schema/schema.ts +++ b/apps/backend/src/schema/schema.ts @@ -1,5 +1,9 @@ import { GlassSize, Prisma, prisma } from '@t09-project-2/db' -import type { OpeningHours, PriceSighting } from '@t09-project-2/db' +import type { + OpeningHours, + OpeningHoursNote, + PriceSighting, +} from '@t09-project-2/db' import { builder } from '../builder.js' import { latestPriceSightings } from './price-sightings.js' @@ -13,6 +17,7 @@ builder.prismaObject('Venue', { lat: t.exposeFloat('lat'), lon: t.exposeFloat('lon'), openingHours: t.relation('openingHours'), + openingHoursNotes: t.relation('openingHoursNotes'), city: t.relation('city'), pricesSighted: t.relation('pricesSighted'), reviews: t.relation('reviews'), @@ -27,6 +32,13 @@ const openingHoursRef = builder.prismaObject('OpeningHours', { }), }) +const openingHoursNoteRef = builder.prismaObject('OpeningHoursNote', { + fields: (t) => ({ + days: t.exposeStringList('days'), + note: t.exposeString('note'), + }), +}) + builder.prismaObject('City', { fields: (t) => ({ id: t.exposeString('id'), @@ -88,6 +100,7 @@ type SearchResultItem = { distanceKm: number | null address: string | null openingHours: OpeningHours[] | null + openingHoursNotes: OpeningHoursNote[] | null latestPriceSighting: PriceSighting | null averageRating: number | null reviewCount: number @@ -109,6 +122,10 @@ const searchResultRef = builder type: [openingHoursRef], nullable: { list: true, items: false }, }), + openingHoursNotes: t.expose('openingHoursNotes', { + type: [openingHoursNoteRef], + nullable: { list: true, items: false }, + }), latestPriceSighting: t.expose('latestPriceSighting', { type: priceSightingRef, nullable: true, @@ -439,6 +456,7 @@ builder.queryType({ where: { id: { in: rows.map((row) => row.id) } }, include: { openingHours: true, + openingHoursNotes: true, pricesSighted: true, }, }) @@ -469,6 +487,7 @@ builder.queryType({ distanceKm: row.distance_km, address: venue.address, openingHours: venue.openingHours, + openingHoursNotes: venue.openingHoursNotes, latestPriceSighting, averageRating: row.average_rating, reviewCount: row.review_count, @@ -488,6 +507,7 @@ builder.queryType({ distanceKm: null, address: null, openingHours: null, + openingHoursNotes: null, latestPriceSighting: null, averageRating: null, reviewCount: 0, diff --git a/apps/frontend/src/components/ClientVenueMap.tsx b/apps/frontend/src/components/ClientVenueMap.tsx index 9c3ba4f..46fea47 100644 --- a/apps/frontend/src/components/ClientVenueMap.tsx +++ b/apps/frontend/src/components/ClientVenueMap.tsx @@ -28,7 +28,7 @@ export default function ClientVenueMap(props: VenueMapProps) { const ready = mounted && LazyVenueMap != null return ( -
+