feat: explain a schedule change on the panel, and preview it in advance

Two things the shop asked for, and one it will notice.

**A message on an exception.** A closure or a late opening can now carry
a reason, and it reaches the panel. It shows while the door is shut and
disappears the moment the shop opens — a notice explaining a late
opening is worse than useless once the door is open.

It outranks a free message on purpose: "closed this afternoon, back
tomorrow" is what someone standing outside needs, and "new collection in
store" can wait. Say so if you would rather it were the other way.

The first version keyed this off the day's `isOpen`, which means "this
day has opening hours" — so a day opening at 14:00 counted as open all
morning, exactly when the reason is needed. A test caught it; the rule
now reads the state at this minute.

**Reusable phrases.** The same handful of notices get written over and
over. /admin/modeles keeps them, translated once, and offers them
wherever a message is composed — exceptions, closure periods, the
banner. Picking one costs no translation at all: the saved English is
reused directly, where the service takes the better part of ten seconds.

Exception notes and holiday labels are translated too, which they were
not before. After the save rather than during it, so a slow service
never costs the shop its dates.

**Previewing the future.** The dashboard can render the panel at any
moment within about a year: "what will the window say while I'm away?"
is worth answering before someone is standing in front of a locked door.
The whole pipeline was already a function of "now", so this costs
passing a different instant. An unparseable or absurd value falls back
to the present rather than confidently rendering nonsense.

Checked against a three-week holiday, which surfaced something worth
knowing: the automatic "opens on…" line stays empty, because the
resolver's search is bounded to fourteen days. During a long closure the
message is the only thing that tells customers when the shop is back —
which is a good reason for this feature to exist.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012cSY9pVhZmJUKNN7wf1Myd
This commit is contained in:
2026-09-23 09:34:14 +02:00
co-authored by Claude Opus 5
parent 743a3778cc
commit 5f7aa951d3
29 changed files with 1141 additions and 59 deletions
+57
View File
@@ -0,0 +1,57 @@
'use client';
/**
* Offers the shop's saved phrases wherever a message is composed.
*
* A picker rather than a free-text-only field, because the same handful of
* notices get written over and over: choosing one keeps the wording
* consistent and — more importantly — reuses a phrase that has already been
* translated, instead of paying for a fresh translation of the same sentence.
*
* The chosen text lands in the field and stays editable. A template is a
* starting point, not a constraint.
*/
export type Template = { id: string; textFr: string };
export default function TemplatePicker({
templates,
onPick,
disabled = false,
label = 'Modèle',
}: {
templates: Template[];
onPick: (textFr: string) => void;
disabled?: boolean;
label?: string;
}) {
if (templates.length === 0) {
return null;
}
return (
<label className="flex items-center gap-2 text-sm">
<span className="text-[var(--ink-muted)]">{label}</span>
<select
aria-label={`${label} de message`}
value=""
disabled={disabled}
onChange={(event) => {
const picked = templates.find((template) => template.id === event.target.value);
if (picked) {
onPick(picked.textFr);
}
// Back to the placeholder: the control is an action, not a state.
event.target.value = '';
}}
className="max-w-56 rounded-[var(--radius-sm)] border border-[var(--line-strong)] bg-[var(--surface)] px-2 py-1.5 text-sm disabled:opacity-40"
>
<option value="">Choisir…</option>
{templates.map((template) => (
<option key={template.id} value={template.id}>
{template.textFr}
</option>
))}
</select>
</label>
);
}