The first administration page, built for the actual use case: a phone held in one hand behind the counter. One card per day, native time inputs so the platform keyboard does the work, and the consequences shown before the save rather than after — the footer names which days are about to change, and the button stays disabled until something actually has. "Duplicate onto the other open days" leaves closed days closed. Someone copying Tuesday's hours means "the days I open, I open like this", not "open seven days a week". Validation runs in the browser for the feedback and again in the action before the write: the client is a convenience, not a guarantee, and this is the schedule the shop window shows. A day being closed drops its leftover slots rather than failing on them. A save that changes nothing writes nothing — no rows, no audit entry, and so no needless panel redraw. Reordering slots does not count as a change. The audit diff stores one readable line per day in French, so the log can be read without cross-referencing the schema. The editing helpers are pure and tested, and the write path is tested against a real database including the read-only refusal. Test files now run sequentially: the integration files share one database and each truncates it, so parallel files raced. The suite takes six seconds; giving every file its own database would buy nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cSY9pVhZmJUKNN7wf1Myd
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { auth } from '@/lib/auth';
|
|
import { prisma } from '@/lib/db';
|
|
import type { Slot } from '@/lib/schedule/types';
|
|
import { toDraft } from '@/lib/schedule/week';
|
|
|
|
import WeekEditor from './WeekEditor';
|
|
|
|
export const metadata = { title: 'Horaires fixes — ITA ITO' };
|
|
|
|
export default async function HoursPage() {
|
|
const [session, rows] = await Promise.all([
|
|
auth(),
|
|
prisma.weeklySchedule.findMany({ orderBy: { dayOfWeek: 'asc' } }),
|
|
]);
|
|
|
|
const initial = toDraft(
|
|
rows.map((row) => ({
|
|
dayOfWeek: row.dayOfWeek,
|
|
isClosed: row.isClosed,
|
|
slots: (row.slots as Slot[] | null) ?? [],
|
|
})),
|
|
);
|
|
|
|
return (
|
|
<main className="mx-auto max-w-3xl px-4 py-10">
|
|
<h1 className="text-2xl">Horaires fixes</h1>
|
|
<p className="mt-2 max-w-prose text-[var(--ink-muted)]">
|
|
La semaine de référence. Les fermetures ponctuelles, les vacances et les jours fériés se
|
|
règlent ailleurs et priment sur ces horaires.
|
|
</p>
|
|
|
|
<WeekEditor initial={initial} canEdit={session?.user?.role === 'admin'} />
|
|
</main>
|
|
);
|
|
}
|