mirror of
https://github.com/bitbaum/vitareba.git
synced 2026-12-04 05:57:39 +01:00
A patient uploads their own lab results; a clinician uploads a report onto a patient's record. Two forms, two skins — and two copies of the same upload: the size pre-check, the FormData, the `data.success` handling, the "Uploaded ✓" that fades after SAVED_FEEDBACK_MS, the reset of the file input, and a long `accept=".pdf,.png,…"` literal typed out twice. The pre-check is what made this worth doing. Refusing a file over DOCUMENT_MAX_FILE_SIZE_MB *before* sending it is what stops a patient on a phone pushing 40 MB up a mobile connection to be told no; a stale copy of that rule would be invisible until someone's upload hung. The server enforces the same limit — the client check is the courtesy, not the gate. lib/hooks/useDocumentUpload.ts now owns all of it, and `patientId` is the whole difference between the callers: the patient form omits it and the server files the document against the signed-in user, which is why a patient cannot upload onto someone else's record by editing a form. The portal's `router.refresh()` rides along as `onUploaded`, since only its list is server-rendered. DOCUMENT_ACCEPT moves to lib/config/portal.ts beside the other DOCUMENT_* constants — it is configuration, not hook state. Both forms keep their own markup, wording and placeholders; nothing rendered or requested changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8