Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3944ea1f9 | ||
|
|
93f9e07a6c | ||
|
|
6fda854df0 | ||
|
|
1458ea4aab | ||
|
|
db9e218423 | ||
|
|
2c7729d139 | ||
|
|
282d2263f2 | ||
|
|
372cd7244e | ||
|
|
370c9f4ad0 | ||
|
|
ac69c34cf2 | ||
|
|
4a20e75f82 | ||
|
|
08617f87c0 | ||
|
|
5ac248cee7 | ||
|
|
d4ae94fcc9 | ||
|
|
a9e40280ee | ||
|
|
d3096cec59 | ||
|
|
9ce5d792f9 |
No files matched your search
@@ -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.
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-01
|
||||
@@ -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.
|
||||
@@ -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`.
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
## 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. Where a data table pins its first column, the pinned column covers the left fade and SHALL instead show a divider on its right edge.
|
||||
|
||||
#### 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
|
||||
- **AND** the pinned username column shows a divider on its right edge
|
||||
|
||||
### 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
|
||||
@@ -0,0 +1,57 @@
|
||||
# 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
|
||||
|
||||
- [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*`
|
||||
- [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`
|
||||
- [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
|
||||
|
||||
- [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`
|
||||
- [x] 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
|
||||
|
||||
- [x] 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*`
|
||||
- [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/**`
|
||||
|
||||
## 4. Release check
|
||||
|
||||
- [x] 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
|
||||
- Done 2026-12-01 on the local stack (review server on port 3001), full portal verify green (vitest 1580 passed with exit 0, tsc 0, lint 0 errors).
|
||||
- Visitor pages at 360 and 1280 px: /r open form (company label, h1, dates, location, hint under mobile, fine-print notice in both languages before consent), the empty-submit errors shown on screen, an unknown code (no event details), /c lookup, /c not yet (heading balanced so the date stays whole), and /i already checked in. One h1 and one main in every state. Dark theme checked on /c. No registration was submitted (no records created).
|
||||
- Header: /events shows no trail, /events/new shows "Events" linking to /events.
|
||||
- Sidebar: Administration label and divider in the full sidebar, divider only in the rail.
|
||||
- Users table at 360 px: right fade at the start and gone at the end. The pinned first column hid the left fade, so it now carries a divider on its right edge (fix found in this check). Dark theme checked.
|
||||
- Reset password (throwaway CV staff user, reverted afterwards): same frame as login at 1280 and 360 px, and the policy error is shown.
|
||||
- My QR (same user, temporarily on the LC Live Check team, then removed and disabled): card layout at 360, 700, 1024 and 1280 px. At 1280 px a button overflowed the card, so the QR now stacks above the buttons (fix found in this check).
|
||||
|
||||
- After the whole-branch review: the giraffe-spot coat and 16px corners were removed from the signed-out frame (DESIGN.md forbids them); login checked again at 1280 and 360 px. DESIGN.md updated to the shipped look. Full verify: vitest 1585 passed (exit 0), tsc 0, lint 0 errors.
|
||||
@@ -79,3 +79,63 @@ Every dropdown in the admin portal SHALL open a styled option menu that matches
|
||||
|
||||
- **WHEN** an admin focuses a dropdown and presses Enter or Space, then the arrow keys and Enter
|
||||
- **THEN** the menu opens, moves between options, and chooses one
|
||||
|
||||
### 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. Where a data table pins its first column, the pinned column covers the left fade and SHALL instead show a divider on its right edge.
|
||||
|
||||
#### 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
|
||||
- **AND** the pinned username column shows a divider on its right edge
|
||||
|
||||
### 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
|
||||
@@ -177,10 +177,16 @@ Slate neutrals with a single blue voice, plus muted semantic and chart tones tha
|
||||
|
||||
An app shell: a sticky 240px white sidebar (collapsible to a 76px icon rail on desktop, a left sheet below the lg breakpoint) beside a column holding a sticky 56px white header and the main area. The sidebar's top block is header-high so its bottom hairline continues the header's. Main content sits on the slate ground with 16px padding, centred up to 1600px.
|
||||
|
||||
Page anatomy: breadcrumb in the header, page header (title, optional meta line, actions right-aligned and wrapping), then filter row, then the content card. Rhythm is a 4px base: 8px between related controls, 16px between blocks and around the page, 24px inside cards. KPI tiles sit in one row of equal columns. Tables scroll horizontally inside their card with a soft shadow on whichever edge has more content. The page reserves the scrollbar gutter so overlays never shift the layout.
|
||||
Page anatomy: on a sub-page the header shows its parent page as a link back (a page reached from the sidebar shows none, since its title already names it), then the page header (title, optional meta line, actions right-aligned and wrapping), then filter row, then the content card. Rhythm is a 4px base: 8px between related controls, 16px between blocks and around the page, 24px inside cards. KPI tiles sit in one row of equal columns. Tables scroll horizontally inside their card with a 20px shadow at 18% ink on whichever edge has more content; it fades out at that end of the scroll. A data table's pinned first column covers the left shadow, so it carries a 1px hairline on its right edge instead. The page reserves the scrollbar gutter so overlays never shift the layout.
|
||||
|
||||
The footer credit "Powered by Containerverse Sdn. Bhd." sits at the foot of the sidebar on desktop and under the content on mobile, in 12px muted text.
|
||||
|
||||
**Public visitor pages** (`/r`, `/i`, `/c`) have no shell. One white card sits on the slate ground, full width with a 16px gutter on phones and at most 448px wide, with the footer credit under it. The card opens with the event header: the company name as a 12px semibold uppercase label in Action Blue, the event name as the 24px h1, then dates and location on their own muted lines with 16px icons. The privacy notice is fine print: 12px muted text on a slate-tint panel, both languages in full. Every end state (loading, thank you, welcome, not yet, inactive) is a centred 40px round icon (blue tint, or 10% red for errors) over a balanced semibold heading. The look is neutral: no company logo or colour.
|
||||
|
||||
**Signed-out pages** (login, reset password) share one frame: from the lg breakpoint a blue-tint panel on the left with the "Back office" pill, a headline and three feature lines, and the form column on the ground at right; below lg the panel folds into a short band above the form.
|
||||
|
||||
**My QR codes** shows one card per code in a grid (one column on phones, two from 768px, three from 1280px): the event name as the card title, dates and location under it, the warning pill in the header when switched off, then the QR above its link and a wrapping row of outline buttons.
|
||||
|
||||
## Elevation & Depth
|
||||
|
||||
Flat surfaces separated by hairlines, with a whisper of shadow that only says "this lifts slightly". Cards carry the card shadow; controls carry a barely-there shadow; floating layers (menus, popovers, toasts, dialogs) step up. In dark mode the card shadow becomes a single dark drop and hairlines do the work.
|
||||
@@ -231,8 +237,8 @@ Quiet, compact, unmistakable.
|
||||
- Live inside a card or an 8px framed container. Header row in slate tint, 40px tall, 12px semibold uppercase muted labels with sort chevrons; cells 14px with 8px padding; rows separated by hairlines, hovering at 50% slate tint. The pager below reads "1-7 of 7" left and outline Previous / Next right.
|
||||
|
||||
### Navigation
|
||||
- **Sidebar:** white, right hairline. Items are 44px tall, 8px radius, 20px outline icon plus 14px medium label. Idle: muted slate, hover slate tint with ink. Active: blue tint with deep blue ink, `aria-current="page"`. Groups expand with a rotating chevron and indent children behind a left hairline. The collapsed rail shows icons only, with groups opening as a side popover.
|
||||
- **Header:** white, bottom hairline, 56px; breadcrumb left; company picker (a styled select), locale switcher, theme toggle and user menu (blue avatar initial) right.
|
||||
- **Sidebar:** white, right hairline. Items are 44px tall, 8px radius, 20px outline icon plus 14px medium label. Idle: muted slate, hover slate tint with ink. Active: blue tint with deep blue ink, `aria-current="page"`. Groups expand with a rotating chevron and indent children behind a left hairline. The collapsed rail shows icons only, with groups opening as a side popover. Admin pages (Users, Roles, Emails, Login security, Audit log, Companies) sit below a hairline divider and a 12px semibold muted "Administration" label; the rail keeps the divider only, and a section with nothing to open is not drawn.
|
||||
- **Header:** white, bottom hairline, 56px; the link back to the parent page left (sub-pages only); company picker (a styled select), locale switcher, theme toggle and user menu (blue avatar initial) right.
|
||||
|
||||
### Data States
|
||||
- Empty: centred muted icon, 14px muted message and a corrective action. Error: a 40% red-bordered panel on 5% red with an alert icon and an outline Retry. Loading: skeleton rows in a bordered surface.
|
||||
@@ -253,4 +259,4 @@ Quiet, compact, unmistakable.
|
||||
- **Don't** add a second typeface or a display face; Inter carries everything.
|
||||
- **Don't** use semantic or chart tones to mark something clickable.
|
||||
- **Don't** add shadows beyond the four steps, or let a shadow stand in for a hairline.
|
||||
- **Don't** apply this system to the booth (My QR), visitor pages (/r, /i, /c) or login screens piecemeal; they move onto it in their own follow-up change.
|
||||
- **Don't** brand the visitor pages per company (logo or colour) without an owner decision; they stay on the neutral Co-Lite tokens.
|
||||
@@ -0,0 +1,89 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ getCheckin: vi.fn(), lookupCheckin: vi.fn(), registerWalkIn: vi.fn() }));
|
||||
vi.mock("@/app/lib/services/publicInvite", () => mocks);
|
||||
vi.mock("next/navigation", () => ({ useParams: () => ({ token: "chk1" }) }));
|
||||
|
||||
import { ApiError } from "@/app/lib/clientApi";
|
||||
import CheckinPage from "./page";
|
||||
|
||||
const open = {
|
||||
state: "OPEN", eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC", companyName: "INS",
|
||||
notice: { id: 7, textEn: "We keep your data safe.", textMs: "Data anda selamat." }, interests: [],
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.getCheckin.mockReset().mockResolvedValue(open);
|
||||
mocks.lookupCheckin.mockReset().mockResolvedValue({ result: "CHECKED_IN", firstName: "Aini" });
|
||||
mocks.registerWalkIn.mockReset().mockResolvedValue({});
|
||||
});
|
||||
|
||||
const h1s = () => screen.getAllByRole("heading", { level: 1 });
|
||||
|
||||
describe("/c visitor card", () => {
|
||||
it("lookup sits in the card under the event header with one h1", async () => {
|
||||
render(<CheckinPage />);
|
||||
await screen.findByLabelText("Mobile number or email");
|
||||
expect(screen.getByText("INS", { selector: "p" })).toBeTruthy();
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
expect(screen.getByText("2026-12-01 - 2026-12-02")).toBeTruthy();
|
||||
expect(document.querySelectorAll("main").length).toBe(1);
|
||||
});
|
||||
|
||||
it("walk-in form shows the notice before consent under one h1", async () => {
|
||||
const user = userEvent.setup();
|
||||
mocks.lookupCheckin.mockResolvedValue({ result: "FORM" });
|
||||
render(<CheckinPage />);
|
||||
await user.type(await screen.findByLabelText("Mobile number or email"), "0123456789");
|
||||
await user.click(screen.getByRole("button", { name: "Check in" }));
|
||||
await screen.findByLabelText("Your name");
|
||||
const notice = screen.getByText("We keep your data safe.");
|
||||
expect(notice.compareDocumentPosition(screen.getByLabelText(/I agree to INS/)) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
});
|
||||
|
||||
it("loading icon spins", () => {
|
||||
mocks.getCheckin.mockReturnValue(new Promise(() => {}));
|
||||
render(<CheckinPage />);
|
||||
expect(screen.getByRole("status").querySelector("svg")).toHaveClass("motion-safe:animate-spin");
|
||||
});
|
||||
|
||||
it("welcome shows an icon and heading under the event header", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<CheckinPage />);
|
||||
await user.type(await screen.findByLabelText("Mobile number or email"), "0123456789");
|
||||
await user.click(screen.getByRole("button", { name: "Check in" }));
|
||||
const s = await screen.findByRole("status");
|
||||
expect(s.querySelector("svg")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 2 }).textContent).toBe("Welcome, Aini. You're checked in.");
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
});
|
||||
|
||||
it("not yet and ended have an icon and the heading as the only h1", async () => {
|
||||
mocks.getCheckin.mockResolvedValue({ state: "NOT_YET", startDate: "2026-12-01" });
|
||||
const { unmount } = render(<CheckinPage />);
|
||||
const s = await screen.findByRole("status");
|
||||
expect(s.querySelector("svg")).toBeTruthy();
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Check-in opens on 2026-12-01."]);
|
||||
unmount();
|
||||
mocks.getCheckin.mockResolvedValue({ state: "ENDED", startDate: "2026-12-01" });
|
||||
render(<CheckinPage />);
|
||||
await screen.findByText("This event has ended.");
|
||||
expect(h1s().length).toBe(1);
|
||||
expect(document.querySelectorAll("main").length).toBe(1);
|
||||
});
|
||||
|
||||
it("inactive and load error are alerts with one h1 and no event details", async () => {
|
||||
mocks.getCheckin.mockRejectedValue(new ApiError("x", 404, { code: "CODE_INACTIVE" }));
|
||||
const { unmount } = render(<CheckinPage />);
|
||||
expect((await screen.findByRole("alert")).querySelector("svg")).toBeTruthy();
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["This code is no longer active."]);
|
||||
unmount();
|
||||
mocks.getCheckin.mockRejectedValue(new ApiError("x", 500, {}));
|
||||
render(<CheckinPage />);
|
||||
await screen.findByRole("alert");
|
||||
expect(h1s().length).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
import { useEffect, useState, type FormEvent } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { AlertCircle, CheckCircle2, Clock, Loader2 } from "lucide-react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { Input } from "@/app/components/ui/input";
|
||||
import { Label } from "@/app/components/ui/label";
|
||||
import { VisitorCard, VisitorState } from "@/app/components/registration/VisitorCard";
|
||||
import { RegistrationForm, apiData, failMessage } from "@/app/components/registration/RegistrationForm";
|
||||
import { getCheckin, lookupCheckin, registerWalkIn, type CheckinState } from "@/app/lib/services/publicInvite";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
@@ -57,19 +59,22 @@ export default function CheckinPage() {
|
||||
}
|
||||
|
||||
const open = state?.state === "OPEN" ? state : null;
|
||||
const alone = (icon: typeof Clock, heading: string, role: "status" | "alert", tone?: "error", iconClassName?: string) => (
|
||||
<VisitorCard><VisitorState h1 icon={icon} heading={heading} role={role} tone={tone} iconClassName={iconClassName} /></VisitorCard>
|
||||
);
|
||||
if (phase === "loading") return alone(Loader2, t("UiLoading"), "status", undefined, "motion-safe:animate-spin");
|
||||
if (phase === "inactive") return alone(AlertCircle, t("RegInactive"), "alert");
|
||||
if (phase === "error" || !state) return alone(AlertCircle, error ?? t("RegLoadFailed"), "alert", "error");
|
||||
if (!open) return alone(Clock, state.state === "NOT_YET" ? t("ChkNotYet", { date: state.startDate }) : t("ChkEnded"), "status");
|
||||
|
||||
let body;
|
||||
if (phase === "loading") body = <p role="status">{t("UiLoading")}</p>;
|
||||
else if (phase === "inactive") body = <p role="alert">{t("RegInactive")}</p>;
|
||||
else if (phase === "error" || !state) body = <p role="alert" className="text-sm text-destructive">{error}</p>;
|
||||
else if (!open) body = <p role="status">{state.state === "NOT_YET" ? t("ChkNotYet", { date: state.startDate }) : t("ChkEnded")}</p>;
|
||||
else if (phase === "welcome") body = <p role="status" className="text-lg font-medium">{firstName ? t("InviteWelcome", { name: firstName }) : t("InviteWelcomeAnon")}</p>;
|
||||
else if (phase === "done") body = <p role="status" className="text-lg font-medium">{t("ChkDone", { event: open.eventName })}</p>;
|
||||
if (phase === "welcome") body = <VisitorState icon={CheckCircle2} heading={firstName ? t("InviteWelcome", { name: firstName }) : t("InviteWelcomeAnon")} role="status" />;
|
||||
else if (phase === "done") body = <VisitorState icon={CheckCircle2} heading={t("ChkDone", { event: open.eventName })} role="status" />;
|
||||
else if (phase === "form") {
|
||||
body = <RegistrationForm tooManyKey="InviteTooMany" info={open} submit={(b) => registerWalkIn(token, b)} onDone={() => setPhase("done")} onInactive={() => setPhase("inactive")} />;
|
||||
} else {
|
||||
body = (
|
||||
<form onSubmit={lookup} className="space-y-4" noValidate>
|
||||
<h1 className="text-2xl font-semibold">{open.eventName}</h1>
|
||||
{error && <p role="alert" className="text-sm text-destructive">{error}</p>}
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="chk-value">{t("ChkLookup")}</Label>
|
||||
@@ -80,5 +85,5 @@ export default function CheckinPage() {
|
||||
);
|
||||
}
|
||||
|
||||
return <main className="mx-auto w-full max-w-md px-4 py-6">{body}</main>;
|
||||
return <VisitorCard event={open}>{body}</VisitorCard>;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
"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
|
||||
// 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 (
|
||||
<div className="grid min-h-svh bg-background lg:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]">
|
||||
<aside className="relative isolate hidden flex-col justify-between gap-10 overflow-hidden bg-accent p-12 text-accent-foreground lg:flex">
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="rounded-full bg-primary px-3 py-1 text-sm font-semibold text-primary-foreground dark:bg-accent-foreground dark:text-accent">
|
||||
{t("BackOfficeLabel")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="max-w-md space-y-8">
|
||||
<p className="font-heading text-4xl leading-tight font-semibold tracking-tight text-balance">
|
||||
{t("BackOfficePanelTitle")}
|
||||
</p>
|
||||
<ul className="space-y-4">
|
||||
{PANEL_POINTS.map(({ icon: PointIcon, code }) => (
|
||||
<li key={code} className="flex items-center gap-3 text-base font-medium">
|
||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground dark:bg-accent-foreground dark:text-accent">
|
||||
<PointIcon aria-hidden="true" className="size-5" />
|
||||
</span>
|
||||
{t(code)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<span aria-hidden="true" />
|
||||
</aside>
|
||||
|
||||
<main className="flex flex-col items-center justify-center gap-8 p-6 sm:p-10">
|
||||
<div className="w-full max-w-sm space-y-8">
|
||||
{/* Below lg a short brand band stands in for the panel: same accent ground. */}
|
||||
<div className="relative isolate flex items-center gap-3 overflow-hidden rounded-lg bg-accent p-4 lg:hidden">
|
||||
<span className="rounded-full bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground dark:bg-accent-foreground dark:text-accent">
|
||||
{t("BackOfficeLabel")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{children}
|
||||
</div>
|
||||
<PoweredBy />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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(<Breadcrumbs />);
|
||||
const { container } = render(<Breadcrumbs />);
|
||||
|
||||
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(
|
||||
<MessagesProvider locale="zh_CN" messages={{ BO_MESSAGES: "消息" }}>
|
||||
@@ -86,7 +86,7 @@ describe("Breadcrumbs", () => {
|
||||
</MessagesProvider>,
|
||||
);
|
||||
|
||||
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(<Breadcrumbs />);
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
@@ -115,3 +115,27 @@ describe("Breadcrumbs pick the most specific match", () => {
|
||||
expect(list.querySelectorAll("li li")).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Breadcrumbs trail without repeats", () => {
|
||||
const EVENT_LINKS: SidebarLink[] = [
|
||||
{ name: "Event", url: "", children: [{ name: "Events", url: "/events", children: [] }] },
|
||||
];
|
||||
|
||||
it("shows no trail on the Events list", () => {
|
||||
state.links = EVENT_LINKS;
|
||||
state.pathname = "/events";
|
||||
|
||||
const { container } = render(<Breadcrumbs />);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
it("shows Events as a link to the list on the new event page", () => {
|
||||
state.links = EVENT_LINKS;
|
||||
state.pathname = "/events/new";
|
||||
|
||||
render(<Breadcrumbs />);
|
||||
|
||||
expect(screen.getByRole("link", { name: "Events" })).toHaveAttribute("href", "/events");
|
||||
});
|
||||
});
|
||||
@@ -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 (
|
||||
<Breadcrumb className="hidden md:block">
|
||||
@@ -35,13 +35,9 @@ export default function Breadcrumbs() {
|
||||
</Fragment>
|
||||
))}
|
||||
<BreadcrumbItem>
|
||||
{pathname === url ? (
|
||||
<BreadcrumbPage>{t(leaf.name)}</BreadcrumbPage>
|
||||
) : (
|
||||
<BreadcrumbLink asChild>
|
||||
<Link href={url}>{t(leaf.name)}</Link>
|
||||
</BreadcrumbLink>
|
||||
)}
|
||||
<BreadcrumbLink asChild>
|
||||
<Link href={url}>{t(leaf.name)}</Link>
|
||||
</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
|
||||
@@ -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(<Header />);
|
||||
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(<Header />);
|
||||
expect(screen.getByRole("link", { name: "Sales Listing" })).toHaveAttribute("href", "/orders/web");
|
||||
} finally {
|
||||
nav.pathname = "/orders/web";
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -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(<SidebarNav />);
|
||||
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(<SidebarNav />);
|
||||
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(<SidebarNav />);
|
||||
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(<SidebarNav collapsed />);
|
||||
expect(screen.queryByText("Administration")).toBeNull();
|
||||
expect(container.querySelector("[data-slot='sidebar-divider']")).not.toBeNull();
|
||||
expect(screen.getAllByRole("link")).toHaveLength(11);
|
||||
});
|
||||
});
|
||||
@@ -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 ? (
|
||||
<RailNode key={link.url || link.name} link={link} trail={trail} />
|
||||
) : (
|
||||
<NavNode key={link.url || link.name} link={link} depth={0} trail={trail} onNavigate={onNavigate} />
|
||||
);
|
||||
const listClass = cn("space-y-1", collapsed ? "px-2 py-3" : "p-3");
|
||||
|
||||
return (
|
||||
<nav aria-label={t("SidebarMainNav")} className="scrollable flex-1 overflow-x-hidden overflow-y-auto">
|
||||
<ul className={cn("space-y-1", collapsed ? "px-2 py-3" : "p-3")}>
|
||||
{links.map((link) =>
|
||||
collapsed ? (
|
||||
<RailNode key={link.url || link.name} link={link} trail={trail} />
|
||||
) : (
|
||||
<NavNode key={link.url || link.name} link={link} depth={0} trail={trail} onNavigate={onNavigate} />
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
{work.length > 0 && <ul className={cn(listClass, admin.length > 0 && "pb-0")}>{work.map(render)}</ul>}
|
||||
{admin.length > 0 && (
|
||||
<>
|
||||
<div data-slot="sidebar-divider" className={cn("mt-3 border-t border-border", collapsed ? "mx-3" : "mx-4")} />
|
||||
{/* The visible label names the list; the rail has no label, so the list carries the name itself. */}
|
||||
{!collapsed && (
|
||||
<p id={adminLabelId} className="px-6 pt-3 text-xs font-semibold text-muted-foreground">
|
||||
{t("SidebarAdministration")}
|
||||
</p>
|
||||
)}
|
||||
<ul
|
||||
aria-labelledby={collapsed ? undefined : adminLabelId}
|
||||
aria-label={collapsed ? t("SidebarAdministration") : undefined}
|
||||
className={cn(listClass, collapsed ? "pt-3" : "pt-2")}>
|
||||
{admin.map(render)}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Copy, Download, Maximize2, Share2 } from "lucide-react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { Dialog, DialogContent } from "@/app/components/ui/dialog";
|
||||
import { Switch } from "@/app/components/ui/switch";
|
||||
import { cn } from "@/app/lib/utils";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
|
||||
const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
||||
@@ -13,6 +14,7 @@ const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(
|
||||
/** One registration code: QR, link, copy, PNG download and (when onToggle is given) an on/off switch. */
|
||||
export function QrCodeItem({
|
||||
label,
|
||||
className,
|
||||
eventName,
|
||||
fileLabel,
|
||||
token,
|
||||
@@ -21,7 +23,9 @@ export function QrCodeItem({
|
||||
prefix = "r",
|
||||
personal = false,
|
||||
}: {
|
||||
label: string;
|
||||
/** Heading above the link; omit when the surrounding card already names the event. */
|
||||
label?: string;
|
||||
className?: string;
|
||||
eventName: string;
|
||||
/** Member name for the download file name; omit for the event code. */
|
||||
fileLabel?: string;
|
||||
@@ -71,11 +75,11 @@ export function QrCodeItem({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center">
|
||||
<div className={cn("flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center", className)}>
|
||||
<QRCodeSVG value={link} size={128} className="shrink-0" />
|
||||
<QRCodeCanvas ref={canvas} value={link} size={512} className="hidden" />
|
||||
<div className="min-w-0 flex-1 space-y-2">
|
||||
<p className="text-sm font-medium">{label}</p>
|
||||
{label && <p className="text-sm font-medium">{label}</p>}
|
||||
<p className="break-all text-xs text-muted-foreground">{link}</p>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Button variant="outline" size="sm" onClick={copy}>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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("renders no heading of its own: the visitor card carries the event header", () => {
|
||||
wrap(<RegistrationForm {...props} />);
|
||||
expect(screen.queryByRole("heading", { level: 1 })).toBeNull();
|
||||
});
|
||||
it("links a contact hint to the mobile field", () => {
|
||||
wrap(<RegistrationForm {...props} />);
|
||||
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(<RegistrationForm {...props} />);
|
||||
expect(screen.getByText("English text").parentElement?.className).toContain("text-muted-foreground");
|
||||
expect(screen.getByText("Teks Melayu")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("sets the consent sentences in regular weight", () => {
|
||||
wrap(<RegistrationForm {...props} />);
|
||||
expect(screen.getByText(/I agree to INS/).closest("span[class*=space-y]")).toHaveClass("font-normal");
|
||||
});
|
||||
});
|
||||
@@ -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 } {
|
||||
@@ -29,8 +30,6 @@ export function failMessage(t: (k: string) => string, err: unknown, tooMany = "R
|
||||
}
|
||||
|
||||
interface Props {
|
||||
/** Heading text; the event name when omitted. */
|
||||
title?: string;
|
||||
/** i18n key for the too-many message (default RegTooMany, the /r wording). */
|
||||
tooManyKey?: string;
|
||||
info: RegistrationInfo;
|
||||
@@ -43,8 +42,9 @@ interface Props {
|
||||
onInactive: () => void;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// The visitor registration form shared by /r, /i and /c: fields, bilingual privacy notice and consent.
|
||||
// The event header comes from the VisitorCard around it.
|
||||
export function RegistrationForm({ tooManyKey, info, initial, submit, onDone, onInactive }: Props) {
|
||||
const t = useT();
|
||||
const [form, setForm] = useState<RegistrationBody>({ ...EMPTY, ...initial });
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
@@ -82,25 +82,23 @@ 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 (
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`reg-${id}`}>{label}</Label>
|
||||
<Input id={`reg-${id}`} className="h-11" type={type} value={form[id]} onChange={(e) => set({ [id]: e.target.value })} disabled={saving} aria-invalid={!!errors[id]} aria-describedby={errors[id] ? `reg-${id}-error` : undefined} />
|
||||
<Input id={`reg-${id}`} className="h-11" type={type} value={form[id]} onChange={(e) => set({ [id]: e.target.value })} disabled={saving} aria-invalid={!!errors[id]} aria-describedby={describedBy} />
|
||||
{hint && <p id={`reg-${id}-hint`} className="text-xs text-muted-foreground">{hint}</p>}
|
||||
{errors[id] && <p id={`reg-${id}-error`} className="text-sm text-destructive">{errors[id]}</p>}
|
||||
</div>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit} className="space-y-4" noValidate>
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">{title ?? info.eventName}</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{info.companyName} | {info.startDate} - {info.endDate} | {info.location}
|
||||
</p>
|
||||
</div>
|
||||
{formError && <p role="alert" className="text-sm text-destructive">{formError}</p>}
|
||||
{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 +118,15 @@ export function RegistrationForm({ title, tooManyKey, info, initial, submit, onD
|
||||
))}
|
||||
</fieldset>
|
||||
)}
|
||||
<div className="space-y-2 rounded-md border p-3 text-sm">
|
||||
<h2 className="font-medium">{t("RegNoticeEn")}</h2>
|
||||
<div className="space-y-2 rounded-md bg-muted p-3 text-xs text-muted-foreground">
|
||||
<h2 className="font-semibold text-foreground">{t("RegNoticeEn")}</h2>
|
||||
<p className="whitespace-pre-line">{info.notice.textEn}</p>
|
||||
<h2 className="font-medium">{t("RegNoticeMs")}</h2>
|
||||
<h2 className="font-semibold text-foreground">{t("RegNoticeMs")}</h2>
|
||||
<p className="whitespace-pre-line">{info.notice.textMs}</p>
|
||||
</div>
|
||||
<Label htmlFor="reg-consent" className={ROW}>
|
||||
<Checkbox id="reg-consent" className={BOX} checked={form.consent} onCheckedChange={(on) => set({ consent: on === true })} aria-invalid={!!errors.consent} aria-describedby={errors.consent ? "reg-consent-error" : undefined} />
|
||||
<span>
|
||||
<Label htmlFor="reg-consent" className={CONSENT_ROW}>
|
||||
<Checkbox id="reg-consent" className={`${BOX} mt-0.5`} checked={form.consent} onCheckedChange={(on) => set({ consent: on === true })} aria-invalid={!!errors.consent} aria-describedby={errors.consent ? "reg-consent-error" : undefined} />
|
||||
<span className="space-y-1 font-normal">
|
||||
<span className="block">{t("RegConsentEn", { company: info.companyName })}</span>
|
||||
<span className="block">{t("RegConsentMs", { company: info.companyName })}</span>
|
||||
</span>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { Inbox } from "lucide-react";
|
||||
import { VisitorCard, VisitorState } from "./VisitorCard";
|
||||
|
||||
const event = { companyName: "INS", eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC" };
|
||||
|
||||
describe("VisitorCard", () => {
|
||||
it("shows the event header in one card with one h1", () => {
|
||||
render(<VisitorCard event={event}><p>body</p></VisitorCard>);
|
||||
expect(screen.getByRole("main")).toBeTruthy();
|
||||
expect(screen.getByText("INS").className).toContain("uppercase");
|
||||
expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("Expo 2026");
|
||||
expect(screen.getByText("2026-12-01 - 2026-12-02")).toBeTruthy();
|
||||
expect(screen.getByText("KLCC")).toBeTruthy();
|
||||
expect(screen.getByText("body")).toBeTruthy();
|
||||
expect(screen.getByText(/Powered by/)).toBeTruthy();
|
||||
});
|
||||
it("title overrides the h1", () => {
|
||||
render(<VisitorCard event={event} title="You're invited to Expo 2026" />);
|
||||
expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("You're invited to Expo 2026");
|
||||
});
|
||||
it("renders without event data", () => {
|
||||
render(<VisitorCard><p>x</p></VisitorCard>);
|
||||
expect(screen.queryByRole("heading", { level: 1 })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("VisitorState", () => {
|
||||
it("renders heading, text, action and role", () => {
|
||||
render(<VisitorState icon={Inbox} heading="Gone" text="Not active" role="alert" tone="error" action={<button>Go</button>} />);
|
||||
expect(screen.getByRole("alert")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 2 }).textContent).toBe("Gone");
|
||||
expect(screen.getByText("Not active")).toBeTruthy();
|
||||
expect(screen.getByRole("button", { name: "Go" })).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { CalendarDays, MapPin, type LucideIcon } from "lucide-react";
|
||||
import PoweredBy from "@/app/components/app/PoweredBy";
|
||||
import type { RegistrationInfo } from "@/app/lib/services/publicRegistration";
|
||||
|
||||
type EventHeader = Pick<RegistrationInfo, "companyName" | "eventName" | "startDate" | "endDate" | "location">;
|
||||
|
||||
// The public visitor page frame: one card on the page ground, event header first, PoweredBy under it.
|
||||
export function VisitorCard({ event, title, children }: { event?: EventHeader; title?: string; children?: ReactNode }) {
|
||||
return (
|
||||
<div className="flex min-h-svh flex-col items-center bg-background px-4 py-8">
|
||||
<main className="w-full max-w-md space-y-6 rounded-lg border bg-card p-6 shadow-card">
|
||||
{event && (
|
||||
<header className="space-y-2">
|
||||
<p className="text-xs font-semibold tracking-wide text-primary uppercase">{event.companyName}</p>
|
||||
<h1 className="text-2xl font-semibold">{title ?? event.eventName}</h1>
|
||||
<p className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<CalendarDays className="size-4 shrink-0" aria-hidden="true" />
|
||||
<span>{event.startDate} - {event.endDate}</span>
|
||||
</p>
|
||||
<p className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<MapPin className="size-4 shrink-0" aria-hidden="true" />
|
||||
<span>{event.location}</span>
|
||||
</p>
|
||||
</header>
|
||||
)}
|
||||
{children}
|
||||
</main>
|
||||
<div className="mt-4"><PoweredBy /></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface StateProps {
|
||||
icon: LucideIcon;
|
||||
heading: string;
|
||||
text?: string;
|
||||
action?: ReactNode;
|
||||
role?: "status" | "alert";
|
||||
tone?: "default" | "error";
|
||||
/** The heading is the page's h1: for states shown without the card's event header. */
|
||||
h1?: boolean;
|
||||
iconClassName?: string;
|
||||
}
|
||||
|
||||
// A message inside the card (thanks, inactive, closed). h2 under the event header's h1; h1 when the card has no event header.
|
||||
export function VisitorState({ icon: Icon, heading, text, action, role, tone = "default", h1, iconClassName }: StateProps) {
|
||||
const Heading = h1 ? "h1" : "h2";
|
||||
return (
|
||||
<div role={role} className="flex flex-col items-center gap-3 text-center">
|
||||
<span className={`flex size-12 items-center justify-center rounded-full ${tone === "error" ? "bg-destructive/10 text-destructive" : "bg-accent text-accent-foreground"}`}>
|
||||
<Icon className={`size-6 ${iconClassName ?? ""}`} aria-hidden="true" />
|
||||
</span>
|
||||
<Heading className="text-lg font-semibold text-balance">{heading}</Heading>
|
||||
{text && <p className="text-sm text-muted-foreground">{text}</p>}
|
||||
{action}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { DataTable } from "./data-table";
|
||||
|
||||
// refine-visitor-pages-and-shell: the pinned first column hides the left scroll cue, so it carries
|
||||
// a divider on its right edge that shows where scrolled columns slide under it.
|
||||
type Row = { id: string; name: string };
|
||||
const columns: ColumnDef<Row, unknown>[] = [{ accessorKey: "name", header: "Name" }];
|
||||
|
||||
describe("pinned first column", () => {
|
||||
it("draws a token-coloured divider on the right edge of the pinned head and body cells", () => {
|
||||
render(
|
||||
<DataTable<Row> label="t" columns={columns} data={[{ id: "1", name: "Alpha" }]} total={1} page={1} pageSize={20}
|
||||
onPageChange={() => {}} rowKey={r => r.id} />,
|
||||
);
|
||||
const divider = "shadow-[inset_-1px_0_0_var(--border)]";
|
||||
expect(screen.getByRole("columnheader", { name: "Name" })).toHaveClass(divider);
|
||||
expect(screen.getByText("Alpha").closest("td")).toHaveClass(divider);
|
||||
});
|
||||
});
|
||||
@@ -42,12 +42,13 @@ declare module '@tanstack/react-table' {
|
||||
|
||||
// The first column stays visible while a wide table scrolls sideways. Its cells need an opaque
|
||||
// background that follows the row's hover/focus/selected state, or scrolled cells show through.
|
||||
const PINNED_HEAD = 'sticky left-0 z-[1] bg-table-head'
|
||||
// The inset right divider stands in for the left scroll cue, which the opaque column covers.
|
||||
const PINNED_HEAD = 'sticky left-0 z-[1] bg-table-head shadow-[inset_-1px_0_0_var(--border)]'
|
||||
// Clicks on these inside a row act on the control, not the row.
|
||||
const ROW_CONTROLS = 'a, button, input, select, textarea, label, [role="checkbox"]'
|
||||
|
||||
const PINNED_CELL =
|
||||
'sticky left-0 z-[1] bg-card group-hover:bg-muted group-focus-visible:bg-muted group-aria-selected:bg-accent'
|
||||
'sticky left-0 z-[1] bg-card shadow-[inset_-1px_0_0_var(--border)] group-hover:bg-muted group-focus-visible:bg-muted group-aria-selected:bg-accent'
|
||||
|
||||
/**
|
||||
* Data table for server-paginated, server-sorted result sets — which is what
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
});
|
||||
@@ -75,11 +75,6 @@
|
||||
--table-head: #F1F5F9;
|
||||
--table-head-foreground: #475569;
|
||||
|
||||
/* Giraffe-spot brand pattern (same artwork as the customer portal's --giraffe-motif): a seamless
|
||||
tile of coat patches, shape only — used as a mask by .giraffe-spots below. */
|
||||
--giraffe-tile: 180px;
|
||||
--giraffe-motif: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="180" height="180" viewBox="0 0 180 180"%3E%3Cpath d="M9.1 -0.2Q15.0 -5.6 23.9 -5.3L37.9 -4.9Q46.8 -4.6 50.4 -1.0L56.1 4.7Q59.7 8.4 56.0 18.6L50.2 34.8Q46.6 45.0 37.4 47.5L23.1 51.3Q13.9 53.7 8.9 47.6L0.9 38.0Q-4.1 31.9 -4.7 26.9L-5.6 18.9Q-6.2 13.8 -0.2 8.4ZM9.1 179.8Q15.0 174.4 23.9 174.7L37.9 175.1Q46.8 175.4 50.4 179.0L56.1 184.7Q59.7 188.4 56.0 198.6L50.2 214.8Q46.6 225.0 37.4 227.5L23.1 231.3Q13.9 233.7 8.9 227.6L0.9 218.0Q-4.1 211.9 -4.7 206.9L-5.6 198.9Q-6.2 193.8 -0.2 188.4ZM230.2 34.8Q226.6 45.0 217.4 47.5L203.1 51.3Q193.9 53.7 188.9 47.6L180.9 38.0Q175.9 31.9 175.3 26.9L174.4 18.9Q173.8 13.8 179.8 8.4L189.1 -0.2Q195.0 -5.6 203.9 -5.3L217.9 -4.9Q226.8 -4.6 230.4 -1.0L236.1 4.7Q239.7 8.4 236.0 18.6ZM230.2 214.8Q226.6 225.0 217.4 227.5L203.1 231.3Q193.9 233.7 188.9 227.6L180.9 218.0Q175.9 211.9 175.3 206.9L174.4 198.9Q173.8 193.8 179.8 188.4L189.1 179.8Q195.0 174.4 203.9 174.7L217.9 175.1Q226.8 175.4 230.4 179.0L236.1 184.7Q239.7 188.4 236.0 198.6ZM12.7 70.7Q15.2 58.5 24.3 56.1L38.6 52.3Q47.8 49.9 55.8 57.4L68.3 69.3Q76.4 76.9 70.4 86.7L61.1 102.2Q55.1 112.1 41.5 109.3L20.1 104.8Q6.4 101.9 8.9 89.8ZM49.1 156.8Q45.9 170.4 37.5 170.1L24.4 169.7Q16.0 169.5 11.5 152.7L4.4 126.3Q-0.2 109.5 1.0 108.7L2.9 107.4Q4.0 106.5 18.2 109.5L40.5 114.2Q54.7 117.1 55.4 118.5L56.5 120.6Q57.2 121.9 54.0 135.5ZM229.1 156.8Q225.9 170.4 217.5 170.1L204.4 169.7Q196.0 169.5 191.5 152.7L184.4 126.3Q179.8 109.5 181.0 108.7L182.9 107.4Q184.0 106.5 198.2 109.5L220.5 114.2Q234.7 117.1 235.4 118.5L236.5 120.6Q237.2 121.9 234.0 135.5ZM59.5 54.1Q51.4 46.4 55.0 36.3L60.7 20.3Q64.4 10.2 74.6 9.7L90.7 9.0Q101.0 8.6 103.9 24.4L108.5 49.3Q111.4 65.2 111.2 65.8L110.9 66.8Q110.6 67.4 102.2 69.2L88.8 72.0Q80.3 73.7 72.2 66.1ZM78.1 126.0Q61.6 119.6 61.0 118.3L59.9 116.3Q59.2 115.0 65.4 104.8L75.0 88.8Q81.1 78.7 89.6 76.9L103.0 74.1Q111.5 72.4 119.4 83.5L131.8 100.9Q139.6 112.1 134.2 120.5L125.7 133.8Q120.3 142.3 103.9 135.9ZM74.3 4.7Q63.6 5.2 60.0 1.5L54.3 -4.2Q50.6 -7.9 53.7 -21.1L58.6 -41.8Q61.6 -55.0 77.6 -48.8L102.8 -39.1Q118.8 -32.9 118.7 -27.7L118.6 -19.5Q118.6 -14.2 113.9 -9.3L106.6 -1.4Q101.9 3.5 91.2 4.0ZM74.3 184.7Q63.6 185.2 60.0 181.5L54.3 175.8Q50.6 172.1 53.7 158.9L58.6 138.2Q61.6 125.0 77.6 131.2L102.8 140.9Q118.8 147.1 118.7 152.3L118.6 160.5Q118.6 165.8 113.9 170.7L106.6 178.6Q101.9 183.5 91.2 184.0ZM155.6 7.5Q168.9 14.4 169.4 19.2L170.3 26.8Q170.8 31.6 155.4 40.0L131.2 53.1Q115.8 61.5 113.0 46.2L108.5 22.1Q105.7 6.8 110.2 2.0L117.1 -5.4Q121.6 -10.1 134.8 -3.3ZM155.6 187.5Q168.9 194.4 169.4 199.2L170.3 206.8Q170.8 211.6 155.4 220.0L131.2 233.1Q115.8 241.5 113.0 226.2L108.5 202.1Q105.7 186.8 110.2 182.0L117.1 174.6Q121.6 169.9 134.8 176.7ZM-56.7 80.4Q-64.7 69.2 -64.5 68.6L-64.2 67.7Q-64.0 67.1 -48.1 58.4L-23.0 44.8Q-7.1 36.1 -2.2 42.0L5.4 51.3Q10.3 57.2 7.8 69.8L3.8 89.7Q1.2 102.4 -0.2 103.4L-2.5 105.0Q-3.9 106.0 -13.0 107.0L-27.1 108.4Q-36.2 109.3 -44.1 98.1ZM123.3 80.4Q115.3 69.2 115.5 68.6L115.8 67.7Q116.0 67.1 131.9 58.4L157.0 44.8Q172.9 36.1 177.8 42.0L185.4 51.3Q190.3 57.2 187.8 69.8L183.8 89.7Q181.2 102.4 179.8 103.4L177.5 105.0Q176.1 106.0 167.0 107.0L152.9 108.4Q143.8 109.3 135.9 98.1ZM-13.6 -68.0Q-4.9 -68.9 -0.4 -52.1L6.7 -25.7Q11.2 -8.9 5.5 -3.7L-3.5 4.5Q-9.2 9.8 -22.4 2.9L-43.2 -7.9Q-56.4 -14.7 -56.4 -20.1L-56.2 -28.5Q-56.2 -33.9 -50.5 -42.8L-41.6 -56.8Q-35.9 -65.7 -27.2 -66.6ZM-13.6 112.0Q-4.9 111.1 -0.4 127.9L6.7 154.3Q11.2 171.1 5.5 176.3L-3.5 184.5Q-9.2 189.8 -22.4 182.9L-43.2 172.1Q-56.4 165.3 -56.4 159.9L-56.2 151.5Q-56.2 146.1 -50.5 137.2L-41.6 123.2Q-35.9 114.3 -27.2 113.4ZM166.4 -68.0Q175.1 -68.9 179.6 -52.1L186.7 -25.7Q191.2 -8.9 185.5 -3.7L176.5 4.5Q170.8 9.8 157.6 2.9L136.8 -7.9Q123.6 -14.7 123.6 -20.1L123.8 -28.5Q123.8 -33.9 129.5 -42.8L138.4 -56.8Q144.1 -65.7 152.8 -66.6ZM166.4 112.0Q175.1 111.1 179.6 127.9L186.7 154.3Q191.2 171.1 185.5 176.3L176.5 184.5Q170.8 189.8 157.6 182.9L136.8 172.1Q123.6 165.3 123.6 159.9L123.8 151.5Q123.8 146.1 129.5 137.2L138.4 123.2Q144.1 114.3 152.8 113.4Z"/%3E%3C/svg%3E');
|
||||
|
||||
--sidebar: #FFFFFF;
|
||||
--sidebar-foreground: #0F172A;
|
||||
--sidebar-primary: #2563EB;
|
||||
@@ -190,16 +185,6 @@ h4 {
|
||||
}
|
||||
|
||||
/* every figure, ID and percentage
|
||||
aligns on tabular numerals. */
|
||||
/* The giraffe-spot pattern as a field: the element's background is the patch colour, masked to the
|
||||
coat shape, so whatever is behind shows through the gaps. Recolour with --giraffe-patch, rescale
|
||||
with --giraffe-size. Decorative only; under text only as a faint wash whose contrast is checked. */
|
||||
.giraffe-spots {
|
||||
background-color: var(--giraffe-patch, var(--accent));
|
||||
-webkit-mask-image: var(--giraffe-motif);
|
||||
mask-image: var(--giraffe-motif);
|
||||
-webkit-mask-size: var(--giraffe-size, var(--giraffe-tile)) var(--giraffe-size, var(--giraffe-tile));
|
||||
mask-size: var(--giraffe-size, var(--giraffe-tile)) var(--giraffe-size, var(--giraffe-tile));
|
||||
}
|
||||
|
||||
.tabular {
|
||||
@@ -248,13 +233,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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ getInvite: vi.fn(), submitInvite: vi.fn(), inviteCheckin: vi.fn() }));
|
||||
vi.mock("@/app/lib/services/publicInvite", () => mocks);
|
||||
vi.mock("next/navigation", () => ({ useParams: () => ({ token: "inv1" }) }));
|
||||
|
||||
import { ApiError } from "@/app/lib/clientApi";
|
||||
import InvitePage from "./page";
|
||||
|
||||
const info = {
|
||||
eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC", companyName: "INS",
|
||||
notice: { id: 7, textEn: "We keep your data safe.", textMs: "Data anda selamat." }, interests: [],
|
||||
guest: { name: "Aini Binti", mobile: "", email: "aini@b.co", companyName: "Acme" }, state: "OPEN",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.getInvite.mockReset().mockResolvedValue(info);
|
||||
mocks.submitInvite.mockReset().mockResolvedValue({});
|
||||
mocks.inviteCheckin.mockReset().mockResolvedValue({ firstName: "Aini" });
|
||||
});
|
||||
|
||||
const h1s = () => screen.getAllByRole("heading", { level: 1 });
|
||||
|
||||
describe("/i visitor card", () => {
|
||||
it("form shows the invited title as the only h1 with the event header and notice before consent", async () => {
|
||||
render(<InvitePage />);
|
||||
await screen.findByLabelText("Your name");
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["You're invited to Expo 2026"]);
|
||||
expect(screen.getByText("INS", { selector: "p" })).toBeTruthy();
|
||||
expect(screen.getByText("2026-12-01 - 2026-12-02")).toBeTruthy();
|
||||
expect(screen.getByText("KLCC")).toBeTruthy();
|
||||
const notice = screen.getByText("We keep your data safe.");
|
||||
expect(notice.compareDocumentPosition(screen.getByLabelText(/I agree to INS/)) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(document.querySelectorAll("main").length).toBe(1);
|
||||
});
|
||||
|
||||
it("thank you shows an icon and heading under one h1", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<InvitePage />);
|
||||
await user.click(await screen.findByRole("button", { name: "Register" }));
|
||||
const s = await screen.findByRole("status");
|
||||
expect(s.querySelector("svg")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 2 }).textContent).toContain("Thank you");
|
||||
expect(h1s().length).toBe(1);
|
||||
});
|
||||
|
||||
it("loading icon spins", () => {
|
||||
mocks.getInvite.mockReturnValue(new Promise(() => {}));
|
||||
render(<InvitePage />);
|
||||
expect(screen.getByRole("status").querySelector("svg")).toHaveClass("motion-safe:animate-spin");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["REGISTERED", "You're already registered for Expo 2026."],
|
||||
["CHECKED_IN", "You're already checked in to Expo 2026."],
|
||||
])("%s invite shows an icon and heading under one h1", async (state, heading) => {
|
||||
mocks.getInvite.mockResolvedValue({ ...info, state });
|
||||
render(<InvitePage />);
|
||||
const s = await screen.findByRole("status");
|
||||
expect(s.querySelector("svg")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 2 }).textContent).toBe(heading);
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
});
|
||||
|
||||
it("check-in day offers the button and welcomes with an icon under one h1", async () => {
|
||||
const user = userEvent.setup();
|
||||
mocks.getInvite.mockResolvedValue({ ...info, state: "CHECKIN" });
|
||||
render(<InvitePage />);
|
||||
await user.click(await screen.findByRole("button", { name: "Check in" }));
|
||||
const s = await screen.findByRole("status");
|
||||
expect(s.querySelector("svg")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 2 }).textContent).toBe("Welcome, Aini. You're checked in.");
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
});
|
||||
|
||||
it("inactive and error have an alert icon, one h1 and no event details", async () => {
|
||||
mocks.getInvite.mockRejectedValue(new ApiError("x", 404, { code: "INVITE_INACTIVE" }));
|
||||
const { unmount } = render(<InvitePage />);
|
||||
expect((await screen.findByRole("alert")).querySelector("svg")).toBeTruthy();
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["This invitation is no longer active."]);
|
||||
expect(screen.queryByText("Expo 2026")).toBeNull();
|
||||
unmount();
|
||||
mocks.getInvite.mockRejectedValue(new ApiError("x", 500, {}));
|
||||
render(<InvitePage />);
|
||||
await screen.findByRole("alert");
|
||||
expect(h1s().length).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -33,7 +33,10 @@ describe("/i/[token] invite page", () => {
|
||||
expect((screen.getByLabelText("Company") as HTMLInputElement).value).toBe("Acme");
|
||||
expect(screen.getByText("Data anda selamat.")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("You're invited to Expo 2026");
|
||||
expect(screen.getByText(/INS \| 2026-12-01 - 2026-12-02 \| KLCC/)).toBeTruthy();
|
||||
// refine-visitor-pages-and-shell: the card header shows company, dates and location on their own lines.
|
||||
expect(screen.getByText("INS")).toBeTruthy();
|
||||
expect(screen.getByText("2026-12-01 - 2026-12-02")).toBeTruthy();
|
||||
expect(screen.getByText("KLCC")).toBeTruthy();
|
||||
expect(screen.getByLabelText(/I agree to INS using my details/).getAttribute("aria-checked")).toBe("false");
|
||||
expect(mocks.getInvite).toHaveBeenCalledWith("inv1");
|
||||
});
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { AlertCircle, CheckCircle2, Loader2 } from "lucide-react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { VisitorCard, VisitorState } from "@/app/components/registration/VisitorCard";
|
||||
import { RegistrationForm, apiData, failMessage } from "@/app/components/registration/RegistrationForm";
|
||||
import { getInvite, inviteCheckin, submitInvite, type InviteInfo } from "@/app/lib/services/publicInvite";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
@@ -46,18 +48,19 @@ export default function InvitePage() {
|
||||
}
|
||||
|
||||
const event = info?.eventName ?? "";
|
||||
const done = (text: string) => <VisitorState icon={CheckCircle2} heading={text} role="status" />;
|
||||
if (phase === "loading") return <VisitorCard><VisitorState h1 icon={Loader2} iconClassName="motion-safe:animate-spin" heading={t("UiLoading")} role="status" /></VisitorCard>;
|
||||
if (phase === "inactive") return <VisitorCard><VisitorState h1 icon={AlertCircle} heading={t("InviteInactive")} role="alert" /></VisitorCard>;
|
||||
if (phase === "error" || !info) return <VisitorCard><VisitorState h1 icon={AlertCircle} heading={error ?? t("RegLoadFailed")} role="alert" tone="error" /></VisitorCard>;
|
||||
|
||||
let body;
|
||||
if (phase === "loading") body = <p role="status">{t("UiLoading")}</p>;
|
||||
else if (phase === "inactive") body = <p role="alert">{t("InviteInactive")}</p>;
|
||||
else if (phase === "error" || !info) body = <p role="alert" className="text-sm text-destructive">{error}</p>;
|
||||
else if (welcome !== null) body = <p role="status" className="text-lg font-medium">{welcome ? t("InviteWelcome", { name: welcome }) : t("InviteWelcomeAnon")}</p>;
|
||||
else if (info.state === "CHECKED_IN") body = <p role="status" className="text-lg font-medium">{t("InviteCheckedIn", { event })}</p>;
|
||||
else if (thanks) body = <p role="status" className="text-lg font-medium">{t("RegThanks", { event })}</p>;
|
||||
else if (info.state === "REGISTERED") body = <p role="status" className="text-lg font-medium">{t("InviteRegistered", { event })}</p>;
|
||||
if (welcome !== null) body = done(welcome ? t("InviteWelcome", { name: welcome }) : t("InviteWelcomeAnon"));
|
||||
else if (info.state === "CHECKED_IN") body = done(t("InviteCheckedIn", { event }));
|
||||
else if (thanks) body = done(t("RegThanks", { event }));
|
||||
else if (info.state === "REGISTERED") body = done(t("InviteRegistered", { event }));
|
||||
else if (info.state === "CHECKIN") {
|
||||
body = (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-2xl font-semibold">{event}</h1>
|
||||
{error && <p role="alert" className="text-sm text-destructive">{error}</p>}
|
||||
<Button className="h-11 w-full" onClick={checkIn}>{t("InviteCheckin")}</Button>
|
||||
</div>
|
||||
@@ -66,7 +69,6 @@ export default function InvitePage() {
|
||||
body = (
|
||||
<RegistrationForm
|
||||
info={info}
|
||||
title={t("InviteTitle", { event })}
|
||||
tooManyKey="InviteTooMany"
|
||||
initial={{ name: info.guest.name ?? "", mobile: info.guest.mobile ?? "", email: info.guest.email ?? "", companyName: info.guest.companyName ?? "" }}
|
||||
submit={(b) => submitInvite(token, b)}
|
||||
@@ -76,5 +78,5 @@ export default function InvitePage() {
|
||||
);
|
||||
}
|
||||
|
||||
return <main className="mx-auto w-full max-w-md px-4 py-6">{body}</main>;
|
||||
return <VisitorCard event={info} title={info.state === "OPEN" && welcome === null && !thanks ? t("InviteTitle", { event }) : undefined}>{body}</VisitorCard>;
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,6 +86,7 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
|
||||
HeaderSwitchToDark: "Switch to dark theme",
|
||||
LocaleSwitcherChange: "Change language",
|
||||
SidebarMainNav: "Main",
|
||||
SidebarAdministration: "Administration",
|
||||
UiBreadcrumb: "breadcrumb",
|
||||
UiMore: "More",
|
||||
UiColumns: "Columns",
|
||||
@@ -478,6 +479,7 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
|
||||
RegName: "Your name",
|
||||
RegMobile: "Mobile number",
|
||||
RegEmail: "Email",
|
||||
RegContactHint: "Mobile or email is required",
|
||||
RegCompany: "Company",
|
||||
RegJobTitle: "Job title",
|
||||
RegInterests: "Interests (optional)",
|
||||
|
||||
@@ -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.
|
||||
<div className="grid min-h-svh bg-background lg:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]">
|
||||
<aside className="relative isolate hidden flex-col justify-between gap-10 overflow-hidden bg-accent p-12 text-accent-foreground lg:flex">
|
||||
{/* Gold ground, brown coat at 14% (owner request: lighter, colours reversed). Dark text still
|
||||
clears AA on a patch: --accent-foreground ≈ 7.0:1 (8.4:1 on plain gold). In dark mode
|
||||
--primary turns light gold, so the coat and the chips switch to --accent-foreground, which
|
||||
stays dark brown; the logo inverts to white on its dark plate. */}
|
||||
<span aria-hidden="true" className="giraffe-spots absolute inset-0 -z-10 opacity-[0.14] [--giraffe-patch:var(--primary)] dark:[--giraffe-patch:var(--accent-foreground)]" />
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="rounded-full bg-primary px-3 py-1 text-sm font-semibold text-primary-foreground dark:bg-accent-foreground dark:text-accent">
|
||||
{t("BackOfficeLabel")}
|
||||
</span>
|
||||
<AuthFrame>
|
||||
<div className="space-y-2">
|
||||
<h1 className="font-heading text-3xl font-semibold tracking-tight">{t("BackOfficeTitle")}</h1>
|
||||
<p className="text-muted-foreground">{t("BackOfficeSubtitle")}</p>
|
||||
</div>
|
||||
|
||||
{error ? <ErrorState message={t(error)} /> : elsewhere && <ErrorState message={t("SignedInElsewhere")} />}
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-5" noValidate>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="company">{t("Company")}</Label>
|
||||
<Input
|
||||
id="company"
|
||||
type="text"
|
||||
autoComplete="organization"
|
||||
placeholder={t("CompanyBlankForSuper")}
|
||||
value={company}
|
||||
onChange={(e) => setCompany(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="max-w-md space-y-8">
|
||||
<p className="font-heading text-4xl leading-tight font-semibold tracking-tight text-balance">
|
||||
{t("BackOfficePanelTitle")}
|
||||
</p>
|
||||
<ul className="space-y-4">
|
||||
{PANEL_POINTS.map(({ icon: PointIcon, code }) => (
|
||||
<li key={code} className="flex items-center gap-3 text-base font-medium">
|
||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground dark:bg-accent-foreground dark:text-accent">
|
||||
<PointIcon aria-hidden="true" className="size-5" />
|
||||
</span>
|
||||
{t(code)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="username">{t("Username")}</Label>
|
||||
<Input
|
||||
id="username"
|
||||
type="text"
|
||||
autoComplete="username"
|
||||
required
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<span aria-hidden="true" />
|
||||
</aside>
|
||||
|
||||
<main className="flex flex-col items-center justify-center gap-8 p-6 sm:p-10">
|
||||
<div className="w-full max-w-sm space-y-8">
|
||||
{/* Below lg a short brand band stands in for the panel: same brown, coat and logo. */}
|
||||
<div className="relative isolate flex items-center gap-3 overflow-hidden rounded-2xl bg-accent p-4 lg:hidden">
|
||||
<span aria-hidden="true" className="giraffe-spots absolute inset-0 -z-10 opacity-[0.14] [--giraffe-patch:var(--primary)] dark:[--giraffe-patch:var(--accent-foreground)]" />
|
||||
<span className="rounded-full bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground dark:bg-accent-foreground dark:text-accent">
|
||||
{t("BackOfficeLabel")}
|
||||
</span>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="password">{t("Password")}</Label>
|
||||
<div className="relative">
|
||||
<Input
|
||||
id="password"
|
||||
type={showPassword ? "text" : "password"}
|
||||
autoComplete="current-password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card pr-11"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword((v) => !v)}
|
||||
aria-label={showPassword ? t("LoginHidePassword") : t("LoginShowPassword")}
|
||||
className="absolute top-1/2 right-1 flex size-9 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff aria-hidden="true" className="size-4" />
|
||||
) : (
|
||||
<Eye aria-hidden="true" className="size-4" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<h1 className="font-heading text-3xl font-semibold tracking-tight">{t("BackOfficeTitle")}</h1>
|
||||
<p className="text-muted-foreground">{t("BackOfficeSubtitle")}</p>
|
||||
</div>
|
||||
|
||||
{error ? <ErrorState message={t(error)} /> : elsewhere && <ErrorState message={t("SignedInElsewhere")} />}
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-5" noValidate>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="company">{t("Company")}</Label>
|
||||
<Input
|
||||
id="company"
|
||||
type="text"
|
||||
autoComplete="organization"
|
||||
placeholder={t("CompanyBlankForSuper")}
|
||||
value={company}
|
||||
onChange={(e) => setCompany(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="username">{t("Username")}</Label>
|
||||
<Input
|
||||
id="username"
|
||||
type="text"
|
||||
autoComplete="username"
|
||||
required
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="password">{t("Password")}</Label>
|
||||
<div className="relative">
|
||||
<Input
|
||||
id="password"
|
||||
type={showPassword ? "text" : "password"}
|
||||
autoComplete="current-password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card pr-11"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword((v) => !v)}
|
||||
aria-label={showPassword ? t("LoginHidePassword") : t("LoginShowPassword")}
|
||||
className="absolute top-1/2 right-1 flex size-9 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff aria-hidden="true" className="size-4" />
|
||||
) : (
|
||||
<Eye aria-hidden="true" className="size-4" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Link href="/forgot-password" className="block text-sm text-muted-foreground underline-offset-4 hover:underline">
|
||||
{t("ForgotLink")}
|
||||
</Link>
|
||||
|
||||
<Button type="submit" className="h-11 w-full text-base shadow-md" disabled={submitting}>
|
||||
{submitting && <Loader2 aria-hidden="true" className="size-4 animate-spin" />}
|
||||
{t("LogIn")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<PoweredBy />
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<Link href="/forgot-password" className="block text-sm text-muted-foreground underline-offset-4 hover:underline">
|
||||
{t("ForgotLink")}
|
||||
</Link>
|
||||
|
||||
<Button type="submit" className="h-11 w-full text-base shadow-md" disabled={submitting}>
|
||||
{submitting && <Loader2 aria-hidden="true" className="size-4 animate-spin" />}
|
||||
{t("LogIn")}
|
||||
</Button>
|
||||
</form>
|
||||
</AuthFrame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen, within } from "@testing-library/react";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ getMyLinks: vi.fn() }));
|
||||
vi.mock("@/app/lib/services/adminRegistration", () => mocks);
|
||||
vi.mock("qrcode.react", () => ({
|
||||
QRCodeSVG: ({ value }: { value: string }) => <svg data-testid="qr-svg" data-value={value} />,
|
||||
QRCodeCanvas: () => <canvas />,
|
||||
}));
|
||||
|
||||
import MyQrPage from "./page";
|
||||
|
||||
const LINK = { eventUuid: "u1", eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC", token: "t1", enabled: true };
|
||||
beforeEach(() => mocks.getMyLinks.mockReset());
|
||||
|
||||
describe("My QR codes as cards", () => {
|
||||
it("shows the event name once, as the card title, with dates and location under it", async () => {
|
||||
mocks.getMyLinks.mockResolvedValue([LINK]);
|
||||
const { container } = render(<MyQrPage />);
|
||||
await screen.findByText("Expo 2026");
|
||||
expect(screen.getAllByText("Expo 2026")).toHaveLength(1);
|
||||
const card = container.querySelector("[data-slot=card]") as HTMLElement;
|
||||
expect(within(card).getByText("Expo 2026").closest("[data-slot=card-title]")).toBeTruthy();
|
||||
expect(within(card).getByText("2026-12-01 - 2026-12-02")).toBeTruthy();
|
||||
expect(within(card).getByText("KLCC")).toBeTruthy();
|
||||
expect(within(card).getByTestId("qr-svg")).toBeTruthy();
|
||||
expect(within(card).getByRole("button", { name: "Share" })).toBeTruthy();
|
||||
});
|
||||
|
||||
it("puts the Switched off badge in the card header", async () => {
|
||||
mocks.getMyLinks.mockResolvedValue([{ ...LINK, enabled: false }]);
|
||||
const { container } = render(<MyQrPage />);
|
||||
const badge = await screen.findByText("Switched off");
|
||||
expect(badge.closest("[data-slot=card-header]")).toBeTruthy();
|
||||
expect(container.querySelectorAll("[data-slot=card]")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("stacks the QR above its buttons, so a narrow card never overflows", async () => {
|
||||
mocks.getMyLinks.mockResolvedValue([LINK]);
|
||||
const { container } = render(<MyQrPage />);
|
||||
await screen.findByText("Expo 2026");
|
||||
const item = container.querySelector("[data-slot=card-content] > div")!;
|
||||
expect(item).toHaveClass("sm:flex-col");
|
||||
expect(item).not.toHaveClass("sm:flex-row");
|
||||
});
|
||||
});
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { PageHeader } from "@/app/components/ui/page-header";
|
||||
import { CalendarDays, MapPin } from "lucide-react";
|
||||
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/app/components/ui/card";
|
||||
import { Badge } from "@/app/components/ui/badge";
|
||||
import { EmptyState, ErrorState } from "@/app/components/ui/states";
|
||||
import { QrCodeItem } from "@/app/components/registration/QrCodeItem";
|
||||
@@ -23,15 +25,31 @@ export default function MyQrPage() {
|
||||
<PageHeader title={t("QrMyTitle")} />
|
||||
{error && <ErrorState message={error} />}
|
||||
{links?.length === 0 && <EmptyState title={t("QrMyNone")} />}
|
||||
<div className="space-y-3">
|
||||
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
{links?.map((l) => (
|
||||
<div key={l.token} className="space-y-1">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{l.startDate} - {l.endDate} | {l.location}
|
||||
</p>
|
||||
{!l.enabled && <Badge variant="warning">{t("QrSwitchedOff")}</Badge>}
|
||||
<QrCodeItem label={l.eventName} eventName={l.eventName} token={l.token} enabled={l.enabled} personal />
|
||||
</div>
|
||||
<Card key={l.token}>
|
||||
<CardHeader>
|
||||
<CardTitle>{l.eventName}</CardTitle>
|
||||
{!l.enabled && (
|
||||
<CardAction>
|
||||
<Badge variant="warning">{t("QrSwitchedOff")}</Badge>
|
||||
</CardAction>
|
||||
)}
|
||||
<CardDescription className="space-y-1">
|
||||
<p className="flex items-center gap-2">
|
||||
<CalendarDays aria-hidden="true" className="size-4 shrink-0" />
|
||||
<span>{l.startDate} - {l.endDate}</span>
|
||||
</p>
|
||||
<p className="flex items-center gap-2">
|
||||
<MapPin aria-hidden="true" className="size-4 shrink-0" />
|
||||
<span>{l.location}</span>
|
||||
</p>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<QrCodeItem eventName={l.eventName} token={l.token} enabled={l.enabled} personal className="border-0 p-0 sm:flex-col sm:items-start" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ getRegistration: vi.fn(), submitRegistration: vi.fn() }));
|
||||
vi.mock("@/app/lib/services/publicRegistration", () => mocks);
|
||||
vi.mock("next/navigation", () => ({ useParams: () => ({ token: "tok1" }) }));
|
||||
|
||||
import { ApiError } from "@/app/lib/clientApi";
|
||||
import RegisterPage from "./page";
|
||||
|
||||
const info = {
|
||||
eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC", companyName: "INS",
|
||||
notice: { id: 7, textEn: "We keep your data safe.", textMs: "Data anda selamat." }, interests: [],
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.getRegistration.mockReset().mockResolvedValue(info);
|
||||
mocks.submitRegistration.mockReset().mockResolvedValue({});
|
||||
});
|
||||
|
||||
const h1s = () => screen.getAllByRole("heading", { level: 1 });
|
||||
|
||||
describe("/r visitor card", () => {
|
||||
it("shows the company label, one h1, dates and location, with the notice before consent", async () => {
|
||||
render(<RegisterPage />);
|
||||
await screen.findByLabelText("Your name");
|
||||
expect(screen.getByText("INS", { selector: "p" })).toBeTruthy();
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
expect(screen.getByText("2026-12-01 - 2026-12-02")).toBeTruthy();
|
||||
expect(screen.getByText("KLCC")).toBeTruthy();
|
||||
const notice = screen.getByText("We keep your data safe.");
|
||||
const consent = screen.getByLabelText(/I agree to INS/);
|
||||
expect(notice.compareDocumentPosition(consent) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(document.querySelectorAll("main").length).toBe(1);
|
||||
});
|
||||
|
||||
it("loading has a status and its heading as the only h1", () => {
|
||||
render(<RegisterPage />);
|
||||
expect(screen.getByRole("status")).toBeTruthy();
|
||||
expect(h1s().length).toBe(1);
|
||||
expect(document.querySelectorAll("main").length).toBe(1);
|
||||
});
|
||||
|
||||
it("loading icon spins", () => {
|
||||
mocks.getRegistration.mockReturnValue(new Promise(() => {}));
|
||||
render(<RegisterPage />);
|
||||
expect(screen.getByRole("status").querySelector("svg")).toHaveClass("motion-safe:animate-spin");
|
||||
});
|
||||
|
||||
it("inactive shows an alert heading as the only h1, no event details", async () => {
|
||||
mocks.getRegistration.mockRejectedValue(new ApiError("x", 404, { code: "CODE_INACTIVE" }));
|
||||
render(<RegisterPage />);
|
||||
await screen.findByRole("alert");
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["This code is no longer active."]);
|
||||
expect(screen.queryByText("Expo 2026")).toBeNull();
|
||||
expect(document.querySelector("svg")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("load error is an alert with one h1", async () => {
|
||||
mocks.getRegistration.mockRejectedValue(new ApiError("x", 429, { code: "TOO_MANY" }));
|
||||
render(<RegisterPage />);
|
||||
await screen.findByRole("alert");
|
||||
expect(h1s().length).toBe(1);
|
||||
});
|
||||
|
||||
it("thank you keeps the event header with an icon, one h1 and the register-another button", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<RegisterPage />);
|
||||
await user.type(await screen.findByLabelText("Your name"), "Aini");
|
||||
await user.type(screen.getByLabelText("Email"), "a@b.co");
|
||||
await user.click(screen.getByRole("button", { name: "Register" }));
|
||||
const done = await screen.findByRole("status");
|
||||
expect(done.textContent).toContain("Thank you, you're registered for Expo 2026");
|
||||
expect(done.querySelector("svg")).toBeTruthy();
|
||||
expect(screen.getByRole("heading", { level: 2 }).textContent).toContain("Thank you");
|
||||
expect(h1s().map((h) => h.textContent)).toEqual(["Expo 2026"]);
|
||||
expect(screen.getByRole("button", { name: "Register another person" })).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { AlertCircle, CheckCircle2, Loader2 } from "lucide-react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { VisitorCard, VisitorState } from "@/app/components/registration/VisitorCard";
|
||||
import { RegistrationForm, apiData } from "@/app/components/registration/RegistrationForm";
|
||||
import { getRegistration, submitRegistration, type RegistrationInfo } from "@/app/lib/services/publicRegistration";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
@@ -32,19 +34,16 @@ export default function RegisterPage() {
|
||||
});
|
||||
}, [token, t]);
|
||||
|
||||
let body;
|
||||
if (phase === "loading") body = <p role="status">{t("UiLoading")}</p>;
|
||||
else if (phase === "inactive") body = <p role="alert">{t("RegInactive")}</p>;
|
||||
else if (phase === "done") {
|
||||
body = (
|
||||
<div className="space-y-4">
|
||||
<p role="status" className="text-lg font-medium">{t("RegThanks", { event: info?.eventName ?? "" })}</p>
|
||||
<Button className="h-11" onClick={() => setPhase("form")}>{t("RegAnother")}</Button>
|
||||
</div>
|
||||
);
|
||||
} else if (info) {
|
||||
body = <RegistrationForm info={info} submit={(b) => submitRegistration(token, b)} onDone={() => setPhase("done")} onInactive={() => setPhase("inactive")} />;
|
||||
} else body = <p role="alert" className="text-sm text-destructive">{loadError}</p>;
|
||||
|
||||
return <main className="mx-auto w-full max-w-md px-4 py-6">{body}</main>;
|
||||
if (phase === "loading") return <VisitorCard><VisitorState h1 icon={Loader2} iconClassName="motion-safe:animate-spin" heading={t("UiLoading")} role="status" /></VisitorCard>;
|
||||
if (phase === "inactive") return <VisitorCard><VisitorState h1 icon={AlertCircle} heading={t("RegInactive")} role="alert" /></VisitorCard>;
|
||||
if (!info) return <VisitorCard><VisitorState h1 icon={AlertCircle} heading={loadError ?? t("RegLoadFailed")} role="alert" tone="error" /></VisitorCard>;
|
||||
return (
|
||||
<VisitorCard event={info}>
|
||||
{phase === "done" ? (
|
||||
<VisitorState icon={CheckCircle2} heading={t("RegThanks", { event: info.eventName })} role="status" action={<Button className="h-11" onClick={() => setPhase("form")}>{t("RegAnother")}</Button>} />
|
||||
) : (
|
||||
<RegistrationForm info={info} submit={(b) => submitRegistration(token, b)} onDone={() => setPhase("done")} onInactive={() => setPhase("inactive")} />
|
||||
)}
|
||||
</VisitorCard>
|
||||
);
|
||||
}
|
||||
@@ -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(<ResetPasswordPage />);
|
||||
expect(screen.getByText("Everything behind Co-Lite, in one place.")).toBeInTheDocument();
|
||||
expect(container.querySelector(".giraffe-spots")).toBeNull();
|
||||
expect(screen.getByRole("link", { name: "Containerverse Sdn. Bhd." })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Set your password" })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -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 (
|
||||
<div className="flex min-h-svh flex-col items-center justify-center gap-4 bg-background p-4">
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader className="gap-2">
|
||||
<CardTitle className="text-lg">{t("ResetTitle")}</CardTitle>
|
||||
<CardDescription>{t("ResetChooseIntro")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{error && <ErrorState message={t(error)} className="mb-4" />}
|
||||
<form onSubmit={handleSubmit} className="space-y-4" noValidate>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="newPassword">{t("ResetNewPassword")}</Label>
|
||||
<Input
|
||||
id="newPassword"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={newPassword}
|
||||
onChange={(e) => setNewPassword(e.target.value)}
|
||||
disabled={submitting}
|
||||
aria-describedby="newPasswordRules"
|
||||
/>
|
||||
<p id="newPasswordRules" className="text-sm text-muted-foreground">{t("AdminPasswordHint")}</p>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="confirmPassword">{t("ResetConfirmPassword")}</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
disabled={submitting}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" className="w-full" disabled={submitting}>
|
||||
{submitting && <Loader2 aria-hidden="true" className="size-4 animate-spin" />}
|
||||
{t("ResetSubmit")}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div className="text-center">
|
||||
<PoweredBy />
|
||||
<AuthFrame>
|
||||
<div className="space-y-2">
|
||||
<h1 className="font-heading text-3xl font-semibold tracking-tight">{t("ResetTitle")}</h1>
|
||||
<p className="text-muted-foreground">{t("ResetChooseIntro")}</p>
|
||||
</div>
|
||||
</div>
|
||||
{error && <ErrorState message={t(error)} />}
|
||||
<form onSubmit={handleSubmit} className="space-y-5" noValidate>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="newPassword">{t("ResetNewPassword")}</Label>
|
||||
<Input
|
||||
id="newPassword"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={newPassword}
|
||||
onChange={(e) => setNewPassword(e.target.value)}
|
||||
disabled={submitting}
|
||||
aria-describedby="newPasswordRules"
|
||||
className="h-11 bg-card"
|
||||
/>
|
||||
<p id="newPasswordRules" className="text-sm text-muted-foreground">{t("AdminPasswordHint")}</p>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="confirmPassword">{t("ResetConfirmPassword")}</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
disabled={submitting}
|
||||
className="h-11 bg-card"
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" className="h-11 w-full text-base shadow-md" disabled={submitting}>
|
||||
{submitting && <Loader2 aria-hidden="true" className="size-4 animate-spin" />}
|
||||
{t("ResetSubmit")}
|
||||
</Button>
|
||||
</form>
|
||||
</AuthFrame>
|
||||
);
|
||||
}
|
||||
@@ -20,7 +20,6 @@ const FILES = globSync("app/**/*.tsx", { cwd: ROOT }).filter((f) => !/\.test\.ts
|
||||
const PROJECT_CLASSES = new Set([
|
||||
"tabular",
|
||||
"scrollable",
|
||||
"giraffe-spots",
|
||||
"print-handover",
|
||||
"print-picklist",
|
||||
"admin-calendar",
|
||||
|
||||
Reference in new issue
Block a user