Compare commits

..
Author SHA1 Message Date
ngqileandClaude Opus 5.5 17880e592b docs(openspec): archive add-visual-foundation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 20:16:55 +08:00
ngqile c82b9365dd Merge pull request 'feat: visual foundation for the admin portal (add-visual-foundation)' (#35) from add-visual-foundation into main
CI / build-and-publish (push) Failing after 0s
2026-12-01 12:16:34 +00:00
ngqileandClaude Opus 5.5 372ef7a6c6 docs: DESIGN.md for the new admin look; align panel corners and dialog surface
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 20:16:16 +08:00
ngqileandClaude Opus 5.5 e0ae164a82 fix: keep the company name together in the footer credit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 20:08:32 +08:00
ngqileandClaude Opus 5.5 a02d923f88 fix: review findings for the visual foundation
Input borders reach 3:1, contrast checks for token pairs, white input fill,
company placeholder and team hint, KPI baseline, one-line footer credit,
tabular dates, selection colour, unused contrast tokens removed, and the
events page no longer exports a non-page value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 20:05:21 +08:00
ngqileandClaude Opus 5.5 91675ffb30 fix: no empty row in the company dropdowns
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 19:53:22 +08:00
ngqileandClaude Opus 5.5 a84128cb83 feat: styled dropdown menus in admin forms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 19:44:53 +08:00
ngqileandClaude Opus 5.5 0710571894 feat: shell wordmark, accent nav item and styled company picker
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 19:35:22 +08:00
ngqileandClaude Opus 5.5 37cb996bc0 feat: slate and blue theme tokens, Inter only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 19:25:51 +08:00
ngqileandClaude Opus 5.5 899b25f45d docs: move the wordmark class removal to the shell task
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 19:05:26 +08:00
ngqileandClaude Opus 5.5 2a78ef0a79 docs: visual foundation design and OpenSpec change
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 18:59:24 +08:00
ngqileandClaude Opus 5.5 92a90d5f48 docs: Co-Lite PRODUCT.md for the visual revamp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:51:42 +08:00
ngqile c5b64c15d0 Merge pull request 'docs(openspec): archive uppercase-company-codes' (#34) from archive-uppercase-company-codes into main
CI / build-and-publish (push) Failing after 0s
2026-12-01 08:41:23 +00:00
ngqileandClaude Opus 5.5 6eec747757 docs(openspec): archive uppercase-company-codes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:41:15 +08:00
ngqile 10b32280ad Merge pull request 'feat: company codes in capitals' (#33) from uppercase-company-codes into main
CI / build-and-publish (push) Failing after 0s
2026-12-01 08:41:03 +00:00
ngqileandClaude Opus 5.5 cbe48c2db9 fix: locale-independent code upper-casing; refresh note
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:40:50 +08:00
ngqileandClaude Opus 5.5 39139ed7b1 docs: uppercase company codes deployment notes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:34:33 +08:00
ngqileandClaude Opus 5.5 5e5762cdcb feat: companies screen shows codes in capitals and allows case-only renames
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:22:03 +08:00
ngqileandClaude Opus 5.5 41c616b3f6 feat: store company codes in capitals
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:13:29 +08:00
ngqileandClaude Opus 5.5 ff4b12c2e9 docs(openspec): propose uppercase-company-codes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 16:07:34 +08:00
ngqile 3ab1a0e0e3 Merge pull request 'docs(openspec): archive add-qr-self-registration' (#32) from archive-add-qr-self-registration into main
CI / build-and-publish (push) Failing after 0s
2026-12-01 06:11:37 +00:00
ngqileandClaude Opus 5.5 5583cf5897 docs(openspec): archive add-qr-self-registration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-01 14:11:28 +08:00
ngqile 03b85737d7 Merge pull request 'feat: QR self-registration for walk-in visitors' (#31) from add-qr-self-registration into main
CI / build-and-publish (push) Failing after 0s
2026-12-01 06:11:05 +00:00
68 changed files with 1425 additions and 300 deletions

No files matched your search

+2
View File
@@ -16,5 +16,7 @@
# Playwright
.playwright-mcp/
solvway-admin-portal/.impeccable/
# Build output
target/
+6
View File
@@ -112,6 +112,12 @@ Run the three in order before the new images go live: the new services-counter w
Run both before the new images go live: the new services-counter reads the new `event_lead` columns on every lead query and fails without them. Both need a user that may create tables. `99-rollback.sql` in the same folder undoes them and deletes the codes, the notices and the consent records.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-01-uppercase-company-codes/sql/01-uppercase-codes.sql` | Turns every company code and every staff login name to capitals (`ins` becomes `INS`, `sales9@cv` becomes `sales9@CV`). Safe to run twice. |
Run it when the new services-system and mobile-api go live. Staff who are signed in keep working until their session needs a refresh, then sign in again. Sign-in still ignores case, so staff may keep typing `ins` or `cv`. `99-rollback.sql` in the same folder turns codes and login names back to lowercase.
**Review the privacy notice before go-live.** The seeded text is a starting template written for the PDPA, not legal advice. INS and CV should each have theirs checked; a super admin changes it under **Companies → Privacy notice**. A company with no notice has no working QR codes.
**Database user:**
@@ -0,0 +1,43 @@
# Co-Lite visual foundation — design
Date: 2026-12-01. Status: direction chosen by the owner; design awaiting approval.
## Why
The admin portal still wears the inherited babyboo look: brown primary, DM Sans headings, 16px soft corners, a gradient wordmark, and native selects whose option lists cannot be styled (the owner asked why the company picker's options are not rounded). The owner wants a complete revamp before go-live (2027-01-15), and the invitations screens (tasks 5.1–5.3 of `add-event-invitations`) wait on it.
## Direction
The owner looked at nine directions on a decision page and chose **the category standard**: a clean SaaS admin, done well, with no brand gimmick. The quality bar is Stripe Dashboard, Linear and Vercel (my call; the owner did not name products). Reference sketch: `solvway-admin-portal/.impeccable/mocks/decision/canon.html` (local only).
- **Colour:** white ground and white sidebar with a 1px slate border; slate text (#0F172A, muted #64748B); slate-50 surfaces (#F1F5F9); one blue accent (#2563EB) for primary buttons, links, focus rings and the active nav item. Status pills are pastel tints with dark text (green, amber, red, blue, slate).
- **Type:** Inter for everything; DM Sans is dropped. Tabular figures for numbers.
- **Shape:** 8px card radius, 6px controls, one soft shadow on cards, 1px borders.
- **Wordmark:** a small blue square mark plus "Co-Lite" in solid text. The gradient text goes.
- **Selects:** every native `<select>` in the portal becomes the shared styled select menu, so open option lists match the rest of the UI.
## Approaches considered
1. **Re-theme the tokens and fix the shell (chosen).** The portal already takes every colour from theme tokens (a test enforces it), so changing the token values, the fonts and the radius re-skins every screen at once. Then fix the few places the tokens do not reach: the wordmark, native selects, and shell spacing.
2. **Rebuild screen by screen.** Gives more control per screen, but takes weeks, and screens look mixed until the end.
3. **Swap in a component kit.** Adds a dependency and churn for no gain: the shadcn-style components are already here.
## Scope
In: theme tokens (light and dark), fonts, radius and shadow; app shell (sidebar, header, page header, footer); shared `ui/` components where token changes are not enough; the six files with native selects; removing the gradient wordmark.
Out (follow-up change on the same tokens): booth screen (My QR codes), public visitor pages (`/r`, `/i`, `/c`), login. Route pills on lead tables arrive with the invitations screens.
Open after the finish review (for the follow-up change): the header label repeats the page title ("Events" above "New event") and is blank on the dashboard; it should show the real trail or go. Also: tables at 360 px cut off mid-column with no scroll cue; the 12-item sidebar could use quiet group dividers; login comments still describe the old brown and gold panel.
## Decisions for the owner to check
- **Dark theme:** keep the existing dark mechanism and re-derive its tokens from the same slate and blue scale. Light stays the default. (PRODUCT.md lists a dark default as undecided.)
- **Per-company accent:** not in this change; both companies use the same blue.
## Constraints
- Colours only from theme tokens; the existing rule and its test stay.
- No new dependencies: the styled select is already in `app/components/ui/select.tsx` (Radix).
- Existing tests that pin the old look (DM Sans on `<html>`, native select interactions) are re-targeted to the new requirements, never weakened.
- Verified in Playwright at 1280 and 360 px, light and dark.
+3 -3
View File
@@ -185,8 +185,8 @@ ALTER TABLE `company`
ADD COLUMN `code` varchar(20) NULL AFTER `name`,
ADD COLUMN `status` char(1) NOT NULL DEFAULT 'A' COMMENT 'A active, I inactive' AFTER `code`;
UPDATE `company` SET `name` = 'INS', `code` = 'ins' WHERE `id` = 1;
INSERT INTO `company` (`name`, `code`, `status`) VALUES ('CV', 'cv', 'A');
UPDATE `company` SET `name` = 'INS', `code` = 'INS' WHERE `id` = 1;
INSERT INTO `company` (`name`, `code`, `status`) VALUES ('CV', 'CV', 'A');
ALTER TABLE `company`
MODIFY COLUMN `code` varchar(20) NOT NULL,
@@ -226,7 +226,7 @@ DROP PROCEDURE `colite_check_admin_usernames`;
UPDATE `user` u SET u.`company_id` = NULL
WHERE u.`type` = 'A' AND EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1);
UPDATE `user` u SET u.`company_id` = 1, u.`username` = CONCAT(u.`username`, '@ins')
UPDATE `user` u SET u.`company_id` = 1, u.`username` = CONCAT(u.`username`, '@INS')
WHERE u.`type` = 'A' AND NOT EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1);
-- add-lead-dashboard/sql/01-status-change.sql (02 backfill has nothing to do on an empty volume)
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-01
@@ -0,0 +1,23 @@
## Context
The portal is a Next.js app with shadcn-style components. Every colour already comes from CSS custom properties in `app/globals.css` (enforced by `app/design-tokens.test.ts`), so the look is mostly token values. The current tokens, fonts (Inter plus DM Sans headings) and 1rem radius came from the babyboo portal. Full design: `docs/superpowers/specs/2026-12-01-visual-foundation-design.md`.
## Goals / Non-Goals
**Goals:** replace the token values, fonts, radius and shadow; fix the shell and the wordmark; turn every native select into the shared Radix select.
**Non-Goals:** booth screen, visitor pages, login (follow-up change); per-company accent; new components or dependencies.
## Decisions
1. **Token values, not class rewrites.** Change `:root` and `.dark` values in `globals.css`: background white, foreground #0F172A, muted foreground #64748B, muted/secondary #F1F5F9, border #E2E8F0, primary and ring #2563EB, destructive red, plus success and warning tokens if missing. `--radius` becomes 0.5rem (cards 8px, controls 6px).
2. **Inter only.** Drop the DM Sans font file and variable from `layout.tsx`; `--font-heading` points at Inter. The test that expects DM Sans on `<html>` is re-targeted to "only Inter" (requirement One Type Family).
3. **Wordmark.** Remove `.brand-gradient-text` and its use; the sidebar shows a blue square mark plus solid "Co-Lite".
4. **Selects.** Use the existing `app/components/ui/select.tsx`. Radix Select does not accept an empty string as a value, so "All companies" uses a sentinel value mapped back to `undefined`. Tests that used `selectOptions` on native selects open the menu and click the option instead (requirement Styled Dropdown Menus).
5. **Dark theme.** Keep the existing `.dark` mechanism; re-derive its values from slate-900/800 surfaces and a lighter blue (#3B82F6) accent.
## Risks / Trade-offs
- [Re-targeted tests could hide a regression] → each changed test maps to a scenario in the new spec; the reviewer checks no assertion is weakened.
- [Radix Select in jsdom] → the existing `select.test.tsx` already drives it; reuse its helpers.
- [Screens look half-done until booth and visitor pages follow] → those pages are public or phone-only and are next in line.
@@ -0,0 +1,27 @@
## Why
The admin portal still wears the inherited babyboo look (brown primary, DM Sans headings, 16px corners, gradient wordmark, unstyled native select menus). The owner chose a replacement direction on 2026-12-01: the category-standard SaaS admin, done well. The invitations screens wait on this foundation.
## What Changes
- New look across the admin portal: white and slate with one blue accent, Inter only, 8px cards and 6px controls, one soft card shadow.
- Dark theme re-derived from the same scale; light stays the default.
- The wordmark becomes a solid "Co-Lite" with a small mark; no gradient text.
- Every dropdown in the admin portal opens a styled option menu instead of the browser's native list (company picker, event form, user form, company status, event-lead forms).
- Booth, visitor and login pages are out of scope (follow-up change).
## Capabilities
### New Capabilities
- `admin-visual-design`: the admin portal's theme rules: colours from theme tokens only, one accent colour, one type family, light default with a dark theme, the product wordmark, and styled dropdown menus.
### Modified Capabilities
None.
## Impact
- `solvway-admin-portal`: `app/globals.css`, `tailwind.config.ts`, `app/layout.tsx` (fonts), `app/components/app/*` (shell, company picker), `app/components/ui/*` where tokens are not enough, and the five other files with native selects.
- Existing tests that pin the old font or drive native selects are re-targeted to the new requirements.
- No backend, API or data changes.
@@ -0,0 +1,75 @@
## ADDED Requirements
### Requirement: Admin Colours Come From Theme Tokens
The admin portal SHALL take every colour from the theme tokens. A component MUST NOT use a fixed palette colour, except a modal scrim, a print-only sheet, a QR code's quiet zone, or a frame showing email HTML.
#### Scenario: A component uses a palette colour
- **WHEN** a component's classes include a fixed palette colour that is not on the exception list
- **THEN** the portal's checks fail
### Requirement: One Accent Colour
The admin portal SHALL use slate neutrals for text, surfaces and borders, and one blue accent for primary actions, links, focus rings and the active navigation item. Status colours (success, warning, danger) SHALL appear only where they carry meaning.
#### Scenario: Primary action
- **WHEN** a page shows a primary button
- **THEN** the button uses the accent colour and the other buttons on the page do not
#### Scenario: Active navigation item
- **WHEN** an admin is on the Events page
- **THEN** the Events item in the sidebar is marked in the accent colour and no other item is
### Requirement: One Type Family
The admin portal SHALL set all text, headings included, in one sans-serif family, with tabular figures for numbers in tables and counts.
#### Scenario: Fonts loaded
- **WHEN** any admin page loads
- **THEN** only the one family's font file is loaded
### Requirement: Light Default With A Dark Theme
The admin portal SHALL show the light theme by default and SHALL offer a dark theme derived from the same neutrals and accent.
#### Scenario: First visit
- **WHEN** an admin opens the portal with no theme preference saved
- **THEN** the light theme is shown
#### Scenario: Dark theme chosen
- **WHEN** an admin switches to the dark theme
- **THEN** every page uses the dark tokens and text keeps at least 4.5:1 contrast
### Requirement: Product Wordmark
The admin portal SHALL show the product name "Co-Lite" as solid text beside a small mark, and SHALL keep "Powered by Containerverse Sdn. Bhd." in the footer.
#### Scenario: Sidebar header
- **WHEN** an admin page loads
- **THEN** the sidebar shows the mark and the text "Co-Lite" in a solid colour, not gradient-filled text
### Requirement: Styled Dropdown Menus
Every dropdown in the admin portal SHALL open a styled option menu that matches the portal's theme, and SHALL stay usable by keyboard and screen reader.
#### Scenario: Company picker
- **WHEN** a super admin opens the company picker in the header
- **THEN** a styled menu lists "All companies" and each company code, and choosing one scopes the pages to that company
#### Scenario: Form dropdown
- **WHEN** an admin opens the salesperson, temperature or status dropdown on an event lead
- **THEN** a styled menu opens, and the chosen value is saved with the form as before
#### Scenario: Keyboard use
- **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
@@ -0,0 +1,34 @@
# Tasks
Serial. One implementer at a time, Opus review gate per task.
## 1. Theme
- [x] 1.1 Token values (light and dark), radius 0.5rem, a card shadow token, Inter only (drop DM Sans).
- Depends on: none
- Tests first: `<html>` carries only the Inter font variable; `globals.css` has no DM Sans; `--primary` is the blue accent in light and dark.
- Scope: `solvway-admin-portal/app/globals.css`, `solvway-admin-portal/app/layout.tsx`, `solvway-admin-portal/app/layout.test.tsx`, `solvway-admin-portal/app/globals.test.ts`, `solvway-admin-portal/app/fonts/**`, `solvway-admin-portal/tailwind.config.ts`
- Verify: `cd solvway-admin-portal && npm run lint; echo L=$?; npx tsc --noEmit; echo T=$?; npx vitest run; echo V=$?`
## 2. Shell
- [x] 2.1 Sidebar wordmark (mark plus solid "Co-Lite"; remove `brand-gradient-text` from `globals.css`), cards use the shadow token, active item in the accent, header and page header spacing to the reference sketch; company picker becomes the styled select.
- Depends on: 1.1
- Tests first: sidebar shows "Co-Lite" with no gradient class; only the current nav item is marked active; the company picker opens a menu with "All companies" and each code, and choosing one sets the scope.
- Scope: `solvway-admin-portal/app/components/app/**`, `solvway-admin-portal/app/components/ui/**`, `solvway-admin-portal/app/lib/CompanyScope*.tsx`, `solvway-admin-portal/app/globals.css`
- Verify: as 1.1
## 3. Form dropdowns
- [x] 3.1 Replace the native selects in the event form, user form, company status, and the new and edit event-lead pages with the styled select; values save as before.
- Depends on: 2.1
- Tests first: each dropdown opens a menu, choosing an option sends that value on save; keyboard opens and chooses.
- Scope: `solvway-admin-portal/app/components/events/**`, `solvway-admin-portal/app/components/users/**`, `solvway-admin-portal/app/companies/**`, `solvway-admin-portal/app/event-leads/**`, `solvway-admin-portal/app/companyScope.forms.test.tsx`
- Verify: as 1.1
## 4. Check and record
- [x] 4.1 Playwright at 1280 and 360 px, light and dark: dashboard, events list, event edit, event leads, a user form, companies; screenshots in the PR. Then the impeccable finish review and DESIGN.md from the built result.
- Depends on: 3.1
- Scope: `solvway-admin-portal/DESIGN.md`, `openspec/changes/add-visual-foundation/tasks.md`
- Verify: as 1.1
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-01
@@ -0,0 +1,27 @@
## Why
Company codes are stored and shown in lowercase (`ins`, `cv`). The owner wants them in capitals (`INS`, `CV`), and the Companies screen cannot change `cv` to `CV`: the portal treats a case-only change as no change, and services-system lowercases every code it saves.
## What Changes
- Company codes are stored and shown in capitals: 2 to 20 characters of `A-Z`, `0-9` and `-`. Any code entered is turned to capitals before it is checked and saved.
- Sign-in keeps ignoring case: staff can type `cv`, `Cv` or `CV`.
- Staff login names follow the code (`sales9@CV`).
- A one-off SQL turns the existing codes and staff login names to capitals.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `company-scoping`: the code format of the Companies requirement becomes capitals.
## Impact
- **services-system:** `CompanyService` code validation and normalisation.
- **mobile-api:** the admin login builds the login name with the code in capitals.
- **portal:** the Companies code fields show and send capitals. A case-only rename is no longer treated as no change.
- **Data:** `sql/01-uppercase-codes.sql` on `service-system`. Signed-in staff must sign in again after it runs, as after any code change.
@@ -0,0 +1,30 @@
# Spec Delta
## MODIFIED Requirements
### Requirement: Companies
The system SHALL let a super admin list, create and edit companies, each with a name, a unique code and an active or inactive status. A code SHALL be 2 to 20 characters of capital letters, digits and hyphens. A code entered in any case SHALL be stored in capitals, and codes SHALL be compared ignoring case. Companies SHALL NOT be deletable. The Companies screen and its endpoints SHALL be available to super admins only.
#### Scenario: Create a company
- **WHEN** a super admin creates company `CV` with code `cv`
- **THEN** it is listed as active with code `CV`
- **AND** staff can be created in it
#### Scenario: Duplicate code
- **GIVEN** a company with code `INS`
- **WHEN** a super admin creates or renames another company to code `ins`
- **THEN** the save is refused and the code is reported as taken
#### Scenario: Not a super admin
- **WHEN** company staff open the Companies page or call a companies endpoint
- **THEN** the page shows not-authorised and the endpoint responds 403
#### Scenario: Sign-in ignores case
- **GIVEN** company code `CV` and its user `sales9`
- **WHEN** they sign in with company `cv`
- **THEN** they are signed in as `sales9` of CV
@@ -0,0 +1,9 @@
-- Co-Lite change uppercase-company-codes: company codes and staff login names in capitals.
-- Target: `service-system`. Signed-in staff must sign in again afterwards. Idempotent.
USE `service-system`;
UPDATE `user` u JOIN `company` c ON c.`id` = u.`company_id`
SET u.`username` = CONCAT(SUBSTRING(u.`username`, 1, CHAR_LENGTH(u.`username`) - CHAR_LENGTH(c.`code`) - 1), '@', UPPER(c.`code`))
WHERE u.`type` = 'A' AND u.`username` LIKE CONCAT('%@', c.`code`) AND BINARY u.`username` <> BINARY CONCAT(SUBSTRING(u.`username`, 1, CHAR_LENGTH(u.`username`) - CHAR_LENGTH(c.`code`) - 1), '@', UPPER(c.`code`));
UPDATE `company` SET `code` = UPPER(`code`) WHERE BINARY `code` <> BINARY UPPER(`code`);
@@ -0,0 +1,8 @@
-- Co-Lite change uppercase-company-codes: rollback to lowercase codes and login names.
USE `service-system`;
UPDATE `user` u JOIN `company` c ON c.`id` = u.`company_id`
SET u.`username` = CONCAT(SUBSTRING(u.`username`, 1, CHAR_LENGTH(u.`username`) - CHAR_LENGTH(c.`code`) - 1), '@', LOWER(c.`code`))
WHERE u.`type` = 'A' AND u.`username` LIKE CONCAT('%@', c.`code`);
UPDATE `company` SET `code` = LOWER(`code`);
@@ -0,0 +1,33 @@
# Tasks
Serial. One implementer, in this session.
## 1. Data
- [x] 1.1 `sql/01-uppercase-codes.sql` and `sql/99-rollback.sql`; change the codes in `local/seed/03-colite.sql` to `INS` and `CV` (the `@ins` login names it builds follow); apply 01 to the local database.
- Depends on: none
- Scope: `local/seed/**`, `openspec/changes/uppercase-company-codes/sql/**`
- Verify: `SELECT code FROM company` gives `INS`, `CV`; staff login names end in `@INS` or `@CV`.
## 2. Backend
- [x] 2.1 services-system `CompanyService` stores codes in capitals (`^[A-Z0-9-]{2,20}$`, entered value trimmed and turned to capitals); mobile-api admin login and forgot-password build the login name with the code in capitals.
- Depends on: 1.1
- Tests first: create with `cv` stores `CV`; rename `cv` to `CV` on a company whose code is `cv` succeeds; `ins` is taken when `INS` exists; an invalid code is refused; login with company `cv` looks up `user@CV`.
- Scope: `solvway-services-system/src/**`, `solvway-mobile-api/src/**`
- Verify: `mvn -T 1C -q -pl solvway-services-system,solvway-mobile-api verify`
## 3. Portal
- [x] 3.1 Companies: code inputs show capitals as typed and the rename compares case-sensitively, so `cv` to `CV` is a change.
- Depends on: 2.1
- Tests first: typing `cv` shows `CV`; renaming `cv` to `CV` sends the request.
- Scope: `solvway-admin-portal/app/**`
- Verify: `cd solvway-admin-portal && npm run lint; echo L=$?; npx tsc --noEmit; echo T=$?; npx vitest run; echo V=$?`
## 4. Release
- [x] 4.1 `docs/deployment.md` notes the SQL and that staff sign in again; Playwright: Companies shows `INS` and `CV`, sign in as `sales9` with company `cv` works.
- Depends on: 3.1
- Scope: `docs/deployment.md`, `openspec/changes/uppercase-company-codes/tasks.md`
- Verify: the 2.1 and 3.1 verifies.
@@ -0,0 +1,81 @@
# admin-visual-design Specification
## Purpose
Keep the admin portal's look consistent and accessible: colours from theme tokens only, slate neutrals with one blue accent, one type family, a light default with a dark theme, the Co-Lite wordmark, and styled dropdown menus.
## Requirements
### Requirement: Admin Colours Come From Theme Tokens
The admin portal SHALL take every colour from the theme tokens. A component MUST NOT use a fixed palette colour, except a modal scrim, a print-only sheet, a QR code's quiet zone, or a frame showing email HTML.
#### Scenario: A component uses a palette colour
- **WHEN** a component's classes include a fixed palette colour that is not on the exception list
- **THEN** the portal's checks fail
### Requirement: One Accent Colour
The admin portal SHALL use slate neutrals for text, surfaces and borders, and one blue accent for primary actions, links, focus rings and the active navigation item. Status colours (success, warning, danger) SHALL appear only where they carry meaning.
#### Scenario: Primary action
- **WHEN** a page shows a primary button
- **THEN** the button uses the accent colour and the other buttons on the page do not
#### Scenario: Active navigation item
- **WHEN** an admin is on the Events page
- **THEN** the Events item in the sidebar is marked in the accent colour and no other item is
### Requirement: One Type Family
The admin portal SHALL set all text, headings included, in one sans-serif family, with tabular figures for numbers in tables and counts.
#### Scenario: Fonts loaded
- **WHEN** any admin page loads
- **THEN** only the one family's font file is loaded
### Requirement: Light Default With A Dark Theme
The admin portal SHALL show the light theme by default and SHALL offer a dark theme derived from the same neutrals and accent.
#### Scenario: First visit
- **WHEN** an admin opens the portal with no theme preference saved
- **THEN** the light theme is shown
#### Scenario: Dark theme chosen
- **WHEN** an admin switches to the dark theme
- **THEN** every page uses the dark tokens and text keeps at least 4.5:1 contrast
### Requirement: Product Wordmark
The admin portal SHALL show the product name "Co-Lite" as solid text beside a small mark, and SHALL keep "Powered by Containerverse Sdn. Bhd." in the footer.
#### Scenario: Sidebar header
- **WHEN** an admin page loads
- **THEN** the sidebar shows the mark and the text "Co-Lite" in a solid colour, not gradient-filled text
### Requirement: Styled Dropdown Menus
Every dropdown in the admin portal SHALL open a styled option menu that matches the portal's theme, and SHALL stay usable by keyboard and screen reader.
#### Scenario: Company picker
- **WHEN** a super admin opens the company picker in the header
- **THEN** a styled menu lists "All companies" and each company code, and choosing one scopes the pages to that company
#### Scenario: Form dropdown
- **WHEN** an admin opens the salesperson, temperature or status dropdown on an event lead
- **THEN** a styled menu opens, and the chosen value is saved with the form as before
#### Scenario: Keyboard use
- **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
+10 -4
View File
@@ -8,18 +8,18 @@ Separate the data of each company using Co-Lite (INS and CV at go-live): staff s
### Requirement: Companies
The system SHALL let a super admin list, create and edit companies, each with a name, a unique code and an active or inactive status. A code SHALL be 2 to 20 characters of lowercase letters, digits and hyphens, compared ignoring case. Companies SHALL NOT be deletable. The Companies screen and its endpoints SHALL be available to super admins only.
The system SHALL let a super admin list, create and edit companies, each with a name, a unique code and an active or inactive status. A code SHALL be 2 to 20 characters of capital letters, digits and hyphens. A code entered in any case SHALL be stored in capitals, and codes SHALL be compared ignoring case. Companies SHALL NOT be deletable. The Companies screen and its endpoints SHALL be available to super admins only.
#### Scenario: Create a company
- **WHEN** a super admin creates company `CV` with code `cv`
- **THEN** it is listed as active
- **THEN** it is listed as active with code `CV`
- **AND** staff can be created in it
#### Scenario: Duplicate code
- **GIVEN** a company with code `ins`
- **WHEN** a super admin creates or renames another company to code `INS`
- **GIVEN** a company with code `INS`
- **WHEN** a super admin creates or renames another company to code `ins`
- **THEN** the save is refused and the code is reported as taken
#### Scenario: Not a super admin
@@ -27,6 +27,12 @@ The system SHALL let a super admin list, create and edit companies, each with a
- **WHEN** company staff open the Companies page or call a companies endpoint
- **THEN** the page shows not-authorised and the endpoint responds 403
#### Scenario: Sign-in ignores case
- **GIVEN** company code `CV` and its user `sales9`
- **WHEN** they sign in with company `cv`
- **THEN** they are signed in as `sales9` of CV
### Requirement: Company sign-in
The system SHALL sign company staff in with company code, username and password, and SHALL sign super admins in with username and password and no company. The answer SHALL be the same for a wrong or unknown company, an inactive company, an unknown user and a wrong password. A user's sessions SHALL end when their company is deactivated or its code is changed.
+133
View File
@@ -0,0 +1,133 @@
# qr-registration Specification
## Purpose
Walk-in visitors scan an event or salesperson QR code and register themselves as a lead, with recorded PDPA consent, abuse limits and staff tools to show, print and switch off codes.
## Requirements
### Requirement: Registration codes
The system SHALL give every event one registration code and one personal code per member of the event's team. A code SHALL be an unguessable token in a link of the form `/r/<token>`. Staff with `BO_EVENTS` SHALL see each code of an event of their company as a QR image, copy its link, download it as an image, and switch it off or on. Every staff user SHALL see their own personal codes for events of their company that have not ended.
#### Scenario: Event page codes
- **GIVEN** event `KL Expo` with `sales1` and `sales2` on its team
- **WHEN** a user with `BO_EVENTS` opens the event
- **THEN** the event's code and the personal codes of `sales1` and `sales2` are shown, each with its QR image and link
#### Scenario: Own codes
- **GIVEN** `sales1` is on the team of `KL Expo`, which ends tomorrow, and of `Penang Fair`, which ended last week
- **WHEN** `sales1` opens My QR codes
- **THEN** only the personal code for `KL Expo` is listed
#### Scenario: Switch a code off
- **WHEN** staff switch off the event code of `KL Expo`
- **THEN** scanning that code shows that it is no longer active
- **AND** the personal codes still work
### Requirement: When a code works
A code SHALL work only while it is switched on, its event is enabled, the event's end date in Malaysia time has not passed, and the event's company has a privacy notice. An inactive or unknown code SHALL show "This code is no longer active." and no event details. A personal code whose salesperson is no longer an active member of the event's team SHALL keep working, and its registrations SHALL have no salesperson.
#### Scenario: Ended event
- **GIVEN** `Penang Fair` ended yesterday
- **WHEN** a visitor scans its code
- **THEN** the page says the code is no longer active and shows no event details
#### Scenario: Salesperson left the team
- **GIVEN** `sales2` was removed from the team of `KL Expo`
- **WHEN** a visitor registers through `sales2`'s code
- **THEN** the registration succeeds and the event lead has no salesperson
### Requirement: Public registration
The registration page SHALL show the event's name, dates and location, and a form for name (required), mobile and email (at least one), company, job title, the company's active interests, and the privacy notice consent (required). Inputs SHALL be normalised and limited as in staff capture. Every accepted submission SHALL show the same thank-you page naming the event, with a button to register another person, whether or not the person was already known.
#### Scenario: Register
- **WHEN** a visitor scans the code of `KL Expo`, enters name `Aisyah`, mobile `012-345 6701` and ticks the consent
- **THEN** the thank-you page names `KL Expo`
- **AND** staff see `Aisyah` with mobile `+60123456701` in the event's leads as NEW and OPEN
#### Scenario: Missing consent or contact
- **WHEN** a visitor submits without ticking the consent, or without a mobile and an email
- **THEN** nothing is saved and the page shows the error under the field
#### Scenario: Known person gets the same answer
- **GIVEN** a lead with mobile `+60123456701` exists in the company
- **WHEN** a visitor registers with that mobile
- **THEN** the page shows the same thank-you page as for a new person
### Requirement: Registration matching
A registration SHALL match a lead of the event's company by mobile first and then by email, the newest lead winning among several. A matched lead SHALL NOT be edited: it SHALL be linked as EXISTING, with every submitted value that differs from the lead's written into the event lead's notes. Without a match a new lead SHALL be created as NEW.
#### Scenario: Existing lead not edited
- **GIVEN** lead `Aisyah` with mobile `+60123456701` and no email
- **WHEN** a visitor registers as `Aisyah Rahman` with that mobile and email `a@example.test`
- **THEN** lead `Aisyah` still has no email and its name is unchanged
- **AND** the new event lead is EXISTING and its notes list the submitted name and email
#### Scenario: Mobile beats email
- **GIVEN** lead `A` has mobile `+60123456701` and lead `B` has email `b@example.test`
- **WHEN** a visitor registers with that mobile and that email
- **THEN** the registration is linked to lead `A`
### Requirement: Registration of a person already captured
When the matched lead is already captured at the event, a registration SHALL change nothing, except that an event lead with no salesperson SHALL get the salesperson of a personal code whose salesperson is an active member of the event's team.
#### Scenario: Already captured, unassigned
- **GIVEN** `Aisyah` is captured at `KL Expo` with no salesperson
- **WHEN** she registers again through `sales1`'s personal code and `sales1` is on the team
- **THEN** her event lead's salesperson becomes `sales1` and nothing else changes
### Requirement: Registration record
An event lead created by a registration SHALL have status OPEN, source QR, captured by `qr`, the consent time and the privacy notice version shown, the chosen interests, and the code's salesperson when that salesperson is an active member of the event's team. Event leads captured by staff SHALL have source STAFF. The status history SHALL record the first status by `qr`.
#### Scenario: Personal code assigns
- **WHEN** a visitor registers through `sales1`'s personal code for `KL Expo`
- **THEN** the event lead's salesperson is `sales1`, its source is QR and it records the consent time and notice version
### Requirement: Privacy notice
Each company SHALL have a privacy notice in English and Bahasa Malaysia, kept as versions: saving a change SHALL add a new version and keep the old ones. Only a super admin SHALL edit it, on the Companies page. The registration page SHALL show the company's current notice in both languages. INS and CV SHALL start with the default notice of the design, with the company's name filled in.
#### Scenario: Edit the notice
- **GIVEN** CV's notice is version 3
- **WHEN** a super admin changes CV's English text and saves
- **THEN** CV's registration pages show the new text
- **AND** event leads registered before still point to version 3
#### Scenario: Not a super admin
- **WHEN** company staff call the privacy notice update endpoint
- **THEN** it responds 403
### Requirement: Registration abuse limits
The system SHALL accept at most 60 registrations per client IP per event in 10 minutes and serve at most 120 registration page loads per client IP in 10 minutes, answering above either limit with "Too many registrations from this device. Try again later." A submission that fills the hidden honeypot field SHALL get the normal thank-you page and save nothing.
#### Scenario: Too many submissions
- **GIVEN** 60 registrations for `KL Expo` from one IP in the last 10 minutes
- **WHEN** the 61st arrives from that IP
- **THEN** nothing is saved and the page shows the too-many message
#### Scenario: Honeypot
- **WHEN** a submission fills the hidden field
- **THEN** the thank-you page shows and no lead or event lead is saved
+256
View File
@@ -0,0 +1,256 @@
---
name: Co-Lite Admin
description: The category-standard SaaS admin for event leads, executed with care.
colors:
primary: "#2563EB"
primary-foreground: "#FFFFFF"
accent-tint: "#EFF6FF"
accent-ink: "#1D4ED8"
ground: "#F8FAFC"
surface: "#FFFFFF"
ink: "#0F172A"
ink-muted: "#475569"
slate-tint: "#F1F5F9"
hairline: "#E2E8F0"
control-stroke: "#7C8BA1"
positive: "#15803D"
warning: "#B45309"
negative: "#B91C1C"
destructive: "#DC2626"
chart-teal: "#0F766E"
chart-amber: "#D97706"
chart-violet: "#7C3AED"
chart-rose: "#E11D48"
typography:
headline:
fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
fontSize: "24px"
fontWeight: 600
lineHeight: 1.33
letterSpacing: "-0.025em"
title:
fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
fontSize: "16px"
fontWeight: 600
lineHeight: 1
body:
fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
fontSize: "14px"
fontWeight: 400
lineHeight: 1.43
label:
fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
fontSize: "12px"
fontWeight: 600
lineHeight: 1.33
letterSpacing: "0.025em"
figure:
fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
fontSize: "24px"
fontWeight: 600
fontFeature: "\"tnum\" 1"
rounded:
sm: "4px"
md: "6px"
lg: "8px"
full: "9999px"
spacing:
xs: "4px"
sm: "8px"
md: "16px"
lg: "24px"
components:
button-primary:
backgroundColor: "{colors.primary}"
textColor: "{colors.primary-foreground}"
rounded: "{rounded.md}"
padding: "8px 16px"
height: "36px"
button-outline:
backgroundColor: "{colors.ground}"
textColor: "{colors.ink}"
rounded: "{rounded.md}"
padding: "8px 16px"
height: "36px"
button-outline-hover:
backgroundColor: "{colors.accent-tint}"
textColor: "{colors.accent-ink}"
button-ghost-hover:
backgroundColor: "{colors.accent-tint}"
textColor: "{colors.accent-ink}"
input:
backgroundColor: "{colors.surface}"
textColor: "{colors.ink}"
rounded: "{rounded.md}"
padding: "4px 12px"
height: "36px"
card:
backgroundColor: "{colors.surface}"
textColor: "{colors.ink}"
rounded: "{rounded.lg}"
padding: "24px"
table-head:
backgroundColor: "{colors.slate-tint}"
textColor: "{colors.ink-muted}"
typography: "{typography.label}"
height: "40px"
badge-positive:
textColor: "{colors.positive}"
rounded: "{rounded.full}"
padding: "2px 8px"
nav-item-active:
backgroundColor: "{colors.accent-tint}"
textColor: "{colors.accent-ink}"
rounded: "{rounded.lg}"
height: "44px"
---
# Design System: Co-Lite Admin
## Overview
**Creative North Star: "The Category Standard"**
Co-Lite looks like the best ordinary SaaS admin and nothing more: white and slate, one blue accent, Inter, no brand gimmicks. The owner chose this deliberately over more characterful worlds; the measure is Stripe Dashboard, Linear and Vercel. Its quality lives in restraint and in the details: exact hairlines, aligned figures, honest contrast, consistent control heights.
The page is a pale slate ground (#F8FAFC) carrying white surfaces: the sidebar, the sticky header and every card are white with a 1px slate hairline. Density is office density: 36px controls, 14px working text, sortable tables inside cards, KPI figures in tabular numerals. An admin should read an event's numbers and filter a lead table without having to learn anything.
This world replaces the inherited babyboo look (brown primary, DM Sans, 16px soft corners, gradient wordmark). That look is retired and must not return; `app/globals.test.ts` fails on DM Sans and on any "brown", "gold" or "dusty" in the stylesheet.
**Key Characteristics:**
- Pale slate ground, white surfaces, 1px slate hairlines.
- One blue accent for primary actions, links, focus and the active nav item.
- Inter for everything; figures, IDs and percentages on tabular numerals.
- Small, quiet radii: 6px controls, 8px cards and tables, full pills for status.
- Depth from hairlines first, with only a whisper of shadow.
- Colour comes only from theme tokens, never palette classes.
## Colors
Slate neutrals with a single blue voice, plus muted semantic and chart tones that each carry a text label.
### Primary
- **Action Blue** (primary): filled primary buttons, links in tables (event names), the brand mark square, the avatar, focus rings (as a 3px ring at 50% opacity), and the first chart series. In dark mode it lightens to #60A5FA with near-black text (#0B1220).
- **Blue Tint** (accent-tint) with **Deep Blue Ink** (accent-ink): the active sidebar item, hover on outline and ghost buttons, menu highlights and `::selection`. The tint is a ground, never text; the ink is the text on it.
### Secondary
- **Semantic tones**: Forest (positive), Burnt Amber (warning), Brick (negative) appear only as status pills (10% fill, 30% border, full-strength text) and as delta text. **Signal Red** (destructive) fills destructive buttons and outlines destructive-outline ones.
- **Chart tones**: Deep Teal, Amber, Violet, Rose follow Action Blue as chart series 2 to 5. Teal and violet double as category pills ("kinds", not states).
### Neutral
- **Slate Ground** (ground): the page behind everything, and the fill of outline buttons.
- **White Surface** (surface): sidebar, header, cards, popovers, menus, input fields.
- **Slate Ink** (ink): all primary text and headings.
- **Muted Slate** (ink-muted): labels, meta lines, descriptions, table header text, idle nav items. It is #475569, darker than the direction contract's #64748B, so it clears 4.5:1 on the slate tint.
- **Slate Tint** (slate-tint): table header rows, secondary buttons, muted fills, row hover at 50%.
- **Hairline** (hairline): every border and divider; the default border colour of every element.
- **Control Stroke** (control-stroke): the border of inputs and select triggers only, darker than the hairline so a field's boundary reaches 3:1.
**Dark theme** is a supported mechanism (`.dark` on html, toggled in the header), not the default. It re-derives the same roles from the slate and blue scale: ground #020617, surfaces #0F172A, ink #F1F5F9, muted #94A3B8, tint #1E293B, accent tint #172554 with ink #BFDBFE, control stroke #64748B, primary #60A5FA. Semantic and chart tones move to their 400 steps.
### Named Rules
**The One Voice Rule.** Blue is the only interactive colour. Primary actions, links, focus and the current location are blue; nothing else is. Semantic and chart tones never mark something clickable.
**The Token-Only Rule.** Colour enters a component only through theme tokens (`bg-primary`, `text-muted-foreground`, `border-input`). Tailwind palette classes (`bg-slate-100`, `text-blue-600`, `bg-white`) are banned and `app/design-tokens.test.ts` fails on them, with a short reasoned allowlist (modal scrims, print sheets, QR quiet zones, email previews).
**The Measured Contrast Rule.** Every text pair clears 4.5:1 and every control border clears 3:1 against ground and surface, in both themes. `app/globals.test.ts` checks this; a new token pair joins that test before it ships.
## Typography
**Display Font:** none (no display face)
**Body Font:** Inter (with ui-sans-serif, system-ui), self-hosted variable woff2 via next/font/local
**Label/Mono Font:** Inter; the mono role aliases sans
**Character:** One family doing every job, separated by weight and size only. Headings at 600 with a slight negative track; working text at 14px.
### Hierarchy
- **Headline** (600, 24px, -0.025em): the page title in the page header, one per page.
- **Title** (600, 16px, line-height 1): card titles ("Funnel", "By event"). Section headings h1 to h4 take 600 and -0.015em globally.
- **Body** (400, 14px): controls, table cells, form text, descriptions. The document base is 16px / 1.6 and inputs render 16px below the md breakpoint to avoid mobile zoom.
- **Label** (600, 12px, 0.025em, uppercase): table column headers only. Form labels are 14px sentence case.
- **Figure** (600, 24px, tabular numerals): KPI tile values; every other number, date and percentage also uses the tabular class at its own size.
### Named Rules
**The Aligned Figures Rule.** Any figure, ID, date or percentage carries tabular numerals (the `.tabular` class), so columns and KPI rows line up digit for digit.
## Layout
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.
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.
## 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.
### Shadow Vocabulary
- **Card** (`box-shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.04)`): cards and data-table frames.
- **Control** (`box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05)`): inputs, select triggers, outline buttons.
- **Float** (`box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`): select menus, dropdowns, popovers, toasts.
- **Modal** (`box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`): dialogs, over a 50% black scrim.
### Named Rules
**The Hairline First Rule.** Separation comes from the 1px hairline and the ground/surface step; shadow never replaces a border and never exceeds the four steps above.
## Shapes
Small, precise corners. Controls (buttons, inputs, selects, menus) are 6px; cards, table frames, tabs lists, nav items and dialogs are 8px; status and category pills and avatars are fully round. Inside a card, anything rounded takes the card's radius minus its padding with an 8px floor, so nested controls and tables render at 8px and corners stay concentric at every depth. The brand mark is a 24px blue square at 6px radius beside the "Co-Lite" wordmark in 18px semibold slate.
## Components
### Buttons
Quiet, compact, unmistakable.
- **Shape:** gently squared (6px), 36px tall; sm 32px, lg 40px, xs 24px. Icon buttons keep a 44px invisible hit area.
- **Primary:** Action Blue fill, white 14px medium text, 16px side padding; hover at 90% fill.
- **Outline:** ground fill, hairline border, control shadow; hover turns blue tint with deep blue ink. Used for secondary actions and pager controls.
- **Secondary:** slate tint fill, ink text. **Ghost:** no fill until hover tint (header icons, row actions). **Link:** blue text, underline on hover.
- **Destructive:** Signal Red fill; **destructive-outline:** red text and 40% red border on ground.
- **Focus:** border turns blue plus a 3px blue ring at 50%. **Disabled:** 50% opacity, no pointer.
- A selected preset in a segmented choice (This month / Last month / Custom) is the primary variant; the others are outline.
### Chips (status pills)
- **Style:** fully round, 12px medium text, 2px 8px padding. Semantic pills use their tone at 10% fill, 30% border, full-strength text; neutral uses slate tint with muted text.
- **State:** status uses positive / warning / negative; kinds use teal, violet or blue-tint "contrast". Every pill keeps its text label, so colour is never the only signal.
### Cards / Containers
- **Corner Style:** 8px.
- **Background:** white surface on the slate ground.
- **Shadow Strategy:** Card shadow (see Elevation).
- **Border:** 1px hairline.
- **Internal Padding:** 24px, with 24px between header, content and footer.
### Inputs / Fields
- **Style:** white field, 1px control-stroke border, 6px radius, 36px tall, 12px side padding, control shadow; placeholder in muted slate. Select triggers match exactly, with a 16px chevron at 50%.
- **Focus:** blue border plus 3px blue ring at 50%.
- **Error / Disabled:** `aria-invalid` turns the border Signal Red with a 20% red ring; disabled at 50% opacity.
- Menus (select content, dropdowns, the company picker) open as white floating panels with hairline border, 6px radius and Float shadow; dates use the styled date picker, never native date inputs.
### Data Tables
- 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.
### 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.
## Do's and Don'ts
### Do:
- **Do** reach for colour only through theme tokens; if a role is missing, add a token in `app/globals.css` (both themes) and a contrast pair in `app/globals.test.ts`.
- **Do** keep Action Blue for primary actions, links, focus and the active nav item.
- **Do** put every figure, date, ID and percentage on tabular numerals.
- **Do** use 36px controls at 6px radius and 8px cards with the card shadow and a hairline.
- **Do** border inputs and select triggers with the control stroke, not the hairline, so they reach 3:1.
- **Do** give every status pill a text label.
### Don't:
- **Don't** use Tailwind palette classes or raw white/black backgrounds outside the test's allowlist.
- **Don't** bring back the babyboo look: brown or gold primaries, DM Sans, 16px soft corners, gradient wordmarks, the giraffe-spot pattern.
- **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.
+69
View File
@@ -0,0 +1,69 @@
# Product
<!-- impeccable:product-schema 1 -->
## Platform
web
## Users
- **Office admins (primary).** Staff of INS and CV, and company-less super admins, working at a desk. They set up events and teams, manage guest lists and invitations, follow up and export leads, and manage users, roles, companies and privacy notices. When the needs of the two staff groups clash, the admin's needs win.
- **Booth staff.** Salespeople at an event, mostly on a phone. They show their personal QR code, capture visitors, and check their own leads.
- **Visitors and guests.** Members of the public on their own phone, with no account. They open a QR, invite or check-in link, fill in a short form and give consent.
## Product Purpose
Co-Lite turns event attendance into leads for one company group (INS and CV at go-live). It captures who registered, who was invited, and who actually came, through four routes: staff capture at the booth, walk-in QR codes, personal invite links, and self check-in at the door. Every lead is followed up from one listing.
Success at go-live (2027-01-15) means:
- every visitor at an INS or CV event becomes a lead with consent;
- admins can see invited, registered, attended and walk-in numbers against capacity;
- nothing is lost between the booth and follow-up.
## Positioning
An event-day lead tool, not a general CRM. Its core is the booth and the event day. Hosting events and a member web portal come later (phase 2): leave room for them, but do not design for them yet.
## Operating Context
- **Admins:** on desktop browsers in the office, before, during and after events.
- **Booth staff:** on phones at a busy booth, often one-handed. A QR code is shown full screen for a visitor to scan.
- **Visitors:** scan printed or on-screen QR codes on their own phones, often on venue Wi-Fi.
- **Invitations:** sent by email. Until an SMTP provider is set up, emails are only saved and listed under Emails, and admins copy links by hand.
- **Companies:** two companies (INS and CV) on one system. Staff see only their own company's data, and super admins see all.
## Capabilities and Constraints
- **Stack:** Next.js admin portal calling JSON admin APIs in mobile-api, with Java/Spring services behind an internal gateway.
- **Access:** screens are controlled by back-office modules assigned to roles (for example `BO_EVENTS`, `BO_EVENT_GUESTS`, `BO_LEADS_EDIT`, `BO_LEADS_EXPORT`). Staff sign in with company code, username and password.
- **Visitor pages are public:**
- `/r/<token>` walk-in registration;
- `/i/<token>` invite;
- `/c/<token>` check-in.
The privacy-notice consent on these pages is bilingual (English and Bahasa Malaysia) by spec.
- **Admin UI languages:** English and Bahasa Malaysia (locale switcher).
- **Not at go-live:** member app, member portal, rewards, built-in WhatsApp sending.
- **Undecided:** per-company logo or accent in the UI; a dark theme as a supported default.
## Brand Commitments
- The product name is **Co-Lite**.
- The footer keeps "Powered by Containerverse Sdn. Bhd."
- The current look (inherited from the babyboo admin portal) is not binding, and the owner welcomes a complete revamp.
- Visual direction (chosen 2026-12-01): the category standard for admin tools, executed with care: white and slate, one blue accent, Inter, no brand gimmicks. The quality bar is Stripe Dashboard, Linear and Vercel.
## Evidence on Hand
- There are no real customer data, testimonials or case studies.
- Local data is test-only (for example the event "LC CV Expo" and test registrations).
- Tastefully customer data must never be copied in.
## Product Principles
1. **Admins first.** Dense, scannable lists and forms serve the office user; booth and visitor screens stay just as fast in their own context.
2. **Every route counts the same.** Staff capture, QR, invite and check-in all end up as one lead, and the numbers agree everywhere.
3. **Consent before capture.** No visitor data is kept without the company's privacy notice and the visitor's consent.
4. **One company at a time.** Staff only ever see their own company's events, leads and guests.
5. **Leads now, events later.** Build for event leads today without locking out event hosting tomorrow.
@@ -13,7 +13,7 @@ vi.mock("@/app/lib/AdminAuthContext", () => ({ useAdminAuth: mocks.useAdminAuth
import CompaniesPage from "./page";
beforeEach(() => {
mocks.apiGet.mockReset().mockResolvedValue([{ id: 1, name: "Insight", code: "ins", status: "A" }]);
mocks.apiGet.mockReset().mockResolvedValue([{ id: 1, name: "Insight", code: "INS", status: "A" }]);
mocks.apiPost.mockReset();
mocks.useAdminAuth.mockReset().mockReturnValue({ loading: false, isSuper: true });
});
@@ -24,7 +24,7 @@ describe("CompaniesPage fixes", () => {
await userEvent.click(await screen.findByRole("button", { name: "Change code" }));
const input = screen.getByLabelText("New code");
await userEvent.clear(input);
await userEvent.type(input, " INS ");
await userEvent.type(input, " ins ");
await userEvent.click(screen.getByRole("button", { name: "Confirm" }));
expect(mocks.apiPost).not.toHaveBeenCalled();
expect(screen.getByRole("alert")).toBeInTheDocument();
@@ -46,6 +46,19 @@ describe("CompaniesPage", () => {
);
});
it("saves the status chosen in the styled dropdown", async () => {
mocks.apiPost.mockResolvedValue({ id: 1 });
render(<CompaniesPage />);
const row = (await screen.findByText("Insight")).closest("tr")!;
await userEvent.click(within(row).getByRole("button", { name: "Edit" }));
await userEvent.click(screen.getByLabelText("Status"));
await userEvent.click(await screen.findByRole("option", { name: "Inactive" }));
await userEvent.click(screen.getByRole("button", { name: /save/i }));
await waitFor(() =>
expect(mocks.apiPost).toHaveBeenCalledWith("/api/companies", { id: 1, name: "Insight", status: "I" }),
);
});
it("edits name and status only, with no code field", async () => {
mocks.apiPost.mockResolvedValue({ id: 1 });
render(<CompaniesPage />);
+11 -13
View File
@@ -6,6 +6,7 @@ import type { ColumnDef } from "@tanstack/react-table";
import { Button } from "@/app/components/ui/button";
import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/app/components/ui/dialog";
import { DataTable } from "@/app/components/ui/data-table";
import { PageHeader } from "@/app/components/ui/page-header";
@@ -39,7 +40,7 @@ function CompanyDialog({ state, onClose, onSaved }: { state: DialogState; onClos
if ((mode === "code" ? newCode : form.code).trim() === "" && (mode === "code" || !form.id)) {
return setError(t("CompCodeRequired"));
}
if (mode === "code" && newCode.trim().toLowerCase() === company.code.toLowerCase()) {
if (mode === "code" && newCode.trim().toUpperCase() === company.code) {
return setError(t("CompCodeUnchanged"));
}
setError(null);
@@ -74,7 +75,7 @@ function CompanyDialog({ state, onClose, onSaved }: { state: DialogState; onClos
<p className="text-sm">{t("CompChangeCodeWarning")}</p>
<div className="space-y-1.5">
<Label htmlFor="company-new-code">{t("CompNewCode")}</Label>
<Input id="company-new-code" value={newCode} onChange={(e) => setNewCode(e.target.value)} disabled={saving} />
<Input id="company-new-code" className="uppercase" value={newCode} onChange={(e) => setNewCode(e.target.value)} disabled={saving} />
</div>
</>
) : (
@@ -86,21 +87,18 @@ function CompanyDialog({ state, onClose, onSaved }: { state: DialogState; onClos
{!form.id && (
<div className="space-y-1.5">
<Label htmlFor="company-code">{t("Code")}</Label>
<Input id="company-code" value={form.code} onChange={(e) => setForm((f) => ({ ...f, code: e.target.value }))} disabled={saving} />
<Input id="company-code" className="uppercase" value={form.code} onChange={(e) => setForm((f) => ({ ...f, code: e.target.value }))} disabled={saving} />
</div>
)}
<div className="space-y-1.5">
<Label htmlFor="company-status">{t("Status")}</Label>
<select
id="company-status"
value={form.status}
onChange={(e) => setForm((f) => ({ ...f, status: e.target.value as AdminCompany["status"] }))}
disabled={saving}
className="h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm"
>
<option value="A">{t("CompActive")}</option>
<option value="I">{t("CompInactive")}</option>
</select>
<Select value={form.status} onValueChange={(v) => setForm((f) => ({ ...f, status: v as AdminCompany["status"] }))} disabled={saving}>
<SelectTrigger id="company-status" className="w-full"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="A">{t("CompActive")}</SelectItem>
<SelectItem value="I">{t("CompInactive")}</SelectItem>
</SelectContent>
</Select>
</div>
</>
)}
@@ -0,0 +1,54 @@
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 mocks = vi.hoisted(() => ({ apiGet: vi.fn(), apiPost: vi.fn(), useAdminAuth: vi.fn() }));
vi.mock("@/app/lib/clientApi", async (importOriginal) => ({
ApiError: (await importOriginal<typeof import("@/app/lib/clientApi")>()).ApiError,
apiGet: mocks.apiGet,
apiPost: mocks.apiPost,
}));
vi.mock("@/app/lib/AdminAuthContext", () => ({ useAdminAuth: mocks.useAdminAuth }));
import CompaniesPage from "./page";
beforeEach(() => {
mocks.apiGet.mockReset().mockResolvedValue([{ id: 2, name: "Clever", code: "cv", status: "A" }]);
mocks.apiPost.mockReset().mockResolvedValue({ id: 2, code: "CV" });
mocks.useAdminAuth.mockReset().mockReturnValue({ loading: false, isSuper: true });
});
async function openChangeCode() {
render(<CompaniesPage />);
const row = (await screen.findByText("Clever")).closest("tr")!;
await userEvent.click(within(row).getByRole("button", { name: /change code/i }));
return screen.getByLabelText("New code");
}
describe("CompaniesPage company codes in capitals", () => {
it("treats a change of case as a change and posts it", async () => {
const code = await openChangeCode();
await userEvent.clear(code);
await userEvent.type(code, "CV");
await userEvent.click(screen.getByRole("button", { name: /confirm/i }));
await waitFor(() => expect(mocks.apiPost).toHaveBeenCalledWith("/api/companies/2/code", { code: "CV" }));
});
it("still refuses the same code typed in any case", async () => {
mocks.apiGet.mockResolvedValue([{ id: 2, name: "Clever", code: "CV", status: "A" }]);
const code = await openChangeCode();
await userEvent.clear(code);
await userEvent.type(code, "cv");
await userEvent.click(screen.getByRole("button", { name: /confirm/i }));
expect(await screen.findByRole("alert")).toBeInTheDocument();
expect(mocks.apiPost).not.toHaveBeenCalled();
});
it("shows code inputs in capitals", async () => {
const code = await openChangeCode();
expect(code).toHaveClass("uppercase");
await userEvent.keyboard("{Escape}");
await userEvent.click(screen.getByRole("button", { name: /add company/i }));
expect(screen.getByLabelText("Code")).toHaveClass("uppercase");
});
});
@@ -49,7 +49,7 @@ describe("UserForm company", () => {
const user = userEvent.setup();
render(<UserForm onSubmit={onSubmit} />);
const company = await screen.findByRole("combobox", { name: "Company" });
expect(company).toHaveValue("2");
expect(company).toHaveTextContent("CV");
await fillUser(user);
await user.click(screen.getByLabelText("HQ"));
await user.click(screen.getByRole("button", { name: /create|save/i }));
@@ -60,7 +60,8 @@ describe("UserForm company", () => {
const onSubmit = vi.fn().mockResolvedValue(undefined);
const user = userEvent.setup();
render(<UserForm onSubmit={onSubmit} />);
await user.selectOptions(await screen.findByRole("combobox", { name: "Company" }), "super");
await user.click(await screen.findByRole("combobox", { name: "Company" }));
await user.click(await screen.findByRole("option", { name: "Super admin (no company)" }));
await fillUser(user);
await user.click(screen.getByLabelText("HQ"));
await user.click(screen.getByRole("button", { name: /create|save/i }));
@@ -106,6 +107,13 @@ describe("UserForm company", () => {
await user.click(screen.getByRole("button", { name: /create|save/i }));
expect(await screen.findByText("Choose a company.")).toBeInTheDocument();
});
it("lists only the company codes and Super admin in the Company menu, with no blank option", async () => {
mocks.useCompanyScope.mockReturnValue(scope(undefined));
const user = userEvent.setup();
render(<UserForm onSubmit={vi.fn()} />);
await user.click(await screen.findByRole("combobox", { name: "Company" }));
expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["INS", "CV", "Super admin (no company)"]);
});
});
describe("EventForm company", () => {
@@ -113,7 +121,7 @@ describe("EventForm company", () => {
const onSubmit = vi.fn().mockResolvedValue(undefined);
const user = userEvent.setup();
render(<EventForm onSubmit={onSubmit} />);
expect(await screen.findByRole("combobox", { name: "Company" })).toHaveValue("2");
expect(await screen.findByRole("combobox", { name: "Company" })).toHaveTextContent("CV");
await user.type(screen.getByLabelText("Name"), "Expo");
await user.type(screen.getByLabelText("Location"), "KL");
pickDate("Start date", "2026-12-01");
@@ -133,7 +141,8 @@ describe("EventForm company", () => {
const user = userEvent.setup();
const { unmount } = render(<EventForm onSubmit={vi.fn()} />);
await waitFor(() => expect(mocks.listSalespersonOptions).toHaveBeenLastCalledWith(2));
await user.selectOptions(screen.getByRole("combobox", { name: "Company" }), "1");
await user.click(screen.getByRole("combobox", { name: "Company" }));
await user.click(await screen.findByRole("option", { name: "INS" }));
await waitFor(() => expect(mocks.listSalespersonOptions).toHaveBeenLastCalledWith(1));
unmount();
mocks.useCompanyScope.mockReturnValue(scope(1));
@@ -161,4 +170,38 @@ describe("EventForm company required", () => {
expect(onSubmit).not.toHaveBeenCalled();
expect(await screen.findByText("Choose a company.")).toBeInTheDocument();
});
it("lists only the company codes in the Company menu, with no blank option", async () => {
mocks.useCompanyScope.mockReturnValue(scope(undefined));
const user = userEvent.setup();
render(<EventForm onSubmit={vi.fn()} />);
await user.click(await screen.findByRole("combobox", { name: "Company" }));
expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["INS", "CV"]);
});
});
describe("company picker placeholder and team hint", () => {
it("shows a placeholder in the empty company picker on the user form", async () => {
mocks.useCompanyScope.mockReturnValue(scope(undefined));
render(<UserForm onSubmit={vi.fn()} />);
expect(await screen.findByRole("combobox", { name: "Company" })).toHaveTextContent("Select a company");
});
it("shows a placeholder in the empty company picker on the event form", async () => {
mocks.useCompanyScope.mockReturnValue(scope(undefined));
render(<EventForm onSubmit={vi.fn()} />);
expect(await screen.findByRole("combobox", { name: "Company" })).toHaveTextContent("Select a company");
});
it("hints to choose a company before the team can be listed, then lists it", async () => {
mocks.useCompanyScope.mockReturnValue(scope(undefined));
const user = userEvent.setup();
render(<EventForm onSubmit={vi.fn()} />);
expect(await screen.findByText("Choose a company to list its team")).toBeInTheDocument();
expect(screen.queryByRole("checkbox", { name: /Alice/ })).not.toBeInTheDocument();
await user.click(screen.getByRole("combobox", { name: "Company" }));
await user.click(await screen.findByRole("option", { name: "CV" }));
expect(await screen.findByRole("checkbox", { name: /Alice/ })).toBeInTheDocument();
expect(screen.queryByText("Choose a company to list its team")).not.toBeInTheDocument();
});
});
@@ -3,6 +3,10 @@
import { useAdminAuth } from "@/app/lib/AdminAuthContext";
import { useCompanyScope } from "@/app/lib/CompanyScope";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
// Radix Select rejects "" as an item value, so "All companies" is this sentinel, mapped to undefined.
const ALL = "all";
// Header company filter; super admins only (staff are always scoped by the server).
export default function CompanyPicker() {
@@ -11,16 +15,16 @@ export default function CompanyPicker() {
const t = useT();
if (!isSuper) return null;
return (
<select
aria-label={t("Company")}
value={companyId ?? ""}
onChange={(e) => setCompanyId(e.target.value ? Number(e.target.value) : undefined)}
className="h-9 rounded-md border bg-background px-2 text-sm"
>
<option value="">{t("AllCompanies")}</option>
{companies.map((c) => (
<option key={c.id} value={c.id}>{c.code}</option>
))}
</select>
<Select value={companyId === undefined ? ALL : String(companyId)} onValueChange={(v) => setCompanyId(v === ALL ? undefined : Number(v))}>
<SelectTrigger aria-label={t("Company")} className="min-w-36">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value={ALL}>{t("AllCompanies")}</SelectItem>
{companies.map((c) => (
<SelectItem key={c.id} value={String(c.id)}>{c.code}</SelectItem>
))}
</SelectContent>
</Select>
);
}
@@ -55,7 +55,7 @@ export default function Header() {
const initial = (name ?? "?").slice(0, 1).toUpperCase();
return (
<header className="sticky top-0 z-30 flex h-16 shrink-0 items-center gap-2 border-b bg-card px-4">
<header className="sticky top-0 z-30 flex h-14 shrink-0 items-center gap-2 border-b bg-card px-4">
<Sheet open={menuOpen} onOpenChange={setMenuOpen}>
<Button
variant="ghost"
@@ -68,7 +68,7 @@ export default function Header() {
</Button>
<SheetContent side="left" className="w-[var(--sidebar-width)] max-w-[85vw] bg-sidebar p-0">
<SheetTitle className="sr-only">{t("HeaderMenu")}</SheetTitle>
<div className="flex h-16 shrink-0 items-center border-b px-4">
<div className="flex h-14 shrink-0 items-center border-b px-4">
<BrandLink onClick={() => setMenuOpen(false)} />
</div>
<SidebarNav onNavigate={() => setMenuOpen(false)} />
@@ -14,7 +14,7 @@ export default function PoweredBy({ compact = false }: { compact?: boolean }) {
target="_blank"
rel="noopener noreferrer"
title={`${POWERED_BY.prefix} ${POWERED_BY.name}`}
className="text-xs text-muted-foreground underline hover:text-foreground"
className="text-xs text-muted-foreground hover:text-foreground hover:underline"
>
{/* The accessible name starts with the visible text (WCAG 2.5.3 Label in Name). */}
{POWERED_BY.short}{" "}
@@ -29,7 +29,7 @@ export default function PoweredBy({ compact = false }: { compact?: boolean }) {
href={POWERED_BY.href}
target="_blank"
rel="noopener noreferrer"
className="underline hover:text-foreground"
className="whitespace-nowrap hover:text-foreground hover:underline"
>
{POWERED_BY.name}
</a>
@@ -392,9 +392,9 @@ describe("Sidebar icon rail", () => {
const sales = screen.getByRole("button", { name: "Sales & orders" });
const stock = screen.getByRole("button", { name: "Stock" });
expect(sales).toHaveAttribute("data-current", "true");
expect(sales.className).toContain("bg-sidebar-primary");
expect(sales).toHaveClass("bg-sidebar-accent", "text-sidebar-accent-foreground");
expect(stock).not.toHaveAttribute("data-current");
expect(stock.className).not.toContain("bg-sidebar-primary");
expect(stock).not.toHaveClass("bg-sidebar-accent");
});
it("keeps a current top-level leaf filled in the rail", async () => {
@@ -405,7 +405,7 @@ describe("Sidebar icon rail", () => {
const link = screen.getByRole("link", { name: "Dashboard" });
expect(link).toHaveAttribute("aria-current", "page");
expect(link.className).toContain("bg-sidebar-primary");
expect(link).toHaveClass("bg-sidebar-accent", "text-sidebar-accent-foreground");
});
it("keeps the footer credit visible in a compact form", async () => {
@@ -430,7 +430,7 @@ describe("Sidebar icon rail", () => {
expect(within(brandRow()).queryByRole("link")).toBeNull();
expect(within(brandRow()).getByRole("button", { name: "Expand sidebar" })).toBeInTheDocument();
expect(brandRow()).toHaveClass("h-16", "justify-center");
expect(brandRow()).toHaveClass("h-14", "justify-center");
await user.click(screen.getByRole("button", { name: "Expand sidebar" }));
expect(within(brandRow()).getByRole("link", { name: /Co-Lite/ })).toBeInTheDocument();
@@ -488,3 +488,35 @@ describe("Sidebar icon rail", () => {
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
});
});
// add-visual-foundation: Product Wordmark / One Accent Colour.
describe("Sidebar visual identity", () => {
afterEach(() => {
state.pathname = "/";
});
it("shows the Co-Lite mark and a solid wordmark, not gradient-filled text", () => {
state.links = [];
const { container } = render(<Sidebar />);
const word = screen.getByText("Co-Lite");
expect(word).not.toHaveClass("brand-wordmark");
expect(word.className).not.toMatch(/gradient|text-transparent/);
expect(container.querySelector("[data-slot='brand-mark']")).not.toBeNull();
});
it("marks only the current top-level item in the accent, not a solid primary fill", () => {
state.links = [
{ name: "Events", url: "/events", iconName: "Users", children: [] },
{ name: "Leads", url: "/leads", iconName: "Users", children: [] },
];
state.pathname = "/events";
render(<Sidebar />);
const events = screen.getByRole("link", { name: "Events" });
const leads = screen.getByRole("link", { name: "Leads" });
expect(events).toHaveAttribute("aria-current", "page");
expect(events).toHaveClass("bg-sidebar-accent", "text-sidebar-accent-foreground");
expect(events).not.toHaveClass("bg-sidebar-primary");
expect(leads).not.toHaveClass("bg-sidebar-accent");
expect(leads).not.toHaveClass("bg-sidebar-primary");
});
});
@@ -44,10 +44,8 @@ function NavNode({ link, depth, trail, onNavigate }: { link: SidebarLink; depth:
"focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none",
depth === 0 ? "min-h-11 text-sm font-medium" : "min-h-9 text-sm",
active
? depth === 0
? "bg-sidebar-primary text-sidebar-primary-foreground"
: "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
: "text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
? "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
: "text-muted-foreground hover:bg-muted hover:text-foreground",
)}
>
{/* eslint-disable-next-line react-hooks/static-components -- Icon comes from
@@ -98,7 +96,7 @@ function NavGroup({
"focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none",
depth === 0 ? "min-h-11 text-sm font-medium" : "min-h-9 text-sm",
active ? "text-sidebar-accent-foreground" : "text-muted-foreground",
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
"hover:bg-muted hover:text-foreground",
)}
>
{Icon && <Icon aria-hidden="true" className="size-5 shrink-0" />}
@@ -124,8 +122,8 @@ const railItemClass = cn(
"flex size-11 items-center justify-center rounded-lg transition-colors",
"focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none",
);
const railIdleClass = "text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground";
const railActiveClass = "bg-sidebar-primary text-sidebar-primary-foreground";
const railIdleClass = "text-muted-foreground hover:bg-muted hover:text-foreground";
const railActiveClass = "bg-sidebar-accent text-sidebar-accent-foreground";
function RailNode({ link, trail }: { link: SidebarLink; trail: SidebarLink[] }) {
const t = useT();
@@ -241,7 +239,8 @@ export function BrandLink({ onClick }: { onClick?: () => void }) {
onClick={onClick}
className="flex items-center gap-2.5 rounded-md focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none"
>
<span className="brand-wordmark text-lg">{BRAND}</span>
<span data-slot="brand-mark" aria-hidden="true" className="size-6 shrink-0 rounded-md bg-primary" />
<span className="text-lg font-semibold tracking-tight text-foreground">{BRAND}</span>
</Link>
);
}
@@ -270,7 +269,7 @@ export default function Sidebar() {
// Expanded on the server and during hydration; the stored choice is applied after mount so both renders agree.
const [collapsed, setCollapsed] = useState(false);
// The width animates only after a toggle: applying a stored collapse on load must not animate
// 272 -> 76px (and reflow the page) on every navigation.
// 240 -> 76px (and reflow the page) on every navigation.
const [animate, setAnimate] = useState(false);
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect -- localStorage is only readable after mount; reading it during render would make the hydration render disagree with the server.
@@ -297,7 +296,7 @@ export default function Sidebar() {
{/* Header-high in both states so its border lines up with the header's; the rail shows only the toggle. */}
<div
className={cn(
"flex h-16 shrink-0 items-center border-b",
"flex h-14 shrink-0 items-center border-b",
collapsed ? "justify-center" : "justify-between gap-2 px-4",
)}
>
@@ -320,7 +319,7 @@ export default function Sidebar() {
<SidebarNav collapsed={collapsed} />
<div className={cn("shrink-0 border-t text-center", collapsed ? "px-1 py-3" : "p-3")}>
<div className={cn("shrink-0 border-t", collapsed ? "px-1 py-3" : "p-3")}>
<PoweredBy compact={collapsed} />
</div>
</aside>
@@ -40,9 +40,9 @@ function bucketLabel(bucket: string, kind: "DAY" | "MONTH"): string {
function Tile({ label, value }: { label: string; value: string }) {
return (
<div role="group" aria-label={label} className="rounded-xl border bg-card p-4">
<div role="group" aria-label={label} className="flex flex-col rounded-lg border bg-card shadow-card p-4">
<div className="text-sm text-muted-foreground">{label}</div>
<div className="mt-1 text-2xl font-semibold tabular">{value}</div>
<div className="mt-auto pt-1 text-2xl font-semibold tabular">{value}</div>
</div>
);
}
@@ -5,6 +5,7 @@ import { Button } from "@/app/components/ui/button";
import { Checkbox } from "@/app/components/ui/checkbox";
import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
import { Switch } from "@/app/components/ui/switch";
import { DatePicker } from "@/app/components/ui/date-picker";
import { ErrorState } from "@/app/components/ui/states";
@@ -179,22 +180,23 @@ export function EventForm({ initial, onSubmit, submitLabel }: EventFormProps) {
{showCompany && (
<div className="space-y-1.5">
<Label htmlFor="evt-company">{t("Company")}</Label>
<select
id="evt-company"
<Select
value={companyChoice}
onChange={(e) => {
setCompanyChoice(e.target.value);
onValueChange={(v) => {
setCompanyChoice(v);
setSelectedIds(new Set()); // the team is company-specific
}}
disabled={saving}
aria-invalid={!!fieldErrors.company}
className="h-9 w-full rounded-md border bg-background px-2 text-sm"
>
<option value="" />
{scope.companies.map((c) => (
<option key={c.id} value={c.id}>{c.code}</option>
))}
</select>
<SelectTrigger id="evt-company" aria-invalid={!!fieldErrors.company} className="w-full">
<SelectValue placeholder={t("SelectCompany")} />
</SelectTrigger>
<SelectContent>
{scope.companies.map((c) => (
<SelectItem key={c.id} value={String(c.id)}>{c.code}</SelectItem>
))}
</SelectContent>
</Select>
{fieldErrors.company && (
<p role="alert" className="text-sm text-destructive">
{fieldErrors.company}
@@ -296,7 +298,9 @@ export function EventForm({ initial, onSubmit, submitLabel }: EventFormProps) {
</p>
)}
<div className="max-h-48 space-y-1 overflow-y-auto rounded-md border p-2">
{loadingPickers ? (
{showCompany && !companyChoice ? (
<p className="text-sm text-muted-foreground">{t("TeamNeedsCompany")}</p>
) : loadingPickers ? (
<p className="text-sm text-muted-foreground">{t("Loading")}</p>
) : (
optionList.map((opt) => {
@@ -24,7 +24,7 @@ const badgeVariants = cva(
// Category tones (feedback 2026-10-21: every type/fulfilment pill was the same beige). For
// kinds, not states — status keeps positive/warning/negative. Each pill keeps its text label,
// so colour is never the only signal.
contrast: "border-contrast/30 bg-contrast-soft text-contrast-foreground",
contrast: "bg-accent text-accent-foreground",
teal: "border-chart-2/30 bg-chart-2/10 text-chart-2",
violet: "border-chart-4/30 bg-chart-4/10 text-chart-4",
link: "text-primary underline-offset-4 [a&]:hover:underline",
@@ -7,7 +7,7 @@ function Card({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card"
className={cn(
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
"flex flex-col gap-6 rounded-lg border bg-card py-6 text-card-foreground shadow-card",
className
)}
{...props}
@@ -75,7 +75,7 @@ function DialogContent({
ref={setRefs}
data-slot="dialog-content"
className={cn(
"fixed inset-0 z-50 m-auto grid h-fit w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
"fixed inset-0 z-50 m-auto grid h-fit w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border bg-card p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
className
)}
{...props}
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
type={type}
data-slot="input"
className={cn(
"h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
"h-9 w-full min-w-0 rounded-md border border-input bg-card px-3 py-1 text-base shadow-sm transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
"aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 dark:aria-[invalid=true]:ring-destructive/40",
className
@@ -37,7 +37,7 @@ function SelectTrigger({
data-slot="select-trigger"
data-size={size}
className={cn(
"flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 [&>[data-slot=select-value]]:line-clamp-1 [&>[data-slot=select-value]]:min-w-0 [&>[data-slot=select-value]]:overflow-hidden [&>[data-slot=select-value]]:flex [&>[data-slot=select-value]]:items-center [&>[data-slot=select-value]]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-[invalid=true]:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
"flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm whitespace-nowrap shadow-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 [&>[data-slot=select-value]]:line-clamp-1 [&>[data-slot=select-value]]:min-w-0 [&>[data-slot=select-value]]:overflow-hidden [&>[data-slot=select-value]]:flex [&>[data-slot=select-value]]:items-center [&>[data-slot=select-value]]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-[invalid=true]:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
className
)}
{...props}
@@ -76,7 +76,7 @@ export function ErrorState({
export function TableSkeleton({ rows = 5, columns = 4 }: { rows?: number; columns?: number }) {
const t = useT()
return (
<div role="status" className="space-y-3 rounded-xl border bg-card p-3">
<div role="status" className="space-y-3 rounded-lg border bg-card shadow-card p-3">
<span className="sr-only">{t("UiLoading")}</span>
{Array.from({ length: rows }).map((_, r) => (
<div key={r} className="flex gap-3">
@@ -23,7 +23,7 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
return (
<thead
data-slot="table-header"
// A gold header row with dusty-blue text (--table-head; owner request 2026-10-23). Opaque, so
// A slate header row (--table-head). Opaque, so
// a sticky header still covers the rows scrolling under it.
className={cn("bg-table-head [&_tr]:border-b [&_tr]:hover:bg-transparent", className)}
{...props}
@@ -7,6 +7,7 @@ import { Button } from "@/app/components/ui/button";
import { Checkbox } from "@/app/components/ui/checkbox";
import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
import { Switch } from "@/app/components/ui/switch";
import { ErrorState } from "@/app/components/ui/states";
import { roleLabel } from "@/app/lib/roleLabel";
@@ -220,20 +221,17 @@ export function UserForm({ initial, onSubmit, submitLabel, withPassword }: UserF
{showCompany && (
<div className="space-y-1.5">
<Label htmlFor="user-company">{t("Company")}</Label>
<select
id="user-company"
value={company}
onChange={(e) => setCompany(e.target.value)}
disabled={saving}
aria-invalid={!!fieldErrors.company}
className="h-9 w-full rounded-md border bg-background px-2 text-sm"
>
<option value="" />
{scope.companies.map((c) => (
<option key={c.id} value={c.id}>{c.code}</option>
))}
<option value="super">{t("CompanySuperAdmin")}</option>
</select>
<Select value={company} onValueChange={(v) => setCompany(v)} disabled={saving}>
<SelectTrigger id="user-company" aria-invalid={!!fieldErrors.company} className="w-full">
<SelectValue placeholder={t("SelectCompany")} />
</SelectTrigger>
<SelectContent>
{scope.companies.map((c) => (
<SelectItem key={c.id} value={String(c.id)}>{c.code}</SelectItem>
))}
<SelectItem value="super">{t("CompanySuperAdmin")}</SelectItem>
</SelectContent>
</Select>
{fieldErrors.company && (
<p role="alert" className="text-sm text-destructive">
{fieldErrors.company}
@@ -59,6 +59,12 @@ beforeEach(() => {
mocks.useAdminAuth.mockReset().mockReturnValue({ loading: false, hasModule: () => true });
});
// Radix selects: open the combobox, then click the option (a native selectOptions no longer applies).
const pick = async (user: ReturnType<typeof userEvent.setup>, label: string, option: string) => {
await user.click(screen.getByLabelText(label));
await user.click(await screen.findByRole("option", { name: option }));
};
describe("EventLeadPage", { timeout: 20000 }, () => {
it("renders NotAuthorized when the module is absent", () => {
mocks.useAdminAuth.mockReturnValue({ loading: false, hasModule: () => false });
@@ -86,9 +92,9 @@ describe("EventLeadPage", { timeout: 20000 }, () => {
it("prefills the editable fields from the event lead", async () => {
await open();
expect(screen.getByLabelText("Salesperson")).toHaveValue("7");
expect(screen.getByLabelText("Temperature")).toHaveValue("WARM");
expect(screen.getByLabelText("Status")).toHaveValue("CONTACTED");
expect(screen.getByLabelText("Salesperson")).toHaveTextContent("Jane Sales");
expect(screen.getByLabelText("Temperature")).toHaveTextContent("Warm");
expect(screen.getByLabelText("Status")).toHaveTextContent("Contacted");
expect(screen.getByLabelText("Product A")).toBeChecked();
expect(screen.getByLabelText("Next follow-up")).toHaveValue("01/12/2026");
expect(screen.getByLabelText("Notes")).toHaveValue("Call back");
@@ -96,7 +102,8 @@ describe("EventLeadPage", { timeout: 20000 }, () => {
it("keeps the current salesperson selectable when not on the event team list", async () => {
await open();
const select = screen.getByLabelText("Salesperson");
await userEvent.setup().click(screen.getByLabelText("Salesperson"));
const select = await screen.findByRole("listbox");
expect(within(select).getByRole("option", { name: "Jane Sales" })).toBeInTheDocument();
expect(within(select).getByRole("option", { name: "Bob Other" })).toBeInTheDocument();
expect(within(select).getByRole("option", { name: "None" })).toBeInTheDocument();
@@ -128,9 +135,9 @@ describe("EventLeadPage", { timeout: 20000 }, () => {
it("saves edited values", async () => {
const user = await open();
await user.selectOptions(screen.getByLabelText("Salesperson"), "8");
await user.selectOptions(screen.getByLabelText("Temperature"), "HOT");
await user.selectOptions(screen.getByLabelText("Status"), "WON");
await pick(user, "Salesperson", "Bob Other");
await pick(user, "Temperature", "Hot");
await pick(user, "Status", "Won");
await user.click(screen.getByLabelText("Product B"));
await user.click(screen.getByLabelText("Product C"));
pickDate("Next follow-up", "2026-12-05");
@@ -146,8 +153,8 @@ describe("EventLeadPage", { timeout: 20000 }, () => {
it("sends null for emptied fields", async () => {
const user = await open();
await user.selectOptions(screen.getByLabelText("Salesperson"), "");
await user.selectOptions(screen.getByLabelText("Temperature"), "");
await pick(user, "Salesperson", "None");
await pick(user, "Temperature", "None");
await user.clear(screen.getByLabelText("Notes"));
await user.click(screen.getByLabelText("Product A"));
await user.click(screen.getByLabelText("Product B"));
@@ -7,6 +7,7 @@ import { Badge } from "@/app/components/ui/badge";
import { Button } from "@/app/components/ui/button";
import { DatePicker } from "@/app/components/ui/date-picker";
import { Label } from "@/app/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
import { PageHeader } from "@/app/components/ui/page-header";
import { EmptyState, ErrorState, TableSkeleton } from "@/app/components/ui/states";
import { useAdminAuth } from "@/app/lib/AdminAuthContext";
@@ -27,7 +28,9 @@ const CODE_MESSAGE: Record<string, string> = {
INVALID_VALUE: "LeadErrInvalidValue",
};
const FIELDS = ["salespersonId", "temperature", "status", "interestIds", "nextFollowUpDate", "notes"];
const SELECT_CLASS = "min-h-11 w-full rounded-md border border-input bg-transparent px-3 text-base shadow-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-[invalid=true]:border-destructive dark:bg-input/30";
// Radix Select rejects "" as an item value, so "None" is this sentinel, mapped back to "".
const NONE = "none";
const TEXTAREA_CLASS = "min-h-11 w-full rounded-md border border-input bg-card px-3 text-base shadow-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-[invalid=true]:border-destructive dark:bg-input/30";
const TALL = "min-h-11";
type Loaded = { lead: EventLeadRow; salespeople: SalespersonOption[]; interests: InterestOption[] };
@@ -156,19 +159,28 @@ function EventLead() {
</div>
{field("salespersonId", t("LeadSalesperson"),
<select {...fieldProps("salespersonId")} className={SELECT_CLASS} value={salespersonId} onChange={(e) => setSalespersonId(e.target.value)} disabled={busy}>
<option value="">{t("LeadNone")}</option>
{salespeople.map((s) => <option key={s.id} value={String(s.id)}>{s.name}</option>)}
</select>)}
<Select value={salespersonId || NONE} onValueChange={(v) => setSalespersonId(v === NONE ? "" : v)} disabled={busy}>
<SelectTrigger {...fieldProps("salespersonId")} className="min-h-11 w-full"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value={NONE}>{t("LeadNone")}</SelectItem>
{salespeople.map((s) => <SelectItem key={s.id} value={String(s.id)}>{s.name}</SelectItem>)}
</SelectContent>
</Select>)}
{field("temperature", t("LeadTemperature"),
<select {...fieldProps("temperature")} className={SELECT_CLASS} value={temperature} onChange={(e) => setTemperature(e.target.value)} disabled={busy}>
<option value="">{t("LeadNone")}</option>
{TEMPERATURES.map(([v, k]) => <option key={v} value={v}>{t(k)}</option>)}
</select>)}
<Select value={temperature || NONE} onValueChange={(v) => setTemperature(v === NONE ? "" : v)} disabled={busy}>
<SelectTrigger {...fieldProps("temperature")} className="min-h-11 w-full"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value={NONE}>{t("LeadNone")}</SelectItem>
{TEMPERATURES.map(([v, k]) => <SelectItem key={v} value={v}>{t(k)}</SelectItem>)}
</SelectContent>
</Select>)}
{field("status", t("LeadStatus"),
<select {...fieldProps("status")} className={SELECT_CLASS} value={status} onChange={(e) => setStatus(e.target.value)} disabled={busy}>
{STATUSES.map(([v, k]) => <option key={v} value={v}>{t(k)}</option>)}
</select>)}
<Select value={status} onValueChange={setStatus} disabled={busy}>
<SelectTrigger {...fieldProps("status")} className="min-h-11 w-full"><SelectValue /></SelectTrigger>
<SelectContent>
{STATUSES.map(([v, k]) => <SelectItem key={v} value={v}>{t(k)}</SelectItem>)}
</SelectContent>
</Select>)}
<fieldset {...fieldProps("interestIds")} className="space-y-1">
<legend className="mb-1.5 text-sm font-medium">{t("LeadInterests")}</legend>
@@ -184,7 +196,7 @@ function EventLead() {
{field("nextFollowUpDate", t("LeadNextFollowUp"),
<DatePicker {...fieldProps("nextFollowUpDate")} className="h-11" value={nextFollowUpDate} onChange={setNextFollowUpDate} disabled={busy} />)}
{field("notes", t("LeadNotes"),
<textarea {...fieldProps("notes")} className={`${SELECT_CLASS} py-2`} rows={3} value={notes} onChange={(e) => setNotes(e.target.value)} disabled={busy} />)}
<textarea {...fieldProps("notes")} className={`${TEXTAREA_CLASS} py-2`} rows={3} value={notes} onChange={(e) => setNotes(e.target.value)} disabled={busy} />)}
<div className="flex flex-col-reverse gap-3 sm:flex-row">
{backLink}
@@ -27,6 +27,11 @@ import { ApiError } from "@/app/lib/clientApi";
import { memoryRouter } from "@/test/memoryRouter";
import NewEventLeadPage from "./page";
// Radix selects: open the combobox, then click the option (a native selectOptions no longer applies).
const pick = async (user: ReturnType<typeof userEvent.setup>, label: string, option: string) => {
await user.click(screen.getByLabelText(label));
await user.click(await screen.findByRole("option", { name: option }));
};
const SERVER_MSG = "Server says: internal detail xyz";
const apiError = (code: string, extra: { errors?: string[]; details?: Record<string, unknown> } = {}) =>
new ApiError(SERVER_MSG, 400, { code, errors: [], details: {}, ...extra });
@@ -171,13 +176,17 @@ describe("NewEventLeadPage", { timeout: 20000 }, () => {
await user.type(screen.getByLabelText("Company"), "Initech");
await user.type(screen.getByLabelText("Job title"), "COO");
await user.type(screen.getByLabelText("Notes"), "Met at booth");
expect(screen.getByLabelText("Status")).toHaveValue("OPEN");
expect(screen.getByLabelText("Status")).toHaveTextContent("Open");
expect(screen.getByLabelText("Status")).toHaveClass("min-h-11");
expect(within(screen.getByLabelText("Temperature")).getByRole("option", { name: "Hot" })).toBeInTheDocument();
await user.click(screen.getByLabelText("Temperature"));
expect(within(await screen.findByRole("listbox")).getByRole("option", { name: "Hot" })).toBeInTheDocument();
await user.keyboard("{Escape}");
await user.click(screen.getByLabelText("Salesperson"));
expect(await screen.findByRole("option", { name: "Jane Sales" })).toBeInTheDocument();
await user.selectOptions(screen.getByLabelText("Salesperson"), "7");
await user.selectOptions(screen.getByLabelText("Temperature"), "HOT");
await user.selectOptions(screen.getByLabelText("Status"), "QUALIFIED");
await user.keyboard("{Escape}");
await pick(user, "Salesperson", "Jane Sales");
await pick(user, "Temperature", "Hot");
await pick(user, "Status", "Qualified");
expect(screen.queryByLabelText("Product B")).toBeNull();
await user.click(await screen.findByLabelText("Product A"));
pickDate("Next follow-up", "2026-12-05");
@@ -199,6 +208,42 @@ describe("NewEventLeadPage", { timeout: 20000 }, () => {
await waitFor(() => expect(memoryRouter.push).toHaveBeenCalledWith("/event-leads/evt-1"));
});
it("opens styled menus for salesperson, temperature and status, and saves the chosen values", async () => {
const user = await toStep1Match([]);
await user.type(await screen.findByLabelText("Name"), "Dee Menu");
const menu = async (label: string) => {
await user.click(screen.getByLabelText(label));
return within(await screen.findByRole("listbox")).getAllByRole("option").map((o) => o.textContent);
};
expect(await menu("Salesperson")).toEqual(["None", "Jane Sales"]);
await user.keyboard("{Escape}");
expect(await menu("Temperature")).toEqual(["None", "Hot", "Warm", "Cold"]);
await user.keyboard("{Escape}");
expect(await menu("Status")).toEqual(["Open", "Contacted", "Qualified", "Won", "Lost"]);
await user.keyboard("{Escape}");
await pick(user, "Salesperson", "Jane Sales");
await pick(user, "Temperature", "Warm");
await pick(user, "Status", "Won");
await user.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(mocks.captureEventLead).toHaveBeenCalledTimes(1));
expect(mocks.captureEventLead.mock.calls[0][1]).toMatchObject({ salespersonId: 7, temperature: "WARM", status: "WON" });
});
it("a dropdown opens with Space, moves with the arrow keys and chooses with Enter", async () => {
const user = await toStep1Match([]);
await user.type(await screen.findByLabelText("Name"), "Kay Board");
await screen.findByLabelText("Temperature");
await user.tab();
screen.getByLabelText("Temperature").focus();
await user.keyboard(" ");
expect(await screen.findByRole("listbox")).toBeVisible();
await user.keyboard("{ArrowDown}{Enter}");
expect(screen.getByLabelText("Temperature")).toHaveTextContent("Hot");
await user.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(mocks.captureEventLead).toHaveBeenCalledTimes(1));
expect(mocks.captureEventLead.mock.calls[0][1]).toMatchObject({ temperature: "HOT" });
});
it("Back returns to step 1", async () => {
const user = await toStep1Match([]);
await user.click(await screen.findByRole("button", { name: "Back" }));
@@ -298,17 +343,17 @@ describe("NewEventLeadPage", { timeout: 20000 }, () => {
it("preselects the capturing user as salesperson when on the team", async () => {
mocks.useAdminAuth.mockReturnValue({ loading: false, hasModule: () => true, id: 7 });
const user = await toStep1Match([]);
await screen.findByRole("option", { name: "Jane Sales" });
await waitFor(() => expect(screen.getByLabelText("Salesperson")).toHaveValue("7"));
await waitFor(() => expect(screen.getByLabelText("Salesperson")).toHaveTextContent("Jane Sales"));
await user.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(mocks.captureEventLead).toHaveBeenCalledWith("evt-1", expect.objectContaining({ salespersonId: 7 })));
});
it("leaves the salesperson empty when the capturing user is not on the team", async () => {
mocks.useAdminAuth.mockReturnValue({ loading: false, hasModule: () => true, id: 99 });
await toStep1Match([]);
const user = await toStep1Match([]);
await user.click(await screen.findByLabelText("Salesperson"));
await screen.findByRole("option", { name: "Jane Sales" });
expect(screen.getByLabelText("Salesperson")).toHaveValue("");
expect(screen.getByLabelText("Salesperson")).toHaveTextContent("None");
});
it("keeps the options-load failure visible after matching", async () => {
@@ -7,6 +7,7 @@ import { Button } from "@/app/components/ui/button";
import { DatePicker } from "@/app/components/ui/date-picker";
import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
import { PageHeader } from "@/app/components/ui/page-header";
import { ErrorState } from "@/app/components/ui/states";
import { RequireModule } from "@/app/lib/RequireModule";
@@ -30,7 +31,9 @@ const CODE_MESSAGE: Record<string, string> = {
};
// Codes that name their field themselves when the server omits details.field.
const IMPLIED_FIELD: Record<string, string> = { INVALID_MOBILE: "mobile", INVALID_EMAIL: "email" };
const SELECT_CLASS = "min-h-11 w-full rounded-md border border-input bg-transparent px-3 text-base shadow-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-[invalid=true]:border-destructive dark:bg-input/30";
// Radix Select rejects "" as an item value, so "None" is this sentinel, mapped back to "".
const NONE = "none";
const TEXTAREA_CLASS = "min-h-11 w-full rounded-md border border-input bg-card px-3 text-base shadow-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-[invalid=true]:border-destructive dark:bg-input/30";
const TALL = "min-h-11";
type Step = "match" | "details";
@@ -272,19 +275,28 @@ function NewEventLead() {
)}
{field("salespersonId", t("LeadSalesperson"),
<select {...fieldProps("salespersonId")} className={SELECT_CLASS} value={salespersonId} onChange={(e) => setSalespersonId(e.target.value)} disabled={busy}>
<option value="">{t("LeadNone")}</option>
{salespeople.map((s) => <option key={s.id} value={String(s.id)}>{s.name}</option>)}
</select>)}
<Select value={salespersonId || NONE} onValueChange={(v) => setSalespersonId(v === NONE ? "" : v)} disabled={busy}>
<SelectTrigger {...fieldProps("salespersonId")} className="min-h-11 w-full"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value={NONE}>{t("LeadNone")}</SelectItem>
{salespeople.map((s) => <SelectItem key={s.id} value={String(s.id)}>{s.name}</SelectItem>)}
</SelectContent>
</Select>)}
{field("temperature", t("LeadTemperature"),
<select {...fieldProps("temperature")} className={SELECT_CLASS} value={temperature} onChange={(e) => setTemperature(e.target.value)} disabled={busy}>
<option value="">{t("LeadNone")}</option>
{TEMPERATURES.map(([v, k]) => <option key={v} value={v}>{t(k)}</option>)}
</select>)}
<Select value={temperature || NONE} onValueChange={(v) => setTemperature(v === NONE ? "" : v)} disabled={busy}>
<SelectTrigger {...fieldProps("temperature")} className="min-h-11 w-full"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value={NONE}>{t("LeadNone")}</SelectItem>
{TEMPERATURES.map(([v, k]) => <SelectItem key={v} value={v}>{t(k)}</SelectItem>)}
</SelectContent>
</Select>)}
{field("status", t("LeadStatus"),
<select {...fieldProps("status")} className={SELECT_CLASS} value={status} onChange={(e) => setStatus(e.target.value)} disabled={busy}>
{STATUSES.map(([v, k]) => <option key={v} value={v}>{t(k)}</option>)}
</select>)}
<Select value={status} onValueChange={setStatus} disabled={busy}>
<SelectTrigger {...fieldProps("status")} className="min-h-11 w-full"><SelectValue /></SelectTrigger>
<SelectContent>
{STATUSES.map(([v, k]) => <SelectItem key={v} value={v}>{t(k)}</SelectItem>)}
</SelectContent>
</Select>)}
<fieldset {...fieldProps("interestIds")} className="space-y-1">
<legend className="mb-1.5 text-sm font-medium">{t("LeadInterests")}</legend>
@@ -300,7 +312,7 @@ function NewEventLead() {
{field("nextFollowUpDate", t("LeadNextFollowUp"),
<DatePicker {...fieldProps("nextFollowUpDate")} className="h-11" value={nextFollowUpDate} onChange={setNextFollowUpDate} disabled={busy} />)}
{field("notes", t("LeadNotes"),
<textarea {...fieldProps("notes")} className={`${SELECT_CLASS} py-2`} rows={3} value={notes} onChange={(e) => setNotes(e.target.value)} disabled={busy} />)}
<textarea {...fieldProps("notes")} className={`${TEXTAREA_CLASS} py-2`} rows={3} value={notes} onChange={(e) => setNotes(e.target.value)} disabled={busy} />)}
<div className="flex flex-col-reverse gap-3 sm:flex-row">
<Button type="button" variant="outline" className={TALL} onClick={() => { setFieldErrors({}); setFormError(null); setStep("match"); }} disabled={busy}>{t("Back")}</Button>
@@ -206,7 +206,7 @@ function EventLeadsDetailPageContent() {
accessorKey: "nextFollowUpDate",
header: t("LeadNextFollowUp"),
enableSorting: false,
cell: ({ row }) => <span>{row.original.nextFollowUpDate ? formatDmy(row.original.nextFollowUpDate) : "—"}</span>,
cell: ({ row }) => <span className="tabular">{row.original.nextFollowUpDate ? formatDmy(row.original.nextFollowUpDate) : "—"}</span>,
},
],
[t, showCompanyColumn, codeOf],
+3 -3
View File
@@ -25,7 +25,7 @@ import { formatDmy } from "@/app/lib/date-input";
const DEFAULTS = { q: "", enabled: "" };
export const EVENT_STATUS_FILTER_OPTIONS = [{ value: "Y", label: "Enabled" }, { value: "N", label: "Disabled" }];
const EVENT_STATUS_FILTER_OPTIONS = [{ value: "Y", label: "Enabled" }, { value: "N", label: "Disabled" }];
function EventsPageContent() {
const t = useT();
@@ -84,12 +84,12 @@ function EventsPageContent() {
{
accessorKey: "startDate",
header: t("EvtStartDate"),
cell: ({ row }) => <span>{formatDmy(row.original.startDate)}</span>,
cell: ({ row }) => <span className="tabular">{formatDmy(row.original.startDate)}</span>,
},
{
accessorKey: "endDate",
header: t("EvtEndDate"),
cell: ({ row }) => <span>{formatDmy(row.original.endDate)}</span>,
cell: ({ row }) => <span className="tabular">{formatDmy(row.original.endDate)}</span>,
},
{
accessorKey: "enabled",
+105 -114
View File
@@ -5,162 +5,162 @@
/*
* Design tokens, ported from src/styles/_variables.scss + tailwind.css
* (Tailwind 4 @theme) into plain CSS custom properties for Tailwind 3's
* postcss-based build (see tailwind.config.ts). The old stylesheet's two
* Sass-only mixins in actual use (brand-gradient-text, custom-scrollbar) are
* folded in below as .brand-wordmark/.scrollable. Fonts (Inter, DM Sans) load
* via next/font in app/layout.tsx, which sets --font-inter / --font-dm-sans.
* postcss-based build (see tailwind.config.ts). The old stylesheet's
* Sass-only mixin in actual use (custom-scrollbar) is
* folded in below as .scrollable. Inter, the one type family,
* loads via next/font in app/layout.tsx, which sets --font-inter.
*
* CURRENT SKIN: Co-Lite. Brand primary #6E3E17 (warm brown), accent #F2BC57 (warm gold), body #121212.
* CURRENT SKIN: Co-Lite. Slate neutrals with one blue accent (--primary/--ring #2563EB).
* To re-skin for another client, edit the values below; nothing else should
* change.
*/
:root {
--radius: 1rem;
/* Data-table frames (owner request 2026-10-23: 20px read too soft for dense tables): 12px, the
scale's sm step, as its own token so tables can move independently of cards. */
--table-radius: calc(var(--radius) - 4px);
--radius: 0.5rem;
/* Data-table frames share the card radius (8px), as their own token so tables can still move
independently of cards. */
--table-radius: 8px;
/* The radius scale (tailwind.config.ts reads these). */
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-sm: 4px;
--radius-md: 6px;
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--radius-xl: 12px;
--sidebar-width: 272px;
--sidebar-width: 240px;
--sidebar-width-collapsed: 76px;
--header-height: 64px;
--header-height: 56px;
--content-max-width: 1600px;
--background: #fdfbf7;
--foreground: #121212;
--background: #F8FAFC;
--foreground: #0F172A;
--card: #ffffff;
--card-foreground: #121212;
--card: #FFFFFF;
--card-foreground: #0F172A;
--popover: #ffffff;
--popover-foreground: #121212;
--popover: #FFFFFF;
--popover-foreground: #0F172A;
--primary: #6e3e17;
--primary-foreground: #ffffff;
--primary: #2563EB;
--primary-foreground: #FFFFFF;
--secondary: #f5ede3;
--secondary-foreground: #3a2410;
--secondary: #F1F5F9;
--secondary-foreground: #0F172A;
--muted: #f7f2ea;
--muted-foreground: #6f5b48;
--muted: #F1F5F9;
--muted-foreground: #475569;
--accent: #f2bc57;
--accent-foreground: #3a2410;
--accent-strong: #9a6212;
--accent: #EFF6FF;
--accent-foreground: #1D4ED8;
--accent-strong: #1D4ED8;
--positive: #1b6e3e;
--negative: #b3261e;
--warning: #8f5200;
--positive: #15803D;
--negative: #B91C1C;
--warning: #B45309;
--destructive: #b3261e;
--destructive-foreground: #ffffff;
--destructive: #DC2626;
--destructive-foreground: #FFFFFF;
--border: #ede4d8;
--input: #8d7761;
--ring: #6e3e17;
--border: #E2E8F0;
--input: #7C8BA1;
--ring: #2563EB;
--chart-1: #6e3e17;
--chart-2: #1f6f6b;
--chart-3: #a15c00;
--chart-4: #7b5ac6;
--chart-5: #a63d5b;
--chart-1: #2563EB;
--chart-2: #0F766E;
--chart-3: #D97706;
--chart-4: #7C3AED;
--chart-5: #E11D48;
/* The contrast colour (dusty blue, approved 2026-10-22 — design.md Part 3): type/category pills
and secondary highlights. Never a primary action, never status. */
--contrast: #4f7396;
--contrast-foreground: #3e5c7a;
--contrast-soft: #e4ecf3;
/* Data-table header row (owner request 2026-10-23: gold with dusty-blue text instead of light
brown). Soft gold, not the full --accent: dusty blue on full gold is only 4.0:1. Opaque, so a
sticky header covers the rows under it. */
--table-head: #f7d99a;
--table-head-foreground: #3e5c7a;
/* Data-table header row: a slate tint with slate text. Opaque, so a sticky header covers the
rows under it. */
--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: #121212;
--sidebar-primary: #6e3e17;
--sidebar-primary-foreground: #ffffff;
--sidebar-accent: #f7f2ea;
--sidebar-accent-foreground: #6e3e17;
--sidebar-border: #ede4d8;
--sidebar-ring: #6e3e17;
--sidebar: #FFFFFF;
--sidebar-foreground: #0F172A;
--sidebar-primary: #2563EB;
--sidebar-primary-foreground: #FFFFFF;
--sidebar-accent: #EFF6FF;
--sidebar-accent-foreground: #1D4ED8;
--sidebar-border: #E2E8F0;
--sidebar-ring: #2563EB;
--font-heading: var(--font-dm-sans), ui-sans-serif, system-ui, sans-serif;
--shadow-card: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.04);
--font-heading: var(--font-sans);
--font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
--font-mono: var(--font-sans);
}
.dark {
--background: #17120f;
--foreground: #f8f4ef;
--background: #020617;
--foreground: #F1F5F9;
--card: #211a16;
--card-foreground: #f8f4ef;
--card: #0F172A;
--card-foreground: #F1F5F9;
--popover: #211a16;
--popover-foreground: #f8f4ef;
--popover: #0F172A;
--popover-foreground: #F1F5F9;
--primary: #d9a05b;
--primary-foreground: #241a10;
--primary: #60A5FA;
--primary-foreground: #0B1220;
--secondary: #2e251f;
--secondary-foreground: #f8f4ef;
--secondary: #1E293B;
--secondary-foreground: #F1F5F9;
--muted: #2e251f;
--muted-foreground: #bca994;
--muted: #1E293B;
--muted-foreground: #94A3B8;
--accent: #f2bc57;
--accent-foreground: #241a10;
--accent-strong: #f2bc57;
--accent: #172554;
--accent-foreground: #BFDBFE;
--accent-strong: #93C5FD;
--positive: #6fcf97;
--negative: #f08a82;
--warning: #f0b94a;
--positive: #4ADE80;
--negative: #F87171;
--warning: #FBBF24;
--destructive: #f08a82;
--destructive-foreground: #241a10;
--destructive: #F87171;
--destructive-foreground: #0B1220;
--border: #332a23;
--input: #7a6a5c;
--ring: #d9a05b;
--border: #1E293B;
--input: #64748B;
--ring: #60A5FA;
--chart-1: #d9a05b;
--chart-2: #5fc9c0;
--chart-3: #f0b94a;
--chart-4: #b49bf0;
--chart-5: #e88aa5;
--chart-1: #60A5FA;
--chart-2: #2DD4BF;
--chart-3: #FBBF24;
--chart-4: #A78BFA;
--chart-5: #FB7185;
--contrast: #9db8d2;
--contrast-foreground: #dbe7f2;
--contrast-soft: #22303d;
--table-head: #4a3a1a;
--table-head-foreground: #dbe7f2;
--table-head: #1E293B;
--table-head-foreground: #CBD5E1;
--sidebar: #211a16;
--sidebar-foreground: #f8f4ef;
--sidebar-primary: #d9a05b;
--sidebar-primary-foreground: #241a10;
--sidebar-accent: #2e251f;
--sidebar-accent-foreground: #f2bc57;
--sidebar-border: #332a23;
--sidebar-ring: #d9a05b;
--sidebar: #0F172A;
--sidebar-foreground: #F1F5F9;
--sidebar-primary: #60A5FA;
--sidebar-primary-foreground: #0B1220;
--sidebar-accent: #172554;
--sidebar-accent-foreground: #BFDBFE;
--sidebar-border: #1E293B;
--sidebar-ring: #60A5FA;
--shadow-card: 0 1px 2px rgb(0 0 0 / 0.4);
}
* {
border-color: var(--border);
}
::selection {
background: var(--accent);
color: var(--accent-foreground);
}
html {
scrollbar-gutter: stable;
}
@@ -209,19 +209,10 @@ h4 {
}
/*
* Ported from src/styles/_mixins.scss (brand-gradient-text, custom-scrollbar):
* plain classes rather than Sass mixins, since Tailwind 3's postcss build has
* no Sass step. Used by app/components/app/Sidebar.tsx (wordmark, scrollable nav).
* Ported from src/styles/_mixins.scss (custom-scrollbar): a plain class rather than
* a Sass mixin, since Tailwind 3's postcss build has no Sass step. Used by
* app/components/app/Sidebar.tsx (scrollable nav).
*/
.brand-wordmark {
background-image: linear-gradient(to right, var(--primary), var(--accent));
background-clip: text;
-webkit-background-clip: text;
color: transparent;
font-family: var(--font-heading);
font-weight: 700;
}
.scrollable {
scrollbar-width: thin;
scrollbar-color: var(--border) transparent;
+35
View File
@@ -11,4 +11,39 @@ describe("globals.css", () => {
expect(css).toMatch(/html\s*\{[^}]*scrollbar-gutter:\s*stable/);
expect(css).toMatch(/html body\[data-scroll-locked\]\s*\{[^}]*margin-right:\s*0\s*!important/);
});
it("uses one type family, the Inter accent blue and the 0.5rem radius", () => {
const css = readFileSync(join(__dirname, "globals.css"), "utf8");
const block = (sel: string) => css.match(new RegExp(`${sel}\\s*\\{([\\s\\S]*?)\\n\\}`))?.[1] ?? "";
expect(css).not.toMatch(/dm-sans|DM Sans/i);
expect(block(":root")).toMatch(/--primary:\s*#2563eb/i);
expect(block("\\.dark")).toMatch(/--primary:\s*#60a5fa/i);
expect(block(":root")).toMatch(/--radius:\s*0\.5rem/);
expect(block(":root")).toMatch(/--table-head:\s*#f1f5f9/i);
expect(block("\\.dark")).toMatch(/--table-head:\s*#1e293b/i);
expect(block(":root")).toMatch(/--muted-foreground:\s*#475569/i);
expect(css).not.toMatch(/dusty|gold|brown/i);
});
// WCAG 2.x: 4.5:1 for text, 3:1 for the boundary of a form control (1.4.11).
it.each([":root", "\\.dark"])("meets WCAG contrast for text and control borders in %s", (sel) => {
const css = readFileSync(join(__dirname, "globals.css"), "utf8");
const body = css.match(new RegExp(`${sel}\\s*\\{([\\s\\S]*?)\\n\\}`))?.[1] ?? "";
const tok = (name: string) => body.match(new RegExp(`--${name}:\\s*(#[0-9a-f]{6})`, "i"))?.[1] ?? "";
const lum = (hex: string) => {
const [r, g, b] = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((v) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4));
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
};
const ratio = (a: string, b: string) => {
const [x, y] = [lum(tok(a)), lum(tok(b))];
return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
};
const text: [string, string][] = [
["foreground", "background"], ["foreground", "card"],
["muted-foreground", "background"], ["muted-foreground", "card"], ["muted-foreground", "muted"],
["primary-foreground", "primary"], ["destructive-foreground", "destructive"],
["accent-foreground", "accent"], ["table-head-foreground", "table-head"],
];
for (const [fg, bg] of text) expect(ratio(fg, bg), `${fg} on ${bg}`).toBeGreaterThanOrEqual(4.5);
for (const bg of ["background", "card"]) expect(ratio("input", bg), `input on ${bg}`).toBeGreaterThanOrEqual(3);
});
});
+2 -2
View File
@@ -89,10 +89,10 @@ describe("RootLayout i18n wiring", () => {
expect(el.props.lang).toBe("zh-TW");
});
it("puts the Inter and DM Sans font variable classes on html", async () => {
it("puts only the Inter font variable class on html", async () => {
const el = await RootLayout({ children: <div>page</div> });
expect(el.props.className).toContain("--font-inter");
expect(el.props.className).toContain("--font-dm-sans");
expect(el.props.className).not.toContain("--font-dm-sans");
});
// Spec: "The Admin Portal Displays Labels From The Message Catalog" -- the
+1 -7
View File
@@ -16,12 +16,6 @@ const inter = localFont({
variable: "--font-inter",
display: "swap",
});
const dmSans = localFont({
src: "./fonts/dm-sans-latin-wght-normal.woff2",
weight: "100 1000",
variable: "--font-dm-sans",
display: "swap",
});
export async function generateMetadata(): Promise<Metadata> {
const t = await getServerT();
@@ -44,7 +38,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
const [{ locale, locales }, messages] = await Promise.all([requestLocale(), requestCatalog()]);
return (
<html lang={locale.replace("_", "-")} className={`${inter.variable} ${dmSans.variable}`}>
<html lang={locale.replace("_", "-")} className={inter.variable}>
<body className="antialiased">
<LocalesProvider locales={locales}>
<MessagesProvider locale={locale} messages={messages}>
@@ -32,13 +32,19 @@ beforeEach(() => {
mocks.useAdminAuth.mockReset().mockReturnValue({ isSuper: true });
});
const openPicker = async (user: ReturnType<typeof userEvent.setup>) => {
const picker = await screen.findByRole("combobox", { name: "Company" });
await user.click(picker);
return picker;
};
describe("CompanyPicker", () => {
it("is shown to a super admin with All companies plus each company", async () => {
const user = userEvent.setup();
renderScope();
const picker = await screen.findByRole("combobox", { name: "Company" });
await waitFor(() => expect(picker.querySelectorAll("option")).toHaveLength(3));
expect([...picker.querySelectorAll("option")].map((o) => o.textContent)).toEqual(["All companies", "INS", "CV"]);
expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV");
await waitFor(() => expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV"));
await openPicker(user);
expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["All companies", "INS", "CV"]);
});
it("is not shown to staff, who never load companies or get a companyId", async () => {
@@ -53,16 +59,29 @@ describe("CompanyPicker", () => {
it("feeds the chosen company into the scope and keeps it for the tab; All companies clears it", async () => {
const user = userEvent.setup();
renderScope();
const picker = await screen.findByRole("combobox", { name: "Company" });
await waitFor(() => expect(picker.querySelectorAll("option")).toHaveLength(3));
await user.selectOptions(picker, "2");
await waitFor(() => expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV"));
await openPicker(user);
await user.click(await screen.findByRole("option", { name: "CV" }));
expect(screen.getByTestId("probe")).toHaveTextContent("2|false|CV");
expect(sessionStorage.getItem("company-scope")).toBe("2");
await user.selectOptions(picker, "");
await openPicker(user);
await user.click(await screen.findByRole("option", { name: "All companies" }));
expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV");
expect(sessionStorage.getItem("company-scope")).toBeNull();
});
it("opens with Enter, moves with the arrow keys and chooses with Enter", async () => {
const user = userEvent.setup();
renderScope();
await waitFor(() => expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV"));
const picker = await screen.findByRole("combobox", { name: "Company" });
picker.focus();
await user.keyboard("{Enter}");
await screen.findByRole("option", { name: "INS" });
await user.keyboard("{ArrowDown}{Enter}");
expect(screen.getByTestId("probe")).toHaveTextContent("1|false|CV");
});
it("restores the choice from sessionStorage", async () => {
sessionStorage.setItem("company-scope", "1");
renderScope();
@@ -20,6 +20,8 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
AllCompanies: "All companies",
CompanySuperAdmin: "Super admin (no company)",
ChooseCompany: "Choose a company.",
SelectCompany: "Select a company",
TeamNeedsCompany: "Choose a company to list its team",
SuperAdminNeedsRole: "A super admin must have the Super admin role.",
CompanyBlankForSuper: "Leave blank for super admin",
BO_COMPANIES: "Companies",
@@ -247,7 +247,7 @@ function LockoutForm() {
const num = (v: string) => (v === "" ? 0 : Number(v));
return (
<section className="space-y-4 rounded-xl border bg-card p-4">
<section className="space-y-4 rounded-lg border bg-card shadow-card p-4">
<h2 className="text-base font-semibold">{t("LsLockoutTitle")}</h2>
<div className="flex items-center gap-2">
<Switch id="ls-enabled" disabled={readOnly} checked={cfg.enabled} onCheckedChange={(enabled) => setCfg({ ...cfg, enabled })} />
@@ -321,7 +321,7 @@ function PasswordRulesForm() {
const edit = (id: number, patch: Partial<RuleEdit>) => setEdits((e) => ({ ...e, [id]: { ...e[id], ...patch } }));
return (
<section className="space-y-4 rounded-xl border bg-card p-4">
<section className="space-y-4 rounded-lg border bg-card shadow-card p-4">
<h2 className="text-base font-semibold">{t("LsRulesTitle")}</h2>
<Table>
<TableHeader>
@@ -19,7 +19,6 @@ const FILES = globSync("app/**/*.tsx", { cwd: ROOT }).filter((f) => !/\.test\.ts
// selectors/markers, not Tailwind utilities.
const PROJECT_CLASSES = new Set([
"tabular",
"brand-wordmark",
"scrollable",
"giraffe-spots",
"print-handover",
+3 -5
View File
@@ -53,11 +53,6 @@ const config: Config = {
DEFAULT: token("table-head"),
foreground: token("table-head-foreground"),
},
contrast: {
DEFAULT: token("contrast"),
foreground: token("contrast-foreground"),
soft: token("contrast-soft"),
},
positive: token("positive"),
negative: token("negative"),
warning: token("warning"),
@@ -87,6 +82,9 @@ const config: Config = {
xl: "var(--radius-xl)",
table: "var(--table-radius)",
},
boxShadow: {
card: "var(--shadow-card)",
},
fontFamily: {
heading: ["var(--font-heading)"],
sans: ["var(--font-sans)"],
@@ -207,7 +207,7 @@ public class AdminAuthController {
if (!StringUtils.hasText(username) || username.contains("@")) {
return null;
}
String code = company == null ? "" : company.trim().toLowerCase();
String code = company == null ? "" : company.trim().toUpperCase(java.util.Locale.ROOT);
return code.isEmpty() ? username.trim() : username.trim() + "@" + code;
}
}
@@ -84,9 +84,9 @@ class AdminAuthControllerCompanyTest {
ArgumentCaptor<AuthRequest> sent = ArgumentCaptor.forClass(AuthRequest.class);
verify(auth).getToken(sent.capture());
assertThat(sent.getValue().getUsername()).isEqualTo("john@ins");
verify(auth).isLocked("john@ins");
verify(auth).record("john@ins", "LOGIN_SUCCESS", null);
assertThat(sent.getValue().getUsername()).isEqualTo("john@INS");
verify(auth).isLocked("john@INS");
verify(auth).record("john@INS", "LOGIN_SUCCESS", null);
}
@Test
@@ -114,7 +114,7 @@ class AdminAuthControllerCompanyTest {
void login_wrongCompanyOrUnknownUser_isBadLogin() throws Exception {
when(auth.getToken(any())).thenReturn(null);
login("{\"company\":\"nope\",\"username\":\"john\",\"password\":\"pw\"}").andExpect(status().isUnauthorized());
verify(auth).record("john@nope", "LOGIN_FAIL", null);
verify(auth).record("john@NOPE", "LOGIN_FAIL", null);
}
@Test
@@ -124,7 +124,7 @@ class AdminAuthControllerCompanyTest {
login("{\"company\":\"ins\",\"username\":\"john\",\"password\":\"pw\"}")
.andExpect(status().isUnauthorized()).andExpect(jsonPath("$.message").value("Invalid username or password"));
verify(auth).record("john@ins", "LOGIN_FAIL", null);
verify(auth).record("john@INS", "LOGIN_FAIL", null);
verify(authenticationService).logoutToken("tok");
}
@@ -154,10 +154,10 @@ class AdminAuthControllerCompanyTest {
mvc.perform(post("/api/admin/auth/forgot-password").contentType(MediaType.APPLICATION_JSON)
.content("{\"company\":\"INS\",\"username\":\"john\",\"email\":\"j@x.com\"}"))
.andExpect(status().isOk()).andExpect(jsonPath("$.result").value("true"));
verify(auth).resetAdminPassword("john@ins", "j@x.com");
verify(auth).resetAdminPassword("john@INS", "j@x.com");
mvc.perform(post("/api/admin/auth/forgot-password").contentType(MediaType.APPLICATION_JSON)
.content("{\"company\":\"ins\",\"username\":\"a@b\",\"email\":\"j@x.com\"}")).andExpect(status().isOk());
verify(auth, never()).resetAdminPassword(org.mockito.ArgumentMatchers.eq("a@b@ins"), anyString());
verify(auth, never()).resetAdminPassword(org.mockito.ArgumentMatchers.eq("a@b@INS"), anyString());
}
}
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
public class CompanyService {
private static final int USERNAME_MAX = 255; // user.username column length
private static final Pattern CODE = Pattern.compile("^[a-z0-9-]{2,20}$");
private static final Pattern CODE = Pattern.compile("^[A-Z0-9-]{2,20}$");
private final CompanyRepository companies;
private final UserRepository users;
@@ -97,8 +97,8 @@ public class CompanyService {
}
private static String validCode(String code) {
String v = code == null ? "" : code.trim().toLowerCase();
if (!CODE.matcher(v).matches()) throw new IllegalArgumentException("Code must be 2 to 20 characters: a-z, 0-9 or -");
String v = code == null ? "" : code.trim().toUpperCase(java.util.Locale.ROOT);
if (!CODE.matcher(v).matches()) throw new IllegalArgumentException("Code must be 2 to 20 characters: A-Z, 0-9 or -");
return v;
}
@@ -69,17 +69,17 @@ class CompanyServiceTest {
}
@Test
void createLowercasesCodeAndDefaultsToActive() {
Company saved = service.save(company(null, " CV ", " CV-2 ", null));
void createStoresCodeInCapitalsAndDefaultsToActive() {
Company saved = service.save(company(null, " CV ", " cv-2 ", null));
assertThat(saved.getName()).isEqualTo("CV");
assertThat(saved.getCode()).isEqualTo("cv-2");
assertThat(saved.getCode()).isEqualTo("CV-2");
assertThat(saved.getStatus()).isEqualTo("A");
}
@Test
void duplicateCodeIgnoringCaseIsRefused() {
when(companies.findByCodeIgnoreCase("ins")).thenReturn(Optional.of(company(1L, "INS", "ins", "A")));
when(companies.findByCodeIgnoreCase("INS")).thenReturn(Optional.of(company(1L, "INS", "ins", "A")));
assertThatThrownBy(() -> service.save(company(null, "Other", "INS", "A")))
.isInstanceOfSatisfying(ResponseStatusException.class, e -> assertThat(e.getStatusCode().value()).isEqualTo(409));
@@ -87,7 +87,7 @@ class CompanyServiceTest {
}
@ParameterizedTest
@ValueSource(strings = {"", "a", "UPPER_case", "has space", "under_score", "abcdefghijklmnopqrstu"})
@ValueSource(strings = {"", "a", "has space", "under_score", "abcdefghijklmnopqrstu"})
void badCodeFormatIsRefused(String code) {
assertThatThrownBy(() -> service.save(company(null, "X", code, "A"))).isInstanceOf(IllegalArgumentException.class);
verify(companies, never()).save(any());
@@ -129,9 +129,9 @@ class CompanyServiceTest {
Company renamed = service.renameCode(2L, "CVX");
assertThat(renamed.getCode()).isEqualTo("cvx");
assertThat(a.getUsername()).isEqualTo("sales@cvx");
assertThat(b.getUsername()).isEqualTo("odd@name@cvx");
assertThat(renamed.getCode()).isEqualTo("CVX");
assertThat(a.getUsername()).isEqualTo("sales@CVX");
assertThat(b.getUsername()).isEqualTo("odd@name@CVX");
verify(users).findByCompanyIdAndType(2L, UserType.A); // only that company, only admins
verify(users).saveAll(List.of(a, b));
// one transaction: company update and username rewrite share one @Transactional method
@@ -142,7 +142,7 @@ class CompanyServiceTest {
@Test
void renameToTakenCodeIsRefusedAndRewritesNothing() {
when(companies.findById(2L)).thenReturn(Optional.of(company(2L, "CV", "cv", "A")));
when(companies.findByCodeIgnoreCase("ins")).thenReturn(Optional.of(company(1L, "INS", "ins", "A")));
when(companies.findByCodeIgnoreCase("INS")).thenReturn(Optional.of(company(1L, "INS", "ins", "A")));
assertThatThrownBy(() -> service.renameCode(2L, "INS")).isInstanceOf(ResponseStatusException.class);
verify(users, never()).saveAll(any());
@@ -191,10 +191,10 @@ class CompanyServiceTest {
void renameToOwnCodeIgnoringCaseIsAllowed() {
Company cv = company(2L, "CV", "cv", "A");
when(companies.findById(2L)).thenReturn(Optional.of(cv));
when(companies.findByCodeIgnoreCase("cv")).thenReturn(Optional.of(cv));
when(companies.findByCodeIgnoreCase("CV")).thenReturn(Optional.of(cv));
when(users.findByCompanyIdAndType(2L, UserType.A)).thenReturn(List.of());
assertThat(service.renameCode(2L, "CV").getCode()).isEqualTo("cv");
assertThat(service.renameCode(2L, "CV").getCode()).isEqualTo("CV");
}
@Test