# Phase 15 — Shared UX Primitives ## What exists From [Phase 14](./phase-14-plan.md): design tokens, `AppShell`, redesigned login. Still fragmented across views: - Status rendering via ad-hoc Tailwind classes / `.status-badge` in lists and forms - OCR assist via [`useOcrFieldConfidence.ts`](../../vigilcare-records-web/src/composables/useOcrFieldConfidence.ts) (thresholds 0.85 / 0.7) and banners in [`EntryForm.vue`](../../vigilcare-records-web/src/components/EntryForm.vue) / [`VerificationForm.vue`](../../vigilcare-records-web/src/components/VerificationForm.vue) - SoD: Verification subtitle shows truncated `enteredByUserId` only ([`VerificationView.vue`](../../vigilcare-records-web/src/views/VerificationView.vue)) - Toasts: [`ToastContainer.vue`](../../vigilcare-records-web/src/components/ToastContainer.vue) + [`useToast.ts`](../../vigilcare-records-web/src/composables/useToast.ts) - Empty/loading: inconsistent per view (`BatchList` loading text, etc.) Design reference: [design-doc.md](../designs/design-doc.md) §§9, 14 (OCR), 15 (SoD), 26–29, 31. ## What needs to be built Reusable components and composables that Phases 16–17 apply. Prefer shared primitives over one-off markup. Frontend-only threshold tweaks for OCR badges are allowed; no API changes. Do not start Phase 16 until these primitives exist and have basic tests. --- ## Step 1 — Status badge system Create e.g. [`StatusBadge.vue`](../../vigilcare-records-web/src/components/StatusBadge.vue): - Input: batch `status` string (`UPLOADED`, `IN_ENTRY`, `PENDING_VERIFICATION`, `AWAITING_CLINICAL_APPROVAL`, `VERIFIED`, `APPROVED`, `PROMOTED`, `REJECTED`, `CANCELLED`, …) - Output: label (humanized) + semantic color + optional icon - Must not rely on color alone (icon or text prefix) Wire into [`BatchList.vue`](../../vigilcare-records-web/src/components/BatchList.vue) and any header chips that show status. --- ## Step 2 — Empty, loading, error patterns Create small presentational components (names flexible): | Component | Behavior | |---|---| | `EmptyState.vue` | Operational copy (“No batches are waiting for verification.”) + optional CTA | | `SkeletonBlock.vue` / row skeletons | Prefer over full-page spinner (design-doc §27) | | `InlineError.vue` | What happened / what was preserved / Retry action (design-doc §28) | Apply to queue lists as the first consumer; other views adopt in Phase 16–17. --- ## Step 3 — Sticky workstation action bar Create e.g. [`WorkstationActionBar.vue`](../../vigilcare-records-web/src/components/WorkstationActionBar.vue): - Sticky bottom of the form/panel column - Slots: `left` (e.g. Reject), `center` (Save Draft), `primary` (Submit…), `right` (Next) - Uses Phase 14 primary/destructive button styles Not wired into Entry/Verification/Approval until Phase 16 — but component + Story/test fixture ready. --- ## Step 4 — OCR field badges Update [`useOcrFieldConfidence.ts`](../../vigilcare-records-web/src/composables/useOcrFieldConfidence.ts): - Expose numeric confidence and a badge label helper (`OCR 98%`) in addition to CSS class - Align thresholds with design-doc §14 (recommended): **95–100%** subtle green, **80–94%** amber, **<80%** strong warning (adjust from current 0.85 / 0.7) Update Entry/Verification forms to show compact badges beside fields when `ocrConfidence.fieldConfidences[path]` exists. Banner copy must say OCR is assistive, not authoritative (e.g. “Pre-filled by OCR — review against the scan”). **Out of this step:** click-to-highlight regions on the scan (no coordinates in API). --- ## Step 5 — Separation of Duties banner Create e.g. [`SeparationOfDutiesBanner.vue`](../../vigilcare-records-web/src/components/SeparationOfDutiesBanner.vue): Props: `enteredByUserId`, `enteredByUserName?`, `currentUserId`, `currentUserName?` - When IDs differ: restrained info banner — “Separation of Duties Enforced” + entered by / current verifier - When same: blocking message — “You cannot verify a batch you entered.” Emit/`disabled` flag for parent to disable Pass actions Use `enteredByUserId` from batch detail today; names optional until API/history provides them. Unit-test both states. --- ## Step 6 — Confirmation dialog pattern Create e.g. [`ConfirmDialog.vue`](../../vigilcare-records-web/src/components/ConfirmDialog.vue) for **meaningful** actions only: - Approve & Promote - Reject batch / return for rework - Cancel batch / delete unsubmitted upload (if used) Props: title, body, confirmLabel, variant (`primary` | `danger`). Do not use for harmless navigation. Approval copy must state promotion into live clinical tables (design-doc §16). --- ## Success criteria - [ ] `StatusBadge` covers all batch statuses used in the UI - [ ] Empty/skeleton/error components exist and are used at least on one queue list - [ ] `WorkstationActionBar` renders sticky with slots; documented for Phase 16 - [ ] OCR badges show percentage + threshold colors; banner is non-authoritative - [ ] SoD banner blocks same-user verify in UI (in addition to API 409) - [ ] Confirm dialog used for at least one destructive/irreversible path or ready with tests - [ ] `npm test` passes; new component tests under `src/__tests__/components/` ## Out of scope - Full Entry/Verification/Approval layout redesign (Phase 16) - Batch events audit panel (Phase 18) - Changing verification/approval API contracts ## Verification 1. `cd vigilcare-records-web && npm test` 2. Manual: open a batch with OCR confidence (OCR enabled env) — badges visible 3. Manual: as entry clerk who entered a batch, open verification for that batch — SoD banner + disabled Pass (if seed allows; else unit test covers) ## Gate Do not start [Phase 16](./phase-16-plan.md) until success criteria above are met.