From d3096cec59291a9c219324c65f760ee9bd547985 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 22:18:30 +0800 Subject: [PATCH 01/14] docs: design and OpenSpec change for visitor pages and shell refinements Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../2026-12-01-visual-followup-design.md | 49 +++++++++++++++ .../.openspec.yaml | 2 + .../refine-visitor-pages-and-shell/design.md | 27 +++++++++ .../proposal.md | 29 +++++++++ .../specs/admin-visual-design/spec.md | 60 +++++++++++++++++++ .../refine-visitor-pages-and-shell/tasks.md | 48 +++++++++++++++ 6 files changed, 215 insertions(+) create mode 100644 docs/superpowers/specs/2026-12-01-visual-followup-design.md create mode 100644 openspec/changes/refine-visitor-pages-and-shell/.openspec.yaml create mode 100644 openspec/changes/refine-visitor-pages-and-shell/design.md create mode 100644 openspec/changes/refine-visitor-pages-and-shell/proposal.md create mode 100644 openspec/changes/refine-visitor-pages-and-shell/specs/admin-visual-design/spec.md create mode 100644 openspec/changes/refine-visitor-pages-and-shell/tasks.md diff --git a/docs/superpowers/specs/2026-12-01-visual-followup-design.md b/docs/superpowers/specs/2026-12-01-visual-followup-design.md new file mode 100644 index 0000000..90ca6fa --- /dev/null +++ b/docs/superpowers/specs/2026-12-01-visual-followup-design.md @@ -0,0 +1,49 @@ +# Visual follow-up: visitor pages, My QR, login and shell fixes + +Date: 2026-12-01. Follows `2026-12-01-visual-foundation-design.md` (merged), on the same tokens and DESIGN.md. + +## Intent + +Visitors judge INS and CV by the page they get when they scan a QR at the booth. Today that page is a plain stack of inputs with a long consent text and the company name only as small grey text. Staff see small leftovers in the shell from the first visual change. Finish the revamp before go-live (2027-01-15) so every screen a visitor or staff member sees matches the new look. + +## Decisions + +- **Neutral look (owner, 2026-12-01).** Visitor pages use Co-Lite's tokens with the company name prominent. No per-company logo or colour. Per-company branding is a later change if INS or CV ask for it. +- **One way to build it (my call).** Restyle with the existing tokens and components. No new dependencies, no backend change, no copy change except the labels listed below. + +## Scope + +1. **Visitor pages `/r`, `/i`, `/c` (shared `RegistrationForm` and the check-in lookup)** + - The page sits on the slate ground. The form is a white card (border, `shadow-card`), full width at 360 px and max-width `md` from `sm`. + - Event header at the top of the card: company name as a small uppercase label in the accent colour, then the event name (h1), then dates and location on their own lines with calendar and map-pin icons. The pipe-separated line goes. + - Fields keep their order and rules. Mobile gets the hint "Mobile or email is required" under the mobile field (new key in the default messages). + - The privacy notice stays fully shown in both languages, as the spec requires. It becomes fine print: `text-xs`, muted foreground (contrast already tested ≥ 4.5), on a muted panel, with the language headings as small labels. + - The consent row aligns the checkbox to the first line of text and gets normal line height. + - The states (loading, inactive, too many, not yet, ended, thank you, welcome, checked in) render in the same card, with an icon (check, clock, alert) and a clear heading. The "register another person" button stays. + - Footer: "Powered by Containerverse Sdn. Bhd." small and muted under the card, the same component as the admin shell. +2. **My QR codes.** Each code is a card: event name as the card title, dates and location under it, the QR, then the buttons in one row that wraps on phones. "Switched off" stays as the warning badge in the card header. +3. **Login and reset password.** They already use the new look. Remove the stale comments that describe the old brown and gold panel. Reset password gets the same two-column layout as login, so the two match. +4. **Header label.** The trail no longer repeats the page title. On a top-level page (`/events`) it shows nothing. On a sub-page (`/events/new`, an event's page) it shows the parent as a link back ("Events"). +5. **Tables on phones.** When a table is wider than the screen, a soft fade on the right edge shows there is more to scroll. Pure CSS (background-attachment scroll shadows) on the shared table container, so every table gets it. The fade goes away at the end of the scroll. +6. **Sidebar groups.** The flat list of 11 items gets one quiet divider with a small muted label "Administration" before Users, Roles, Emails, Login security, Audit log and Companies. Work items (Dashboard, Events, Event leads, Interests, Leads) stay above. The collapsed rail shows the divider without the label. The grouping is a fixed list of module names in the portal, since the menu tree from the server is flat. + +## Non-goals + +- Per-company logo or colour, or any change to Companies. +- New fields, flows or copy on the visitor pages beyond the hint above. +- Any change to how the visitor pages follow the light or dark theme. They keep today's behaviour. + +## Anti-goals + +- Hiding or shortening the privacy notice. It must stay readable in both languages. +- Anything that slows the visitor form on a phone (no new fonts, images or libraries). + +## Verification + +- Vitest, typecheck and lint, with the exit-code check. +- Playwright at 1280 and 360 px: `/r`, `/i` and `/c` in each state, My QR, login, reset password, `/events` and `/events/new` header, a wide table at 360 px, and the sidebar in full and rail mode. +- The token and contrast tests stay green. + +## Left to the builder + +Icon choice within lucide, exact spacing, and the fade width. diff --git a/openspec/changes/refine-visitor-pages-and-shell/.openspec.yaml b/openspec/changes/refine-visitor-pages-and-shell/.openspec.yaml new file mode 100644 index 0000000..785b150 --- /dev/null +++ b/openspec/changes/refine-visitor-pages-and-shell/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-12-01 diff --git a/openspec/changes/refine-visitor-pages-and-shell/design.md b/openspec/changes/refine-visitor-pages-and-shell/design.md new file mode 100644 index 0000000..6e82394 --- /dev/null +++ b/openspec/changes/refine-visitor-pages-and-shell/design.md @@ -0,0 +1,27 @@ +## Context + +The product design is in `docs/superpowers/specs/2026-12-01-visual-followup-design.md`. It builds on the tokens, components and DESIGN.md from `add-visual-foundation`. The owner chose the neutral look. + +## Goals / Non-Goals + +**Goals:** a visitor-page card layout, My QR cards, reset password matching login, the header trail, the table scroll cue and the sidebar sections. + +**Non-Goals:** per-company branding, backend changes, new dependencies, changing the theme behaviour of the visitor pages. + +## Decisions + +- **One shared visitor card.** Add a `VisitorCard` in `app/components/registration/` that renders the ground, the card, the event header and the footer. `/r`, `/i` and `/c` wrap every state in it. `RegistrationForm` drops its own header and takes the card's. The states render a small `VisitorState` (icon, heading, optional text, optional action) inside the card. Alternative rejected: styling each page separately, which would let the three pages drift. +- **Fine-print notice.** Keep the `whitespace-pre-line` text and set it as `text-xs text-muted-foreground` on `bg-muted`. The muted foreground is already contrast-tested at ≥ 4.5 on card and muted. +- **Scroll cue in CSS.** Use the background-attachment `local` versus `scroll` gradient technique on the `table-container` in `ui/table.tsx`, with colours from `--card`, as a utility in `globals.css`. It needs no JavaScript and no resize observers. Sticky header cells keep their opaque background. +- **Trail.** In `Breadcrumbs`, return nothing when the pathname equals the leaf's own URL. Otherwise render the leaf as a link (the parent of the current sub-page), as it does now. +- **Sidebar sections.** Keep a fixed `ADMIN_MODULES` list of module names (`BO_USERS`, `BO_ROLES`, `BO_EMAILS`, `BO_LOGIN_SECURITY`, `BO_AUDIT_LOG`, `BO_COMPANIES`; Companies is added by `useAclSidebar` for super admins, the rest come from the menu tree) in `aclSidebar.ts`. Split the top-level links into work and admin lists when rendering. The server menu tree is flat, so the grouping lives in the portal. A module not in the list stays with the work items. +- **Reset password** reuses the login page's two-column frame. Extract it to a small `AuthFrame` only if both pages need the same markup; otherwise copy the wrapper classes. + +## Risks / Trade-offs + +- The fixed admin-module list goes stale when a new admin module is added. It then falls into the work section, which is visible and harmless. Mark it with a `ponytail:` comment. +- The CSS scroll shadows need opaque table cells, or the fade draws under them. Row hover uses a token background, so check it at 360 px. + +## Migration Plan + +Portal deploy only. Roll back by redeploying the previous portal image. diff --git a/openspec/changes/refine-visitor-pages-and-shell/proposal.md b/openspec/changes/refine-visitor-pages-and-shell/proposal.md new file mode 100644 index 0000000..a1ea77f --- /dev/null +++ b/openspec/changes/refine-visitor-pages-and-shell/proposal.md @@ -0,0 +1,29 @@ +## Why + +Visitors judge INS and CV by the page they get when they scan a booth QR. Today that page is a plain stack of inputs with a long consent text, and the company name appears only as small grey text. Staff still see leftovers in the shell from `add-visual-foundation`: the header label repeats the page title, phone tables cut off with no scroll cue, and the sidebar is one flat list of 11 items. This change finishes the revamp before go-live. + +## What Changes + +- The visitor pages `/r`, `/i` and `/c` get a card layout with an event header (company label, event name, dates and location). The privacy notice becomes fine print and stays complete in both languages. The states get an icon and a heading. A "Mobile or email is required" hint is added. +- My QR codes shows each code as a card. +- Reset password matches the login layout. The stale login comments go. +- The header trail stops repeating the page title. On a sub-page it shows the parent as a link back. +- Wide tables show a fade on the edge that can still scroll. +- The sidebar gets an "Administration" divider before the admin items. +- The look is neutral: Co-Lite tokens, with no per-company logo or colour (owner decision, 2026-12-01). + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `admin-visual-design`: adds requirements for the visitor page look, the header trail, the table scroll cue and the sidebar sections. + +## Impact + +- Portal only (`solvway-admin-portal`): `RegistrationForm`, the `/r`, `/i` and `/c` pages, `my-qr`, `reset-password`, `login` (comments only), `Breadcrumbs`, the `ui/table` container, `Sidebar`, `globals.css`, and the i18n messages (one new key). +- No backend, API, SQL or dependency change. +- Product design: `docs/superpowers/specs/2026-12-01-visual-followup-design.md`. diff --git a/openspec/changes/refine-visitor-pages-and-shell/specs/admin-visual-design/spec.md b/openspec/changes/refine-visitor-pages-and-shell/specs/admin-visual-design/spec.md new file mode 100644 index 0000000..09931da --- /dev/null +++ b/openspec/changes/refine-visitor-pages-and-shell/specs/admin-visual-design/spec.md @@ -0,0 +1,60 @@ +## ADDED Requirements + +### Requirement: Visitor Page Look + +The public visitor pages (registration, invitation and check-in) SHALL show their content in one card on the page ground. The card SHALL be headed by the company name as a small label, the event name as the main heading, and the event dates and location. The pages SHALL use only the portal's theme tokens and SHALL NOT show a per-company logo or colour. The privacy notice SHALL be shown in full in English and Bahasa Malaysia as smaller, muted text that keeps at least 4.5:1 contrast. + +#### Scenario: Visitor opens a registration code + +- **WHEN** a visitor opens the registration page of an INS event +- **THEN** the card shows "INS" as a label above the event name, then the event dates and location +- **AND** the full privacy notice appears in both languages above the consent box + +#### Scenario: Visitor needs a contact + +- **WHEN** a visitor sees the mobile field on the registration form +- **THEN** a hint under it says that a mobile number or an email is required + +#### Scenario: Visitor reaches an end state + +- **WHEN** a visitor's registration is accepted, or the code is inactive, or check-in has not opened yet +- **THEN** the same card shows an icon and a heading for that state + +### Requirement: Header Trail Without Repeats + +The admin header SHALL NOT repeat the page title. On a page reached directly from the sidebar it SHALL show no trail. On a page below one, it SHALL show the parent page as a link back. + +#### Scenario: Top-level page + +- **WHEN** an admin opens the Events list +- **THEN** the header shows no trail text + +#### Scenario: Sub-page + +- **WHEN** an admin opens the new event page +- **THEN** the header shows "Events" as a link to the Events list + +### Requirement: Table Scroll Cue + +A table wider than its container SHALL show a fade on each edge where more columns can be scrolled into view. The fade SHALL disappear at that end of the scroll. + +#### Scenario: Users list on a phone + +- **WHEN** an admin opens the Users list at 360 px wide +- **THEN** a fade shows on the right edge of the table +- **AND** after scrolling to the last column the right fade is gone + +### Requirement: Sidebar Sections + +The sidebar SHALL list the work pages first, then an "Administration" section for Users, Roles, Emails, Login security, Audit log and Companies. The section SHALL be marked by a divider and a small muted label, and only the divider SHALL show in the collapsed rail. A section with no item the admin may open SHALL NOT show. + +#### Scenario: Super admin sidebar + +- **WHEN** a super admin opens the portal +- **THEN** Dashboard, Events, Event leads, Interests and Leads are listed above the "Administration" label +- **AND** Users, Roles, Emails, Login security, Audit log and Companies are listed below it + +#### Scenario: Staff without admin pages + +- **WHEN** a staff user who can open only Events and Event leads opens the portal +- **THEN** the sidebar shows no "Administration" label diff --git a/openspec/changes/refine-visitor-pages-and-shell/tasks.md b/openspec/changes/refine-visitor-pages-and-shell/tasks.md new file mode 100644 index 0000000..7f8063d --- /dev/null +++ b/openspec/changes/refine-visitor-pages-and-shell/tasks.md @@ -0,0 +1,48 @@ +# Tasks: refine-visitor-pages-and-shell + +Design: `design.md` and `docs/superpowers/specs/2026-12-01-visual-followup-design.md`. Portal only. Every task is TDD, followed by the review gate. Tasks run serially in this order, because several of them touch `globals.css` and the i18n messages. + +Verify for every task: `cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint`. Check the vitest exit code: an unhandled error fails the run even when every test passes. + +## 1. Shell + +- [ ] 1.1 Header trail without repeats: `Breadcrumbs` shows nothing on a page whose URL is the matched leaf's own URL, and shows the leaf as a link on a sub-page. + - Depends on: none + - Scope: `solvway-admin-portal/app/components/app/Breadcrumbs*` +- [ ] 1.2 Sidebar sections: an `ADMIN_MODULES` list in `aclSidebar.ts`, the work and Administration split in `Sidebar` (full sidebar and drawer: divider and label; rail: divider only; no section when it has no items), and the "Administration" label in `defaultMessages.ts`. + - Depends on: 1.1 + - Scope: `solvway-admin-portal/app/lib/aclSidebar*`, `solvway-admin-portal/app/components/app/Sidebar*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts` +- [ ] 1.3 Table scroll cue: a scroll-shadow utility in `globals.css` applied to the `table-container`, with colours from tokens only (the design-tokens test stays green). + - Depends on: 1.2 + - Scope: `solvway-admin-portal/app/components/ui/table*`, `solvway-admin-portal/app/globals.css`, `solvway-admin-portal/app/globals.test.ts` + +## 2. Visitor pages + +- [ ] 2.1 `VisitorCard` (ground, card, event header with the company label, the dates and location with icons, footer) and `VisitorState` (icon, heading, text, action). `RegistrationForm` drops its header, adds the "Mobile or email is required" hint (new key in `defaultMessages.ts`), sets the notice as fine print, and aligns the consent row. + - Depends on: 1.3 + - Scope: `solvway-admin-portal/app/components/registration/**` except `QrCodeItem*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts` +- [ ] 2.2 `/r`, `/i` and `/c` render every state inside `VisitorCard`, with `VisitorState` for loading, inactive, error, too many, not yet, ended, thank you, welcome and checked in. Existing behaviour and text stay the same. + - Depends on: 2.1 + - Scope: `solvway-admin-portal/app/r/**`, `solvway-admin-portal/app/i/**`, `solvway-admin-portal/app/c/**` + +## 3. Staff screens + +- [ ] 3.1 My QR codes as cards: the event name as the title, dates and location, the switched-off badge in the card header, the QR and a wrapping button row. + - Depends on: 2.2 + - Scope: `solvway-admin-portal/app/my-qr/**`, `solvway-admin-portal/app/components/registration/QrCodeItem*` +- [ ] 3.2 Reset password uses the login page's two-column frame. Remove the stale brown and gold comments in login. + - Depends on: 3.1 + - Scope: `solvway-admin-portal/app/reset-password/**`, `solvway-admin-portal/app/login/**` + +## 4. Release check + +- [ ] 4.1 Playwright at 1280 and 360 px: + - `/r`, `/i` and `/c` in each reachable state; + - My QR, using a throwaway staff user that is reverted afterwards; + - login and reset password; + - the `/events` and `/events/new` header; + - the Users table at 360 px, before and after scrolling; + - the sidebar, full and rail. + + Run the full portal verify. Record the result here. + - Depends on: 3.2 From a9e40280ee0f447fab4bdc97d2e154e35a693dd6 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 22:33:58 +0800 Subject: [PATCH 02/14] feat: header trail no longer repeats the page title Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../refine-visitor-pages-and-shell/tasks.md | 2 +- .../app/components/app/Breadcrumbs.test.tsx | 20 ++++----- .../components/app/Breadcrumbs.trail.test.tsx | 44 +++++++++++++++++++ .../app/components/app/Breadcrumbs.tsx | 12 ++--- .../app/components/app/Header.test.tsx | 19 ++++++-- 5 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 solvway-admin-portal/app/components/app/Breadcrumbs.trail.test.tsx diff --git a/openspec/changes/refine-visitor-pages-and-shell/tasks.md b/openspec/changes/refine-visitor-pages-and-shell/tasks.md index 7f8063d..8a77343 100644 --- a/openspec/changes/refine-visitor-pages-and-shell/tasks.md +++ b/openspec/changes/refine-visitor-pages-and-shell/tasks.md @@ -6,7 +6,7 @@ Verify for every task: `cd solvway-admin-portal && npx vitest run; echo VITEST=$ ## 1. Shell -- [ ] 1.1 Header trail without repeats: `Breadcrumbs` shows nothing on a page whose URL is the matched leaf's own URL, and shows the leaf as a link on a sub-page. +- [x] 1.1 Header trail without repeats: `Breadcrumbs` shows nothing on a page whose URL is the matched leaf's own URL, and shows the leaf as a link on a sub-page. - Depends on: none - Scope: `solvway-admin-portal/app/components/app/Breadcrumbs*` - [ ] 1.2 Sidebar sections: an `ADMIN_MODULES` list in `aclSidebar.ts`, the work and Administration split in `Sidebar` (full sidebar and drawer: divider and label; rail: divider only; no section when it has no items), and the "Administration" label in `defaultMessages.ts`. diff --git a/solvway-admin-portal/app/components/app/Breadcrumbs.test.tsx b/solvway-admin-portal/app/components/app/Breadcrumbs.test.tsx index d72e42c..b553c73 100644 --- a/solvway-admin-portal/app/components/app/Breadcrumbs.test.tsx +++ b/solvway-admin-portal/app/components/app/Breadcrumbs.test.tsx @@ -4,7 +4,8 @@ import type { SidebarLink } from "@/app/lib/aclSidebar"; import { MessagesProvider } from "@/app/lib/i18n/MessagesProvider"; // fix-admin-shell-foundation: header breadcrumbs derived from the sidebar tree. Group names are -// text; the module crumb is the current page on its own url and a link back to it on a sub-page. +// text; on the module's own url there is no trail (refine-visitor-pages-and-shell), and on a +// sub-page the module crumb is a link back to it. const state = vi.hoisted(() => ({ links: [] as SidebarLink[], pathname: "/" })); @@ -47,15 +48,14 @@ describe("Breadcrumbs", () => { expect(screen.queryByRole("link", { name: "Sales & Orders" })).toBeNull(); }); - it("marks the list page itself as the current page, not a link", () => { + // The page title already names a list page, so its own trail is not repeated (refine-visitor-pages-and-shell). + it("shows nothing on the list page itself", () => { state.links = LINKS; state.pathname = "/orders/web"; - render(); + const { container } = render(); - expect(screen.queryByRole("link", { name: "Sales Listing" })).toBeNull(); - expect(screen.getByText("Sales Listing")).toHaveAttribute("aria-current", "page"); - expect(screen.getByRole("navigation", { name: "breadcrumb" })).toHaveTextContent("Sales & Orders"); + expect(container).toBeEmptyDOMElement(); }); it("shows nothing on the dashboard", () => { @@ -78,7 +78,7 @@ describe("Breadcrumbs", () => { it("uses the same translated labels as the sidebar", () => { state.links = [{ name: "BO_USERS", url: "", children: [{ name: "BO_MESSAGES", url: "/messages", children: [] }] }]; - state.pathname = "/messages"; + state.pathname = "/messages/7"; render( @@ -86,7 +86,7 @@ describe("Breadcrumbs", () => { , ); - expect(screen.getByText("消息")).toHaveAttribute("aria-current", "page"); + expect(screen.getByRole("link", { name: "消息" })).toHaveAttribute("href", "/messages"); expect(screen.getByRole("navigation", { name: "breadcrumb" })).toHaveTextContent("Users"); }); }); @@ -97,11 +97,11 @@ describe("Breadcrumbs pick the most specific match", () => { { name: "Event", url: "", children: [{ name: "Event POS", url: "/pos", children: [] }] }, { name: "Sales", url: "", children: [{ name: "Branch Counter", url: "/pos/counter", children: [] }] }, ]; - state.pathname = "/pos/counter"; + state.pathname = "/pos/counter/5"; render(); - expect(screen.getByText("Branch Counter")).toHaveAttribute("aria-current", "page"); + expect(screen.getByRole("link", { name: "Branch Counter" })).toHaveAttribute("href", "/pos/counter"); expect(screen.getByRole("navigation", { name: "breadcrumb" })).not.toHaveTextContent("Event"); }); diff --git a/solvway-admin-portal/app/components/app/Breadcrumbs.trail.test.tsx b/solvway-admin-portal/app/components/app/Breadcrumbs.trail.test.tsx new file mode 100644 index 0000000..72b241d --- /dev/null +++ b/solvway-admin-portal/app/components/app/Breadcrumbs.trail.test.tsx @@ -0,0 +1,44 @@ +import { render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import type { SidebarLink } from "@/app/lib/aclSidebar"; + +// refine-visitor-pages-and-shell: no trail on a leaf's own page (the page title says it already). + +const state = vi.hoisted(() => ({ links: [] as SidebarLink[], pathname: "/" })); + +vi.mock("next/navigation", () => ({ usePathname: () => state.pathname })); +vi.mock("@/app/lib/useAclSidebar", () => ({ useAclSidebar: () => state.links })); + +import Breadcrumbs from "./Breadcrumbs"; + +const LINKS: SidebarLink[] = [ + { + name: "Event", + url: "", + children: [{ name: "Events", url: "/events", children: [] }], + }, +]; + +afterEach(() => { + state.pathname = "/"; +}); + +describe("Breadcrumbs trail without repeats", () => { + it("shows no trail on the Events list", () => { + state.links = LINKS; + state.pathname = "/events"; + + const { container } = render(); + + expect(container).toBeEmptyDOMElement(); + }); + + it("shows Events as a link to the list on the new event page", () => { + state.links = LINKS; + state.pathname = "/events/new"; + + render(); + + expect(screen.getByRole("link", { name: "Events" })).toHaveAttribute("href", "/events"); + }); +}); diff --git a/solvway-admin-portal/app/components/app/Breadcrumbs.tsx b/solvway-admin-portal/app/components/app/Breadcrumbs.tsx index 47c395a..de03d94 100644 --- a/solvway-admin-portal/app/components/app/Breadcrumbs.tsx +++ b/solvway-admin-portal/app/components/app/Breadcrumbs.tsx @@ -11,7 +11,6 @@ import { BreadcrumbItem, BreadcrumbLink, BreadcrumbList, - BreadcrumbPage, BreadcrumbSeparator, } from "@/app/components/ui/breadcrumb"; @@ -24,6 +23,7 @@ export default function Breadcrumbs() { if (!leaf || leaf.url === "/") return null; const url = matchedUrl(leaf, pathname)!; + if (pathname === url) return null; return ( @@ -35,13 +35,9 @@ export default function Breadcrumbs() { ))} - {pathname === url ? ( - {t(leaf.name)} - ) : ( - - {t(leaf.name)} - - )} + + {t(leaf.name)} + diff --git a/solvway-admin-portal/app/components/app/Header.test.tsx b/solvway-admin-portal/app/components/app/Header.test.tsx index e714083..0b7dcfb 100644 --- a/solvway-admin-portal/app/components/app/Header.test.tsx +++ b/solvway-admin-portal/app/components/app/Header.test.tsx @@ -2,10 +2,10 @@ import { render, screen, waitFor, within } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { describe, it, expect, vi, beforeEach } from "vitest"; -const nav = vi.hoisted(() => ({ replace: vi.fn(), refresh: vi.fn() })); +const nav = vi.hoisted(() => ({ replace: vi.fn(), refresh: vi.fn(), pathname: "/orders/web" })); vi.mock("next/navigation", () => ({ useRouter: () => ({ replace: nav.replace, refresh: nav.refresh }), - usePathname: () => "/orders/web", + usePathname: () => nav.pathname, })); // The mobile drawer (fix-admin-shell-foundation) renders the same aclMenu-derived tree as the sidebar. @@ -144,8 +144,19 @@ describe("Header mobile navigation", () => { await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull()); }); - it("shows breadcrumbs for the current page", () => { + // On a list page the trail is empty: the page title already names it (refine-visitor-pages-and-shell). + it("shows no breadcrumbs on a list page", () => { render(
); - expect(screen.getByRole("navigation", { name: "breadcrumb" })).toHaveTextContent("Sales Listing"); + expect(screen.queryByRole("navigation", { name: "breadcrumb" })).toBeNull(); + }); + + it("shows the list page as a link back on a sub-page", () => { + nav.pathname = "/orders/web/1"; + try { + render(
); + expect(screen.getByRole("link", { name: "Sales Listing" })).toHaveAttribute("href", "/orders/web"); + } finally { + nav.pathname = "/orders/web"; + } }); }); From d4ae94fcc94494dfa36b83469b320314798befa0 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 22:38:22 +0800 Subject: [PATCH 03/14] feat: reset password shares the login frame Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../app/components/app/AuthFrame.tsx | 67 ++++++ solvway-admin-portal/app/login/page.tsx | 196 +++++++----------- .../app/reset-password/page.frame.test.tsx | 18 ++ .../app/reset-password/page.tsx | 84 ++++---- 4 files changed, 195 insertions(+), 170 deletions(-) create mode 100644 solvway-admin-portal/app/components/app/AuthFrame.tsx create mode 100644 solvway-admin-portal/app/reset-password/page.frame.test.tsx diff --git a/solvway-admin-portal/app/components/app/AuthFrame.tsx b/solvway-admin-portal/app/components/app/AuthFrame.tsx new file mode 100644 index 0000000..048644b --- /dev/null +++ b/solvway-admin-portal/app/components/app/AuthFrame.tsx @@ -0,0 +1,67 @@ +"use client"; + +import type { ReactNode } from "react"; +import { CalendarDays, ListChecks, UserPlus } from "lucide-react"; +import { useT } from "@/app/lib/i18n/MessagesProvider"; +import PoweredBy from "@/app/components/app/PoweredBy"; + +/** What the back office is for, on the brand panel. */ +const PANEL_POINTS = [ + { icon: CalendarDays, code: "BackOfficePanelEvents" }, + { icon: UserPlus, code: "BackOfficePanelLeads" }, + { icon: ListChecks, code: "BackOfficePanelFollowUps" }, +] as const; + +// Two-column frame shared by the signed-out pages (login, forced password change): an accent panel +// with the giraffe-spot coat on the left from lg, the page's own content on the right. Below lg the +// panel folds into a compact brand row above the content. +export default function AuthFrame({ children }: { children: ReactNode }) { + const t = useT(); + return ( +
+ + +
+
+ {/* Below lg a short brand band stands in for the panel: same accent ground and giraffe-spot coat. */} +
+
+ + {children} +
+ +
+
+ ); +} diff --git a/solvway-admin-portal/app/login/page.tsx b/solvway-admin-portal/app/login/page.tsx index 235e885..6ade404 100644 --- a/solvway-admin-portal/app/login/page.tsx +++ b/solvway-admin-portal/app/login/page.tsx @@ -1,7 +1,7 @@ "use client"; import { useState, useSyncExternalStore } from "react"; -import { CalendarDays, Eye, EyeOff, ListChecks, Loader2, UserPlus } from "lucide-react"; +import { Eye, EyeOff, Loader2 } from "lucide-react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { Button } from "@/app/components/ui/button"; @@ -11,20 +11,13 @@ import { ErrorState } from "@/app/components/ui/states"; import { ApiError, apiPost } from "@/app/lib/clientApi"; import { useAdminAuth } from "@/app/lib/AdminAuthContext"; import { useT } from "@/app/lib/i18n/MessagesProvider"; -import PoweredBy from "@/app/components/app/PoweredBy"; +import AuthFrame from "@/app/components/app/AuthFrame"; import { signedInElsewhere } from "@/app/lib/signedInElsewhere"; import { safeReturnTo } from "@/app/lib/returnTo"; /** The marker is read once per render; nothing in the page changes it. */ const noSubscription = () => () => {}; -/** What the back office is for, on the brand panel. */ -const PANEL_POINTS = [ - { icon: CalendarDays, code: "BackOfficePanelEvents" }, - { icon: UserPlus, code: "BackOfficePanelLeads" }, - { icon: ListChecks, code: "BackOfficePanelFollowUps" }, -] as const; - // Ported from src/legacy-pages/login/LoginPage.tsx. The hardcoded // services/auth.ts credential check and localStorage session are gone (spec: // "The hardcoded SPA auth is gone"); submit now calls the same-origin @@ -74,127 +67,80 @@ export default function LoginPage() { } return ( - // Brand split (feedback 2026-10-23, "make it impactful"): a brand-gold panel with the brown giraffe - // coat and the logo on the left from lg, the form on the cream page on the right. Below lg the - // panel folds into a compact brand row above the form. -
- - -
-
- {/* Below lg a short brand band stands in for the panel: same brown, coat and logo. */} -
-
-
+ + + {t("ForgotLink")} + + + + + ); } diff --git a/solvway-admin-portal/app/reset-password/page.frame.test.tsx b/solvway-admin-portal/app/reset-password/page.frame.test.tsx new file mode 100644 index 0000000..c1bc196 --- /dev/null +++ b/solvway-admin-portal/app/reset-password/page.frame.test.tsx @@ -0,0 +1,18 @@ +import { render, screen } from "@testing-library/react"; +import { describe, it, expect, vi } from "vitest"; + +vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn() }) })); +vi.mock("@/app/lib/clientApi", () => ({ apiPost: vi.fn(), ApiError: class ApiError extends Error {} })); +vi.mock("@/app/lib/AdminAuthContext", () => ({ useAdminAuth: () => ({ refresh: vi.fn() }) })); + +import ResetPasswordPage from "./page"; + +describe("ResetPasswordPage frame", () => { + it("uses the login two-column frame", () => { + const { container } = render(); + expect(screen.getByText("Everything behind Co-Lite, in one place.")).toBeInTheDocument(); + expect(container.querySelector(".giraffe-spots")).not.toBeNull(); + expect(screen.getByRole("link", { name: "Containerverse Sdn. Bhd." })).toBeInTheDocument(); + expect(screen.getByRole("heading", { name: "Set your password" })).toBeInTheDocument(); + }); +}); diff --git a/solvway-admin-portal/app/reset-password/page.tsx b/solvway-admin-portal/app/reset-password/page.tsx index 74a4999..a369c07 100644 --- a/solvway-admin-portal/app/reset-password/page.tsx +++ b/solvway-admin-portal/app/reset-password/page.tsx @@ -4,14 +4,13 @@ import { useState } from "react"; import { Loader2 } from "lucide-react"; import { useRouter } from "next/navigation"; import { Button } from "@/app/components/ui/button"; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/app/components/ui/card"; import { Input } from "@/app/components/ui/input"; import { Label } from "@/app/components/ui/label"; import { ErrorState } from "@/app/components/ui/states"; import { apiPost } from "@/app/lib/clientApi"; import { useAdminAuth } from "@/app/lib/AdminAuthContext"; import { useT } from "@/app/lib/i18n/MessagesProvider"; -import PoweredBy from "@/app/components/app/PoweredBy"; +import AuthFrame from "@/app/components/app/AuthFrame"; // First sign-in: login answered resetPasswordRequired (the account is still on the temporary // password an admin set), so the user must choose their own before reaching the portal. @@ -48,49 +47,44 @@ export default function ResetPasswordPage() { } return ( -
- - - {t("ResetTitle")} - {t("ResetChooseIntro")} - - - {error && } -
-
- - setNewPassword(e.target.value)} - disabled={submitting} - aria-describedby="newPasswordRules" - /> -

{t("AdminPasswordHint")}

-
-
- - setConfirmPassword(e.target.value)} - disabled={submitting} - /> -
- -
-
-
-
- + +
+

{t("ResetTitle")}

+

{t("ResetChooseIntro")}

-
+ {error && } +
+
+ + setNewPassword(e.target.value)} + disabled={submitting} + aria-describedby="newPasswordRules" + className="h-11 bg-card" + /> +

{t("AdminPasswordHint")}

+
+
+ + setConfirmPassword(e.target.value)} + disabled={submitting} + className="h-11 bg-card" + /> +
+ +
+ ); } From 5ac248cee76582e65f818803995654c4f611c46c Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 22:48:00 +0800 Subject: [PATCH 04/14] feat: sidebar lists admin pages under an Administration divider Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../refine-visitor-pages-and-shell/tasks.md | 4 +- .../components/app/Sidebar.sections.test.tsx | 54 +++++++++++++++++++ .../app/components/app/Sidebar.tsx | 40 ++++++++++---- solvway-admin-portal/app/lib/aclSidebar.ts | 3 ++ .../app/lib/i18n/defaultMessages.ts | 1 + 5 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 solvway-admin-portal/app/components/app/Sidebar.sections.test.tsx diff --git a/openspec/changes/refine-visitor-pages-and-shell/tasks.md b/openspec/changes/refine-visitor-pages-and-shell/tasks.md index 8a77343..30b51d2 100644 --- a/openspec/changes/refine-visitor-pages-and-shell/tasks.md +++ b/openspec/changes/refine-visitor-pages-and-shell/tasks.md @@ -9,7 +9,7 @@ Verify for every task: `cd solvway-admin-portal && npx vitest run; echo VITEST=$ - [x] 1.1 Header trail without repeats: `Breadcrumbs` shows nothing on a page whose URL is the matched leaf's own URL, and shows the leaf as a link on a sub-page. - Depends on: none - Scope: `solvway-admin-portal/app/components/app/Breadcrumbs*` -- [ ] 1.2 Sidebar sections: an `ADMIN_MODULES` list in `aclSidebar.ts`, the work and Administration split in `Sidebar` (full sidebar and drawer: divider and label; rail: divider only; no section when it has no items), and the "Administration" label in `defaultMessages.ts`. +- [x] 1.2 Sidebar sections: an `ADMIN_MODULES` list in `aclSidebar.ts`, the work and Administration split in `Sidebar` (full sidebar and drawer: divider and label; rail: divider only; no section when it has no items), and the "Administration" label in `defaultMessages.ts`. - Depends on: 1.1 - Scope: `solvway-admin-portal/app/lib/aclSidebar*`, `solvway-admin-portal/app/components/app/Sidebar*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts` - [ ] 1.3 Table scroll cue: a scroll-shadow utility in `globals.css` applied to the `table-container`, with colours from tokens only (the design-tokens test stays green). @@ -30,7 +30,7 @@ Verify for every task: `cd solvway-admin-portal && npx vitest run; echo VITEST=$ - [ ] 3.1 My QR codes as cards: the event name as the title, dates and location, the switched-off badge in the card header, the QR and a wrapping button row. - Depends on: 2.2 - Scope: `solvway-admin-portal/app/my-qr/**`, `solvway-admin-portal/app/components/registration/QrCodeItem*` -- [ ] 3.2 Reset password uses the login page's two-column frame. Remove the stale brown and gold comments in login. +- [x] 3.2 Reset password uses the login page's two-column frame. Remove the stale brown and gold comments in login. - Depends on: 3.1 - Scope: `solvway-admin-portal/app/reset-password/**`, `solvway-admin-portal/app/login/**` diff --git a/solvway-admin-portal/app/components/app/Sidebar.sections.test.tsx b/solvway-admin-portal/app/components/app/Sidebar.sections.test.tsx new file mode 100644 index 0000000..329a28d --- /dev/null +++ b/solvway-admin-portal/app/components/app/Sidebar.sections.test.tsx @@ -0,0 +1,54 @@ +import { render, screen, within } from "@testing-library/react"; +import { describe, it, expect, vi } from "vitest"; +import type { SidebarLink } from "@/app/lib/aclSidebar"; + +const state = vi.hoisted(() => ({ links: [] as SidebarLink[] })); + +vi.mock("next/navigation", () => ({ usePathname: () => "/" })); +vi.mock("@/app/lib/useAclSidebar", () => ({ useAclSidebar: () => state.links })); + +import { SidebarNav } from "./Sidebar"; + +const link = (name: string): SidebarLink => ({ name, url: `/${name}`, children: [] }); +const names = (...n: string[]) => n.map(link); + +const ALL = names( + "BO_DASHBOARD", "BO_EVENTS", "BO_EVENT_LEADS", "BO_INTERESTS", "BO_LEADS", + "BO_USERS", "BO_ROLES", "BO_EMAILS", "BO_LOGIN_SECURITY", "BO_AUDIT_LOG", "BO_COMPANIES", +); + +describe("Sidebar sections", () => { + it("lists work pages above the Administration label and admin pages below it", () => { + state.links = ALL; + render(); + const label = screen.getByText("Administration"); + const before = (el: HTMLElement) => label.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING; + const after = (el: HTMLElement) => label.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING; + const hrefs = (re: RegExp) => screen.getAllByRole("link").filter((a) => re.test(a.getAttribute("href") ?? "")); + for (const a of hrefs(/DASHBOARD|EVENTS|EVENT_LEADS|INTERESTS|LEADS/)) expect(before(a)).toBeTruthy(); + for (const a of hrefs(/USERS|ROLES|EMAILS|LOGIN_SECURITY|AUDIT_LOG|COMPANIES/)) expect(after(a)).toBeTruthy(); + expect(screen.getAllByRole("link")).toHaveLength(11); + }); + + it("names the admin list by the label", () => { + state.links = ALL; + render(); + const list = screen.getByRole("list", { name: "Administration" }); + expect(within(list).getAllByRole("link")).toHaveLength(6); + }); + + it("shows no Administration label or divider when no admin module is available", () => { + state.links = names("BO_EVENTS", "BO_EVENT_LEADS"); + const { container } = render(); + expect(screen.queryByText("Administration")).toBeNull(); + expect(container.querySelector("[data-slot='sidebar-divider']")).toBeNull(); + }); + + it("shows only the divider in the collapsed rail", () => { + state.links = ALL; + const { container } = render(); + expect(screen.queryByText("Administration")).toBeNull(); + expect(container.querySelector("[data-slot='sidebar-divider']")).not.toBeNull(); + expect(screen.getAllByRole("link")).toHaveLength(11); + }); +}); diff --git a/solvway-admin-portal/app/components/app/Sidebar.tsx b/solvway-admin-portal/app/components/app/Sidebar.tsx index a809ad4..117f993 100644 --- a/solvway-admin-portal/app/components/app/Sidebar.tsx +++ b/solvway-admin-portal/app/components/app/Sidebar.tsx @@ -5,7 +5,7 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; import { ChevronDown, PanelLeftClose, PanelLeftOpen } from "lucide-react"; import { useAclSidebar } from "@/app/lib/useAclSidebar"; -import { currentTrail, type SidebarLink } from "@/app/lib/aclSidebar"; +import { ADMIN_MODULES, currentTrail, type SidebarLink } from "@/app/lib/aclSidebar"; import { useT } from "@/app/lib/i18n/MessagesProvider"; import { iconFor } from "./icon-map"; import { cn } from "@/app/lib/utils"; @@ -216,18 +216,38 @@ export function SidebarNav({ onNavigate, collapsed = false }: { onNavigate?: () const t = useT(); const links = useAclSidebar(); const trail = currentTrail(links, usePathname()); + const adminLabelId = useId(); + + const work = links.filter((l) => !ADMIN_MODULES.includes(l.name)); + const admin = links.filter((l) => ADMIN_MODULES.includes(l.name)); + const render = (link: SidebarLink) => + collapsed ? ( + + ) : ( + + ); + const listClass = cn("space-y-1", collapsed ? "px-2 py-3" : "p-3"); return ( ); } diff --git a/solvway-admin-portal/app/lib/aclSidebar.ts b/solvway-admin-portal/app/lib/aclSidebar.ts index d4cbe52..480ddda 100644 --- a/solvway-admin-portal/app/lib/aclSidebar.ts +++ b/solvway-admin-portal/app/lib/aclSidebar.ts @@ -12,6 +12,9 @@ export interface SidebarLink { children: SidebarLink[]; } +// ponytail: fixed list; a new admin module falls into the work section until added here. +export const ADMIN_MODULES = ["BO_USERS", "BO_ROLES", "BO_EMAILS", "BO_LOGIN_SECURITY", "BO_AUDIT_LOG", "BO_COMPANIES"]; + const byId = (nodes: AdminModule[] | undefined) => [...(nodes ?? [])].sort((a, b) => (a.id ?? 0) - (b.id ?? 0)); /** diff --git a/solvway-admin-portal/app/lib/i18n/defaultMessages.ts b/solvway-admin-portal/app/lib/i18n/defaultMessages.ts index bf461fd..90b9051 100644 --- a/solvway-admin-portal/app/lib/i18n/defaultMessages.ts +++ b/solvway-admin-portal/app/lib/i18n/defaultMessages.ts @@ -86,6 +86,7 @@ export const DEFAULT_MESSAGES: Record = { HeaderSwitchToDark: "Switch to dark theme", LocaleSwitcherChange: "Change language", SidebarMainNav: "Main", + SidebarAdministration: "Administration", UiBreadcrumb: "breadcrumb", UiMore: "More", UiColumns: "Columns", From 08617f87c02158da3b82569991245efc2cc20842 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 22:49:09 +0800 Subject: [PATCH 05/14] feat: stronger scroll cue on wide tables Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../components/ui/table.scrollcue.test.tsx | 32 +++++++++++++++++++ solvway-admin-portal/app/globals.css | 12 ++++--- 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx diff --git a/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx b/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx new file mode 100644 index 0000000..63508e8 --- /dev/null +++ b/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx @@ -0,0 +1,32 @@ +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; + +// refine-visitor-pages-and-shell: wide tables show a visible fade on an edge that can still scroll. +// The old 10px shadow at 12% was too faint to notice at 360px. +describe("table scroll cue", () => { + const css = readFileSync(join(__dirname, "../../globals.css"), "utf8"); + const rule = css.match(/\[data-slot="table-container"\]\s*\{([\s\S]*?)\n\}/)?.[1] ?? ""; + + it("uses local covers over scroll shadows", () => { + expect(rule.match(/ local/g)).toHaveLength(2); + expect(rule.match(/ scroll/g)).toHaveLength(2); + }); + + it("draws a shadow wide and strong enough to see, from theme tokens only", () => { + const shadow = [...rule.matchAll(/var\(--foreground\) (\d+)%[^/]*\/ (\d+)px/g)]; + expect(shadow).toHaveLength(2); + for (const [, pct, px] of shadow) { + expect(Number(pct)).toBeGreaterThanOrEqual(18); + expect(Number(px)).toBeGreaterThanOrEqual(16); + } + expect(rule).not.toMatch(/#[0-9a-f]{3,8}\b|rgb\(|hsl\(/i); + }); + + it("makes each cover wider than its shadow, so the fade is gone at that end", () => { + const covers = [...rule.matchAll(/var\(--card\)[^/]*\/ (\d+)px/g)].map((m) => Number(m[1])); + const shadows = [...rule.matchAll(/var\(--foreground\)[^/]*\/ (\d+)px/g)].map((m) => Number(m[1])); + expect(covers).toHaveLength(2); + expect(Math.min(...covers)).toBeGreaterThan(Math.max(...shadows)); + }); +}); diff --git a/solvway-admin-portal/app/globals.css b/solvway-admin-portal/app/globals.css index d15d87a..5edc5b3 100644 --- a/solvway-admin-portal/app/globals.css +++ b/solvway-admin-portal/app/globals.css @@ -248,13 +248,15 @@ h4 { } } -/* Scroll-edge cue: a soft shadow on a side only while more content is scrollable there. */ +/* Scroll-edge cue: a shadow on a side only while more content is scrollable there. The covers + (local) scroll with the content and hide the shadows (scroll) at each end. Covers assume a card + backdrop; on the page ground they read as a faint lighter strip. */ [data-slot="table-container"] { background: - linear-gradient(to right, var(--card) 30%, transparent) left center / 24px 100% no-repeat local, - linear-gradient(to left, var(--card) 30%, transparent) right center / 24px 100% no-repeat local, - linear-gradient(to right, color-mix(in srgb, var(--foreground) 12%, transparent), transparent) left center / 10px 100% no-repeat scroll, - linear-gradient(to left, color-mix(in srgb, var(--foreground) 12%, transparent), transparent) right center / 10px 100% no-repeat scroll; + linear-gradient(to right, var(--card) 40%, transparent) left center / 40px 100% no-repeat local, + linear-gradient(to left, var(--card) 40%, transparent) right center / 40px 100% no-repeat local, + linear-gradient(to right, color-mix(in srgb, var(--foreground) 18%, transparent), transparent) left center / 20px 100% no-repeat scroll, + linear-gradient(to left, color-mix(in srgb, var(--foreground) 18%, transparent), transparent) right center / 20px 100% no-repeat scroll; } /* From 4a20e75f82abbe24bb48d6ff8e3bf80d916894fd Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 23:01:17 +0800 Subject: [PATCH 06/14] feat: visitor card, visitor states and a calmer registration form Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../refine-visitor-pages-and-shell/tasks.md | 4 +- .../RegistrationForm.look.test.tsx | 27 +++++++++ .../registration/RegistrationForm.tsx | 43 +++++++++------ .../registration/VisitorCard.test.tsx | 37 +++++++++++++ .../components/registration/VisitorCard.tsx | 55 +++++++++++++++++++ .../app/lib/i18n/defaultMessages.ts | 1 + 6 files changed, 148 insertions(+), 19 deletions(-) create mode 100644 solvway-admin-portal/app/components/registration/RegistrationForm.look.test.tsx create mode 100644 solvway-admin-portal/app/components/registration/VisitorCard.test.tsx create mode 100644 solvway-admin-portal/app/components/registration/VisitorCard.tsx diff --git a/openspec/changes/refine-visitor-pages-and-shell/tasks.md b/openspec/changes/refine-visitor-pages-and-shell/tasks.md index 30b51d2..389d6de 100644 --- a/openspec/changes/refine-visitor-pages-and-shell/tasks.md +++ b/openspec/changes/refine-visitor-pages-and-shell/tasks.md @@ -12,13 +12,13 @@ Verify for every task: `cd solvway-admin-portal && npx vitest run; echo VITEST=$ - [x] 1.2 Sidebar sections: an `ADMIN_MODULES` list in `aclSidebar.ts`, the work and Administration split in `Sidebar` (full sidebar and drawer: divider and label; rail: divider only; no section when it has no items), and the "Administration" label in `defaultMessages.ts`. - Depends on: 1.1 - Scope: `solvway-admin-portal/app/lib/aclSidebar*`, `solvway-admin-portal/app/components/app/Sidebar*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts` -- [ ] 1.3 Table scroll cue: a scroll-shadow utility in `globals.css` applied to the `table-container`, with colours from tokens only (the design-tokens test stays green). +- [x] 1.3 Table scroll cue: a scroll-shadow utility in `globals.css` applied to the `table-container`, with colours from tokens only (the design-tokens test stays green). - Depends on: 1.2 - Scope: `solvway-admin-portal/app/components/ui/table*`, `solvway-admin-portal/app/globals.css`, `solvway-admin-portal/app/globals.test.ts` ## 2. Visitor pages -- [ ] 2.1 `VisitorCard` (ground, card, event header with the company label, the dates and location with icons, footer) and `VisitorState` (icon, heading, text, action). `RegistrationForm` drops its header, adds the "Mobile or email is required" hint (new key in `defaultMessages.ts`), sets the notice as fine print, and aligns the consent row. +- [x] 2.1 `VisitorCard` (ground, card, event header with the company label, the dates and location with icons, footer) and `VisitorState` (icon, heading, text, action). `RegistrationForm` drops its header, adds the "Mobile or email is required" hint (new key in `defaultMessages.ts`), sets the notice as fine print, and aligns the consent row. - Depends on: 1.3 - Scope: `solvway-admin-portal/app/components/registration/**` except `QrCodeItem*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts` - [ ] 2.2 `/r`, `/i` and `/c` render every state inside `VisitorCard`, with `VisitorState` for loading, inactive, error, too many, not yet, ended, thank you, welcome and checked in. Existing behaviour and text stay the same. diff --git a/solvway-admin-portal/app/components/registration/RegistrationForm.look.test.tsx b/solvway-admin-portal/app/components/registration/RegistrationForm.look.test.tsx new file mode 100644 index 0000000..8f6461f --- /dev/null +++ b/solvway-admin-portal/app/components/registration/RegistrationForm.look.test.tsx @@ -0,0 +1,27 @@ +import { describe, it, expect } from "vitest"; +import { render, screen } from "@testing-library/react"; +import { RegistrationForm } from "./RegistrationForm"; + +const info = { + eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC", companyName: "INS", + notice: { id: 1, textEn: "English text", textMs: "Teks Melayu" }, interests: [], +}; +const props = { info, submit: async () => undefined, onDone: () => {}, onInactive: () => {} }; +const wrap = (ui: React.ReactElement) => render(ui); + +describe("RegistrationForm look", () => { + it("hides its own header when header is false", () => { + wrap(); + expect(screen.queryByRole("heading", { level: 1 })).toBeNull(); + }); + it("links a contact hint to the mobile field", () => { + wrap(); + const hint = screen.getByText("Mobile or email is required"); + expect(screen.getByLabelText("Mobile number").getAttribute("aria-describedby")).toBe(hint.id); + }); + it("shows the notice as fine print in both languages", () => { + wrap(); + expect(screen.getByText("English text").parentElement?.className).toContain("text-muted-foreground"); + expect(screen.getByText("Teks Melayu")).toBeTruthy(); + }); +}); diff --git a/solvway-admin-portal/app/components/registration/RegistrationForm.tsx b/solvway-admin-portal/app/components/registration/RegistrationForm.tsx index efb9aec..e39068b 100644 --- a/solvway-admin-portal/app/components/registration/RegistrationForm.tsx +++ b/solvway-admin-portal/app/components/registration/RegistrationForm.tsx @@ -13,6 +13,7 @@ const EMPTY: RegistrationBody = { name: "", mobile: "", email: "", companyName: // Fields the form renders; a server error for any other field goes to the form-level alert. const FIELDS = ["name", "mobile", "email", "companyName", "jobTitle", "consent"]; const ROW = "flex min-h-11 w-full cursor-pointer items-center gap-3 rounded-md border p-3"; +const CONSENT_ROW = "flex min-h-11 w-full cursor-pointer items-start gap-3 rounded-md border p-3 leading-normal"; const BOX = "size-6"; export function apiData(err: unknown): { status?: number; code?: string; error?: string; field?: string } { @@ -31,6 +32,8 @@ export function failMessage(t: (k: string) => string, err: unknown, tooMany = "R interface Props { /** Heading text; the event name when omitted. */ title?: string; + /** Render the event header (default). Pages inside a VisitorCard pass false: the card shows it. */ + header?: boolean; /** i18n key for the too-many message (default RegTooMany, the /r wording). */ tooManyKey?: string; info: RegistrationInfo; @@ -44,7 +47,7 @@ interface Props { } // The visitor registration form shared by /r, /i and /c: event header, fields, bilingual privacy notice and consent. -export function RegistrationForm({ title, tooManyKey, info, initial, submit, onDone, onInactive }: Props) { +export function RegistrationForm({ title, header = true, tooManyKey, info, initial, submit, onDone, onInactive }: Props) { const t = useT(); const [form, setForm] = useState({ ...EMPTY, ...initial }); const [errors, setErrors] = useState>({}); @@ -82,25 +85,31 @@ export function RegistrationForm({ title, tooManyKey, info, initial, submit, onD } } - const field = (id: "name" | "mobile" | "email" | "companyName" | "jobTitle", label: string, type = "text") => ( + const field = (id: "name" | "mobile" | "email" | "companyName" | "jobTitle", label: string, type = "text", hint?: string) => { + const describedBy = [hint && `reg-${id}-hint`, errors[id] && `reg-${id}-error`].filter(Boolean).join(" ") || undefined; + return (
- set({ [id]: e.target.value })} disabled={saving} aria-invalid={!!errors[id]} aria-describedby={errors[id] ? `reg-${id}-error` : undefined} /> + set({ [id]: e.target.value })} disabled={saving} aria-invalid={!!errors[id]} aria-describedby={describedBy} /> + {hint &&

{hint}

} {errors[id] &&

{errors[id]}

}
- ); + ); + }; return (
-
-

{title ?? info.eventName}

-

- {info.companyName} | {info.startDate} - {info.endDate} | {info.location} -

-
+ {header && ( +
+

{title ?? info.eventName}

+

+ {info.companyName} | {info.startDate} - {info.endDate} | {info.location} +

+
+ )} {formError &&

{formError}

} {field("name", t("RegName"))} - {field("mobile", t("RegMobile"), "tel")} + {field("mobile", t("RegMobile"), "tel", t("RegContactHint"))} {field("email", t("RegEmail"), "email")} {field("companyName", t("RegCompany"))} {field("jobTitle", t("RegJobTitle"))} @@ -120,15 +129,15 @@ export function RegistrationForm({ title, tooManyKey, info, initial, submit, onD ))} )} -
-

{t("RegNoticeEn")}

+
+

{t("RegNoticeEn")}

{info.notice.textEn}

-

{t("RegNoticeMs")}

+

{t("RegNoticeMs")}

{info.notice.textMs}

-