diff --git a/src/api/viewService.ts b/src/api/viewService.ts index 059b5a9..6ae5caf 100644 --- a/src/api/viewService.ts +++ b/src/api/viewService.ts @@ -27,7 +27,7 @@ async function request(method: string, path: string, body?: unknown): Promise } if (!res.ok) { let msg = res.statusText; - try { const e = await res.json(); if (e.error) msg = e.error; } catch {} + try { const e = await res.json(); if (e.error) msg = e.error; } catch { } throw new Error(msg); } if (res.status === 204) return undefined as T; diff --git a/src/components/variants/Calendar.tsx b/src/components/variants/Calendar.tsx index b5e78c3..eefd636 100644 --- a/src/components/variants/Calendar.tsx +++ b/src/components/variants/Calendar.tsx @@ -214,6 +214,17 @@ export function CalendarView() { const visibleCarIds = useMemo(() => new Set(visibleCars.map((c) => Number(c.id))), [visibleCars]); + // Only render rows for cars that actually have ≥1 slot in the displayed week, + // otherwise cars with no slots this week (e.g. seeding gaps) show as dead "—" rows. + const weekCars = useMemo(() => { + const days = new Set(weekDays); + const idsThisWeek = new Set(); + dealerDrives.forEach((d) => { + if (days.has(istDayKey(d.slot_start))) idsThisWeek.add(Number(d.car_id)); + }); + return visibleCars.filter((c) => idsThisWeek.has(Number(c.id))); + }, [visibleCars, dealerDrives, weekDays]); + // For the visible week, count bookings per day for the header summary. const bookingsByDay = useMemo(() => { const m = new Map(); @@ -374,7 +385,7 @@ export function CalendarView() { {weekDays.map((dk) => (
- {visibleCars.map((c) => { + {weekCars.map((c) => { const cell = grid.get(`${dk}|${tk}|${Number(c.id)}`); if (!cell) { return (