The review of PR #210 removed the `^` of DATE_TIME in dueDate.ts and no
test failed: `12026-11-15T09:00:00Z` would then be read as the year 2026
instead of being refused. Two values join the refusal list of
parseDueDate, a fifth digit of the year and a space before a date-time:
with the anchor removed, 1 of the 242 tests of `npx vitest run` fails;
on the code as it is, the 242 pass.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
REVIEW.md, zone "API et isolation des comptes": what POST /api/tasks and
PUT /api/tasks/[id] accept as a due date (a date alone stored at 12:00
UTC, a date-time with Z or an offset kept, the rest refused with a 400),
what a PUT without dueDate does, why the edit form only sends the field
when it changed, and why dueDate.ts stays import-free.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The task forms of the companion send what <input type="date"> gives, a
date alone, and the task schemas only took a full date-time: POST
/api/tasks answered 400 for any dated task, PUT /api/tasks/[id] for any
task that already had a due date, and both forms closed as if the write
had worked.
- dueDate.ts (new, import-free): parseDueDate turns a date alone into
that day at 12:00 UTC, keeps the instant of an ISO 8601 date-time with
Z or an offset, and refuses the rest (a date-time without a time zone,
a day that does not exist, a year PostgreSQL cannot store). localDay
and dueDateField hold the logic of the edit form's date field.
- validators.ts: dueDateSchema (40 characters at most, parseDueDate, a
Date out) for createTaskSchema and updateTaskSchema. It lives there,
not in dueDate.ts, so that zod stays out of the client bundle. The two
routes write the Date the schema gives; a PUT without dueDate leaves
the due date alone.
- TaskItem.tsx: the date field is prefilled with the local day (it was
the UTC day), and dueDate is only sent when the field changed, so the
time of a due date set on the phone is not rewritten to noon UTC.
- TaskForm.tsx, TaskItem.tsx: res.ok is read. On a refusal or a network
error the form stays open with its values and shows task.saveError.
- vitest.config.mts: hookTimeout of 30 s, for the PGlite boot of each
route test file.
test: reproduces #198 (web/src/app/api/tasks/route.test.ts, written
first: 5 of its 15 tests fail on the tree before the fix, 400 instead of
201 and 200).
Resolves#198
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>