From 0458e17f354df00d0f2cabb2c68ede0d8b4f9ea4 Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Sai Potteri Date: Thu, 25 Jun 2026 11:44:52 +0530 Subject: [PATCH] =?UTF-8?q?calendar:=20hide=20cars=20with=20no=20slots=20i?= =?UTF-8?q?n=20displayed=20week=20(kill=20dead=20=E2=80=94=20rows)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calendar reserved a row for every dealer car even when the car had zero slots in the shown week (seeding gaps), rendering as dead '—, —' rows. New weekCars memo filters to cars with >=1 slot that week. Co-Authored-By: Claude Opus 4.8 --- src/api/viewService.ts | 2 +- src/components/variants/Calendar.tsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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 (