calendar: hide cars with no slots in displayed week (kill dead — rows)

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 <noreply@anthropic.com>
This commit is contained in:
Bhanu Prakash Sai Potteri 2026-06-25 11:44:52 +05:30
parent 338bacda90
commit 0458e17f35
2 changed files with 13 additions and 2 deletions

View File

@ -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<number>();
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<string, number>();
@ -374,7 +385,7 @@ export function CalendarView() {
{weekDays.map((dk) => (
<td key={dk + tk} className="px-2 py-2 align-top" style={{ borderTop: `1px solid ${TM_BORDER}`, borderLeft: `1px solid ${TM_BORDER}` }}>
<div className="grid grid-cols-1 gap-1">
{visibleCars.map((c) => {
{weekCars.map((c) => {
const cell = grid.get(`${dk}|${tk}|${Number(c.id)}`);
if (!cell) {
return (