D7: read-only schedule grid UI (rows=instances, cols=positions, week nav)
Server-component schedule page backed by a pure data layer (src/db/grid.ts): gridForWeek() returns positions + instances (->slots->assignments), and defaultWeekStart() defaults to the earliest upcoming published instance so a seeded DB shows data on first load. Week nav via ?week=YYYY-MM-DD (server rendered, no client state). Fixes two latent bugs that kept the grid empty/incorrect: - tz: weekdayInTz()/nextSundaysInTz() built Date.UTC(y,mo-1,d) from a LOCAL date string and read its weekday; for America/New_York (UTC-5) UTC midnight lands the previous evening, so the seed materialized instances on Mondays and the default week was off by one. weekdayInTz now builds the local-midnight instant via utcOffsetMs; nextSundaysInTz uses weekdayInTz + addDaysISO. - grid: occursOn (date mode) was run through dateInTimezone(), reinterpreting the UTC instant as wall-clock and shifting a day early; now extracts the UTC calendar date directly (occursOnISO). - schedule-grid: <table className=... collapse ...> set visibility: collapse (Tailwind 'collapse'), hiding the whole grid server-rendered-but-invisible; changed to border-collapse. E2E: new schedule-grid.spec.ts + shell.spec.ts grid assertion. Full suite green: tsc, eslint, 178 unit tests, next build, 6/6 Playwright.
This commit is contained in:
@@ -1,16 +1,39 @@
|
||||
import { StateMessage } from "@/components/app/state-message";
|
||||
import { gridForWeek, defaultWeekStart } from "@/db/grid";
|
||||
import { WeekNav } from "@/components/app/week-nav";
|
||||
import { ScheduleGrid } from "@/components/app/schedule-grid";
|
||||
|
||||
export const metadata = { title: "Schedule" };
|
||||
|
||||
export default function SchedulePage() {
|
||||
/**
|
||||
* Scheduling grid (unit D7). Read-only: rows = instances, cols = positions,
|
||||
* with week navigation via `?week=YYYY-MM-DD` (a Sunday). Defaults to the week
|
||||
* of the earliest upcoming published instance so a seeded DB shows data at once.
|
||||
*/
|
||||
export default async function SchedulePage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ week?: string }>;
|
||||
}) {
|
||||
const { week: paramWeek } = await searchParams;
|
||||
// Validate the param is a YYYY-MM-DD string; fall back to the default week.
|
||||
const weekStart =
|
||||
typeof paramWeek === "string" && /^\d{4}-\d{2}-\d{2}$/.test(paramWeek)
|
||||
? paramWeek
|
||||
: await defaultWeekStart();
|
||||
|
||||
const week = await gridForWeek(weekStart);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-lg font-semibold tracking-tight">Schedule</h1>
|
||||
<p className="text-sm text-muted-foreground">Your upcoming slots and what to do the day of service.</p>
|
||||
<StateMessage
|
||||
title="Nothing scheduled yet"
|
||||
description="Slots confirmed for you will show up here, with call times and a way to add them to your calendar."
|
||||
/>
|
||||
</>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold tracking-tight">Schedule</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Service instances for the week and who is on each position.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<WeekNav weekStart={weekStart} />
|
||||
<ScheduleGrid week={week} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user