Compare commits

...
27 changed files with 850 additions and 192 deletions

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`.
@@ -0,0 +1,60 @@
## ADDED Requirements
### Requirement: Visitor Page Look
The public visitor pages (registration, invitation and check-in) SHALL show their content in one card on the page ground. The card SHALL be headed by the company name as a small label, the event name as the main heading, and the event dates and location. The pages SHALL use only the portal's theme tokens and SHALL NOT show a per-company logo or colour. The privacy notice SHALL be shown in full in English and Bahasa Malaysia as smaller, muted text that keeps at least 4.5:1 contrast.
#### Scenario: Visitor opens a registration code
- **WHEN** a visitor opens the registration page of an INS event
- **THEN** the card shows "INS" as a label above the event name, then the event dates and location
- **AND** the full privacy notice appears in both languages above the consent box
#### Scenario: Visitor needs a contact
- **WHEN** a visitor sees the mobile field on the registration form
- **THEN** a hint under it says that a mobile number or an email is required
#### Scenario: Visitor reaches an end state
- **WHEN** a visitor's registration is accepted, or the code is inactive, or check-in has not opened yet
- **THEN** the same card shows an icon and a heading for that state
### Requirement: Header Trail Without Repeats
The admin header SHALL NOT repeat the page title. On a page reached directly from the sidebar it SHALL show no trail. On a page below one, it SHALL show the parent page as a link back.
#### Scenario: Top-level page
- **WHEN** an admin opens the Events list
- **THEN** the header shows no trail text
#### Scenario: Sub-page
- **WHEN** an admin opens the new event page
- **THEN** the header shows "Events" as a link to the Events list
### Requirement: Table Scroll Cue
A table wider than its container SHALL show a fade on each edge where more columns can be scrolled into view. The fade SHALL disappear at that end of the scroll.
#### Scenario: Users list on a phone
- **WHEN** an admin opens the Users list at 360 px wide
- **THEN** a fade shows on the right edge of the table
- **AND** after scrolling to the last column the right fade is gone
### Requirement: Sidebar Sections
The sidebar SHALL list the work pages first, then an "Administration" section for Users, Roles, Emails, Login security, Audit log and Companies. The section SHALL be marked by a divider and a small muted label, and only the divider SHALL show in the collapsed rail. A section with no item the admin may open SHALL NOT show.
#### Scenario: Super admin sidebar
- **WHEN** a super admin opens the portal
- **THEN** Dashboard, Events, Event leads, Interests and Leads are listed above the "Administration" label
- **AND** Users, Roles, Emails, Login security, Audit log and Companies are listed below it
#### Scenario: Staff without admin pages
- **WHEN** a staff user who can open only Events and Event leads opens the portal
- **THEN** the sidebar shows no "Administration" label
@@ -0,0 +1,48 @@
# Tasks: refine-visitor-pages-and-shell
Design: `design.md` and `docs/superpowers/specs/2026-12-01-visual-followup-design.md`. Portal only. Every task is TDD, followed by the review gate. Tasks run serially in this order, because several of them touch `globals.css` and the i18n messages.
Verify for every task: `cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint`. Check the vitest exit code: an unhandled error fails the run even when every test passes.
## 1. Shell
- [x] 1.1 Header trail without repeats: `Breadcrumbs` shows nothing on a page whose URL is the matched leaf's own URL, and shows the leaf as a link on a sub-page.
- Depends on: none
- Scope: `solvway-admin-portal/app/components/app/Breadcrumbs*`
- [ ] 1.2 Sidebar sections: an `ADMIN_MODULES` list in `aclSidebar.ts`, the work and Administration split in `Sidebar` (full sidebar and drawer: divider and label; rail: divider only; no section when it has no items), and the "Administration" label in `defaultMessages.ts`.
- Depends on: 1.1
- Scope: `solvway-admin-portal/app/lib/aclSidebar*`, `solvway-admin-portal/app/components/app/Sidebar*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts`
- [ ] 1.3 Table scroll cue: a scroll-shadow utility in `globals.css` applied to the `table-container`, with colours from tokens only (the design-tokens test stays green).
- Depends on: 1.2
- Scope: `solvway-admin-portal/app/components/ui/table*`, `solvway-admin-portal/app/globals.css`, `solvway-admin-portal/app/globals.test.ts`
## 2. Visitor pages
- [ ] 2.1 `VisitorCard` (ground, card, event header with the company label, the dates and location with icons, footer) and `VisitorState` (icon, heading, text, action). `RegistrationForm` drops its header, adds the "Mobile or email is required" hint (new key in `defaultMessages.ts`), sets the notice as fine print, and aligns the consent row.
- Depends on: 1.3
- Scope: `solvway-admin-portal/app/components/registration/**` except `QrCodeItem*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts`
- [ ] 2.2 `/r`, `/i` and `/c` render every state inside `VisitorCard`, with `VisitorState` for loading, inactive, error, too many, not yet, ended, thank you, welcome and checked in. Existing behaviour and text stay the same.
- Depends on: 2.1
- Scope: `solvway-admin-portal/app/r/**`, `solvway-admin-portal/app/i/**`, `solvway-admin-portal/app/c/**`
## 3. Staff screens
- [ ] 3.1 My QR codes as cards: the event name as the title, dates and location, the switched-off badge in the card header, the QR and a wrapping button row.
- Depends on: 2.2
- Scope: `solvway-admin-portal/app/my-qr/**`, `solvway-admin-portal/app/components/registration/QrCodeItem*`
- [ ] 3.2 Reset password uses the login page's two-column frame. Remove the stale brown and gold comments in login.
- Depends on: 3.1
- Scope: `solvway-admin-portal/app/reset-password/**`, `solvway-admin-portal/app/login/**`
## 4. Release check
- [ ] 4.1 Playwright at 1280 and 360 px:
- `/r`, `/i` and `/c` in each reachable state;
- My QR, using a throwaway staff user that is reverted afterwards;
- login and reset password;
- the `/events` and `/events/new` header;
- the Users table at 360 px, before and after scrolling;
- the sidebar, full and rail.
Run the full portal verify. Record the result here.
- Depends on: 3.2
+132
View File
@@ -0,0 +1,132 @@
# event-attendance Specification
## Purpose
Record who actually came to an event, through self check-in at the venue and capture during the event days, and show an event's invited, registered, attended and walk-in numbers against its capacity.
## Requirements
### Requirement: Check-in code
Every event SHALL have one check-in code, a link of the form `/c/<token>` with an unguessable token. Users with `BO_EVENTS` SHALL see it on the event page as a QR image, with copy link and image download, for printing at the entrance.
#### Scenario: Code on the event page
- **WHEN** a user with `BO_EVENTS` opens `KL Expo`
- **THEN** the page shows the check-in QR with copy link and download
### Requirement: Check-in code availability
The check-in code SHALL work only on the event days (Malaysia, from the start date through the end date), while the event is enabled and its company has a privacy notice. Before the event it SHALL show "Check-in opens on <start date>". After the event it SHALL show "This event has ended." An unknown token or a disabled event SHALL show "This code is no longer active." None of these pages SHALL show any other event details.
#### Scenario: Before the event
- **GIVEN** `KL Expo` starts tomorrow
- **WHEN** a visitor opens its check-in link
- **THEN** the page says check-in opens on the start date
#### Scenario: On the day
- **GIVEN** today is the first day of `KL Expo`
- **WHEN** a visitor opens its check-in link
- **THEN** the page asks for a mobile or email
### Requirement: Self check-in of a known person
On the event days, the check-in page SHALL ask for one mobile or email, normalised as in staff capture. When the value matches a registered guest or an event lead of this event, that event lead SHALL be marked attended and the page SHALL show "Welcome, <first name>. You're checked in." Checking in again SHALL show the same welcome and change nothing. The page SHALL never show a guest's or lead's details other than the first name in the welcome.
#### Scenario: Registered guest checks in
- **GIVEN** `Tan Mei Ling` registered by invitation for `KL Expo`
- **WHEN** she enters `012-555 0101` on the check-in page on the event day
- **THEN** the page welcomes `Tan` and her event lead is attended
- **AND** the guest list shows her as Attended
### Requirement: Self check-in of a walk-in
When the value matches an invited guest who has not registered, or no one, the check-in page SHALL show the walk-in form, blank, with the privacy consent. An accepted submission SHALL capture the person with the QR registration rules and no salesperson, link a matching guest, mark the event lead attended, and show the checked-in page.
#### Scenario: Invited but not registered
- **GIVEN** `Lim Wei` is Invited but never registered
- **WHEN** he enters his mobile on the check-in page
- **THEN** a blank walk-in form with the consent is shown, not his details
- **AND** after he submits, he is Attended on the guest list
#### Scenario: Unknown walk-in
- **WHEN** a visitor whose mobile matches no one enters it and submits the walk-in form
- **THEN** an event lead is captured for them and marked attended
### Requirement: Check-in by invite link
On the event days, a registered guest's invite link SHALL show a "Check in" button instead of the registration form. Pressing it SHALL mark the guest's event lead attended and show the checked-in page.
#### Scenario: Check in from the email
- **GIVEN** `Tan Mei Ling` is registered and today is an event day
- **WHEN** she opens her invite link and presses Check in
- **THEN** she is Attended
### Requirement: Attendance at capture
Each event lead SHALL have an attended time. A staff capture, a walk-in code registration or a check-in-page capture made during the event days SHALL set it. A registration made before the event days SHALL NOT set it. Event leads that exist before this change SHALL count as not attended.
#### Scenario: Walk-in on the day
- **GIVEN** today is the first day of `KL Expo`
- **WHEN** staff capture a visitor at the booth
- **THEN** the event lead is attended
#### Scenario: Early QR registration
- **GIVEN** `KL Expo` starts next week
- **WHEN** a visitor registers through the event's walk-in code
- **THEN** the event lead is registered but not attended
### Requirement: Attendance in staff screens
Users who can edit event leads SHALL tick or untick Attended. The event leads listing SHALL show an Attended column and filter, and each event lead's source (Staff, QR, Invite).
#### Scenario: Staff untick
- **WHEN** staff untick Attended on an event lead linked to a guest
- **THEN** the guest list shows that guest as Registered
### Requirement: Guest linking across routes
A guest's status SHALL be derived from the event lead it is linked to: Registered when linked, Attended when that event lead is attended. Whenever a capture for an event creates or finds an event lead, by staff, walk-in code, invite or check-in, an unlinked guest of the same event SHALL be linked to it. The guest is matched by mobile first, else by email. The guest then SHALL count as a guest, not as a walk-in.
#### Scenario: Guest captured by staff
- **GIVEN** `Lim Wei` is Invited to `KL Expo`
- **WHEN** staff capture `Lim Wei` with his mobile at the booth on the event day
- **THEN** the guest list shows him as Attended
- **AND** he is not counted as a walk-in
### Requirement: Event attendance numbers
The event page SHALL show:
- invited: the number of guests, against the invitation cap when set;
- registered: guests linked to an event lead;
- attended: attended event leads;
- walk-ins: event leads not linked to a guest;
- total: registered guests plus walk-ins, against capacity when set.
The numbers SHALL agree with the guest list and the event leads listing. A total above capacity SHALL be shown, not hidden.
#### Scenario: Numbers
- **GIVEN** `KL Expo` has capacity 100, cap 50, 40 guests of whom 30 registered and 20 attended, plus 15 walk-ins of whom 15 attended
- **WHEN** an admin opens the event page
- **THEN** the event page shows invited 40 of 50, registered 30, attended 35, walk-ins 15, total 45 of 100
### Requirement: Check-in abuse limits
The check-in endpoints SHALL allow at most 300 lookups and submissions per IP per event per 10 minutes, answering "Too many attempts. Try again later." beyond that. The IP SHALL be determined as on the QR page. The check-in page SHALL NOT count against the QR page-load limit.
#### Scenario: Door rush
- **WHEN** 200 guests check in from the venue Wi-Fi within 10 minutes
- **THEN** none of them is refused as too many
+192
View File
@@ -0,0 +1,192 @@
# event-invitations Specification
## Purpose
Admins invite named guests to an event before it happens, each with a personal invite link, and see who registered, against an optional invitation cap and event capacity.
## Requirements
### Requirement: Event capacity and invitation cap
An event SHALL have an optional max capacity and an optional invitation cap. Each SHALL be empty or a whole number of at least 1. Only users with `BO_EVENT_GUESTS` SHALL set them. Every user who can open the event SHALL see them.
#### Scenario: Set both
- **GIVEN** a user with `BO_EVENTS` and `BO_EVENT_GUESTS`
- **WHEN** they set capacity `200` and invitation cap `150` on `KL Expo`
- **THEN** the event shows capacity 200 and cap 150
#### Scenario: Without the guests module
- **GIVEN** a user with `BO_EVENTS` only
- **WHEN** they open `KL Expo`
- **THEN** they see capacity and cap but cannot change them
### Requirement: Guest list
Each event SHALL have a guest list, kept separate from its event leads. A guest SHALL have a name (required), a mobile and an email (at least one of the two), an optional company and an optional salesperson from the event team. Inputs SHALL be normalised and limited as in staff capture. A guest SHALL NOT appear in event leads, lead listings or the dashboard until registered.
#### Scenario: Add a guest
- **WHEN** an admin adds guest `Tan Mei Ling` with mobile `012-555 0101` to `KL Expo`
- **THEN** the guest list shows `Tan Mei Ling` as Invited
- **AND** the event's leads do not include her
### Requirement: Guest duplicates
A mobile or email already on the event's guest list SHALL be refused with a message naming the existing guest.
#### Scenario: Duplicate refused
- **GIVEN** `Tan Mei Ling` with mobile `+60125550101` is on the list
- **WHEN** an admin adds another guest with mobile `0125550101`
- **THEN** it is refused with a message naming `Tan Mei Ling`
### Requirement: Adding guests by paste
Users with `BO_EVENT_GUESTS` SHALL add guests one at a time or by pasting a list of lines `name, mobile, email, company`. A pasted list SHALL show a preview with per-line errors and save only the valid lines.
#### Scenario: Paste with errors
- **WHEN** an admin pastes three lines, one of which has neither mobile nor email
- **THEN** the preview marks that line with its error
- **AND** saving adds the other two guests only
### Requirement: Invitation cap enforcement
When an event has an invitation cap, the number of guests on its list SHALL NOT exceed it. Adding a guest beyond the cap SHALL be refused with "Invitation cap reached (N)". A pasted list SHALL save valid lines only up to the cap and report the lines left out. Lowering the cap below the current number of guests SHALL be refused.
#### Scenario: Cap reached
- **GIVEN** `KL Expo` has cap 2 and two guests
- **WHEN** an admin adds a third guest
- **THEN** it is refused with "Invitation cap reached (2)"
#### Scenario: Lower the cap too far
- **GIVEN** `KL Expo` has five guests
- **WHEN** an admin sets the cap to 4
- **THEN** the change is refused
### Requirement: Guest removal
A user with `BO_EVENT_GUESTS` SHALL be able to remove a guest who is only Invited. A guest who has registered or attended SHALL NOT be removable from the guest list.
#### Scenario: Remove an invited guest
- **WHEN** an admin removes an Invited guest
- **THEN** the guest is gone and their invite link shows that it is no longer active
#### Scenario: Registered guest stays
- **GIVEN** `Tan Mei Ling` has registered
- **THEN** no remove action is offered for her
### Requirement: Invite links
Every guest SHALL have a personal invite link of the form `/i/<token>` with an unguessable token. Copying a guest's link SHALL be available to users with `BO_EVENT_GUESTS`. An invite link SHALL work only while:
- the guest is on the list;
- the event is enabled;
- the event's end date in Malaysia time has not passed;
- the event's company has a privacy notice.
Otherwise it SHALL show "This invitation is no longer active." and no event details.
#### Scenario: Copy a link
- **WHEN** an admin copies the invite link of `Tan Mei Ling`
- **THEN** the clipboard holds her `/i/<token>` link
#### Scenario: Ended event
- **GIVEN** `Penang Fair` ended yesterday
- **WHEN** a guest opens their invite link
- **THEN** the page says the invitation is no longer active
### Requirement: Invite email
A user with `BO_EVENT_GUESTS` SHALL be able to send an invite email to one guest who has an email, or to every guest with an email who has not been sent one yet. The email SHALL be in English and Bahasa Malaysia and SHALL carry the event's name, dates and location and the guest's invite link. Values from the event and guest SHALL be escaped as text, never as markup. A guest with no email SHALL offer copy link only.
#### Scenario: Send to all not yet sent
- **GIVEN** three guests with an email, one already sent
- **WHEN** an admin chooses send to all not yet sent
- **THEN** two emails are saved
### Requirement: Invite sending record
Sending SHALL record that the guest was invited and how many times an invite was sent. The email SHALL belong to the event's company, so that company's users with Emails can see it.
#### Scenario: Send to one
- **WHEN** an admin sends an invite to `Tan Mei Ling`, who has an email
- **THEN** an email to her address with her invite link is saved by the email service
- **AND** her invite sent count is 1
### Requirement: Invite page
The invite page SHALL show "You're invited to <event>" with the event's name, dates and location. Its form SHALL be filled in with the guest's name, mobile, email and company, which the guest may correct. It SHALL offer the company's active interests and the privacy notice consent (required), as on the QR page.
#### Scenario: Prefilled form
- **WHEN** `Tan Mei Ling` opens her invite link before the event
- **THEN** the form shows her name and mobile, and the consent unticked
### Requirement: Registration by invitation
An accepted invite submission SHALL register the guest with the same normalisation, limits, matching and existing-lead rules as QR registration. The resulting event lead SHALL have source `INVITE` and the guest's salesperson. The guest SHALL become Registered and be linked to that event lead. Submitting again SHALL change nothing and SHALL show the same thank-you page.
#### Scenario: Guest registers
- **WHEN** `Tan Mei Ling` opens her invite link, ticks the consent and submits
- **THEN** the thank-you page names `KL Expo`
- **AND** she is Registered on the guest list
- **AND** an event lead with source INVITE exists for her
#### Scenario: Guest already a lead elsewhere
- **GIVEN** `Tan Mei Ling` is an existing lead with a different job title
- **WHEN** she registers by invitation with a new job title
- **THEN** her lead is not edited and the new job title is in the event lead's notes
### Requirement: Capacity before the event
When an event has a capacity, invite registrations SHALL be refused before the event days once the number of registered guests plus walk-in event leads reaches it. A refused registration SHALL show "This event is full". On the event days (Malaysia, from the start date through the end date) no registration or check-in SHALL be refused for capacity. Staff capture SHALL never be refused for capacity.
#### Scenario: Full before the event
- **GIVEN** `KL Expo` starts next week, has capacity 2, and two registered guests
- **WHEN** a third guest submits their invite
- **THEN** the page says the event is full and nothing is saved
#### Scenario: Not refused on the day
- **GIVEN** the same event on its first day
- **WHEN** the third guest submits their invite
- **THEN** they are registered
### Requirement: Guest list access
Users with `BO_EVENTS` SHALL see an event's guest list with each guest's status, invite sent count and salesperson. Only users with `BO_EVENT_GUESTS` SHALL add, paste, remove, copy links for or send invites to guests. Guest endpoints SHALL apply the company scope as everywhere: staff only reach their company's events.
#### Scenario: Read only
- **GIVEN** a user with `BO_EVENTS` but not `BO_EVENT_GUESTS`
- **WHEN** they open `KL Expo`
- **THEN** they see the guests and their statuses without any guest actions
#### Scenario: Other company
- **GIVEN** a CV staff user with both modules
- **WHEN** they call the guest endpoints of an INS event
- **THEN** the answer is not found
### Requirement: Invite abuse limits
The public invite endpoints SHALL apply the QR page's limits: 120 page loads per IP per 10 minutes and 60 submissions per IP per event per 10 minutes, answering "Too many attempts. Try again later." beyond them. The IP SHALL be determined as on the QR page.
#### Scenario: Too many submissions
- **WHEN** one IP submits a 61st invite registration for `KL Expo` within 10 minutes
- **THEN** it is refused as too many
+43
View File
@@ -131,3 +131,46 @@ The system SHALL accept at most 60 registrations per client IP per event in 10 m
- **WHEN** a submission fills the hidden field
- **THEN** the thank-you page shows and no lead or event lead is saved
### Requirement: Sharing personal walk-in codes
On My QR codes, each code SHALL offer:
- Share: opens the device's share sheet with the link and a short message, or copies them where the device has no share sheet;
- Show full screen: shows the QR as large as the screen allows, on a plain background.
After sign-in, a user with a personal code for an event they joined in the last 7 days SHALL see a notice that links to My QR codes.
#### Scenario: Share from a phone
- **WHEN** `sales1` presses Share on their `KL Expo` code on a phone
- **THEN** the phone's share sheet opens with the registration link
#### Scenario: Full screen at the booth
- **WHEN** `sales1` presses Show full screen
- **THEN** only the QR is shown, filling the screen
#### Scenario: New code notice
- **GIVEN** `sales1` was added to the team of `KL Expo` yesterday
- **WHEN** `sales1` signs in
- **THEN** a notice links to My QR codes
### Requirement: Printing event codes
On the event page, users with `BO_EVENTS` SHALL have:
- Print cards: opens a print-ready page with one card per team member (name, event name and dates, QR and link), plus the event code and the check-in code;
- Copy all links: copies one line per code, as `name: link`.
#### Scenario: Print cards
- **GIVEN** `KL Expo` has three team members
- **WHEN** an admin presses Print cards
- **THEN** the print page shows three member cards plus the event and check-in codes
#### Scenario: Copy all links
- **WHEN** an admin presses Copy all links on `KL Expo`
- **THEN** the clipboard holds one `name: link` line per code
@@ -0,0 +1,67 @@
"use client";
import type { ReactNode } from "react";
import { CalendarDays, ListChecks, UserPlus } from "lucide-react";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import PoweredBy from "@/app/components/app/PoweredBy";
/** What the back office is for, on the brand panel. */
const PANEL_POINTS = [
{ icon: CalendarDays, code: "BackOfficePanelEvents" },
{ icon: UserPlus, code: "BackOfficePanelLeads" },
{ icon: ListChecks, code: "BackOfficePanelFollowUps" },
] as const;
// Two-column frame shared by the signed-out pages (login, forced password change): an accent panel
// with the giraffe-spot coat on the left from lg, the page's own content on the right. Below lg the
// panel folds into a compact brand row above the content.
export default function AuthFrame({ children }: { children: ReactNode }) {
const t = useT();
return (
<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">
{/* Light accent ground with the giraffe-spot coat at 14%. In dark mode the coat and the chips
switch to --accent-foreground so they stay legible on the dark accent. */}
<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>
</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 and giraffe-spot coat. */}
<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>
{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");
});
@@ -0,0 +1,44 @@
import { render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { SidebarLink } from "@/app/lib/aclSidebar";
// refine-visitor-pages-and-shell: no trail on a leaf's own page (the page title says it already).
const state = vi.hoisted(() => ({ links: [] as SidebarLink[], pathname: "/" }));
vi.mock("next/navigation", () => ({ usePathname: () => state.pathname }));
vi.mock("@/app/lib/useAclSidebar", () => ({ useAclSidebar: () => state.links }));
import Breadcrumbs from "./Breadcrumbs";
const LINKS: SidebarLink[] = [
{
name: "Event",
url: "",
children: [{ name: "Events", url: "/events", children: [] }],
},
];
afterEach(() => {
state.pathname = "/";
});
describe("Breadcrumbs trail without repeats", () => {
it("shows no trail on the Events list", () => {
state.links = LINKS;
state.pathname = "/events";
const { container } = render(<Breadcrumbs />);
expect(container).toBeEmptyDOMElement();
});
it("shows Events as a link to the list on the new event page", () => {
state.links = LINKS;
state.pathname = "/events/new";
render(<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";
}
});
});
+71 -125
View File
@@ -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,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")).not.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>
);
}