Compare commits

..
Author SHA1 Message Date
ngqileandClaude Opus 5.5 ba6ab7554d feat(pages): a short sign-up form on landing pages, and coloured sections join
Landing-page forms drop job title, ask for one service in a dropdown and fold the
privacy notice behind one line above the consent box. QR, invitation and customer
forms keep the full form. Sections with a colour look join with no gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:47:02 +08:00
ngqile a7129b417e Merge pull request 'docs: archive add-html-image-upload' (#75) from archive-html-image-upload into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 02:10:43 +00:00
ngqileandClaude Opus 5.5 a83752c34e docs: archive add-html-image-upload
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:10:35 +08:00
ngqile bba99993cb Merge pull request 'feat(pages): upload an image from a Custom HTML block and copy its link' (#74) from add-html-image-upload into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 02:10:26 +00:00
ngqileandClaude Opus 5.5 1136046fc2 feat(pages): upload an image from a Custom HTML block and copy its link
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:10:15 +08:00
ngqile 44eace2bcb Merge pull request 'docs: archive add-hero-full-width' (#73) from archive-hero-full-width into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 01:47:05 +00:00
ngqileandClaude Opus 5.5 dc5cfd1c54 docs: archive add-hero-full-width
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 09:46:57 +08:00
ngqile fae25c11a6 Merge pull request 'feat(pages): a hero can run full width with points and a form card heading' (#72) from add-hero-full-width into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 01:46:44 +00:00
32 changed files with 587 additions and 33 deletions

No files matched your search

+4
View File
@@ -468,4 +468,8 @@ A form stops taking sign-ups when its event is disabled, its end date has passed
**Release add-hero-full-width (SQL, in its OpenSpec change folder):** deploy services-counter, then the portal, then run `sql/01-hero-full-width-labels.sql` (labels only). Deploy services-counter first, because the portal's editor saves the new hero fields. A hero can now run full width, carry bullet points, and give its form card a heading. Custom HTML frames now shrink to fit short content and no longer leave a gap next to a full-width hero. Rollback: the previous images. Saved heroes keep the new fields in their JSON; the old code ignores them and shows the boxed hero. The old services-counter refuses to save a hero that has points or a form heading, so remove them before saving such a page.
**Release add-html-image-upload (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-html-image-labels.sql` (labels only). A Custom HTML block's panel can now upload an image and show its link to copy. Rollback: the previous portal image.
**Release add-compact-landing-form (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-compact-form-labels.sql` (labels only). Landing-page sign-up forms drop job title, ask for one service in a dropdown, and fold the privacy notice behind one line. Coloured sections now join with no gap. QR, invitation and customer forms are unchanged. Before go-live, the PDPA owner should confirm the folded notice. Rollback: the previous portal image.
**New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand.
+10
View File
@@ -1117,6 +1117,12 @@ INSERT INTO message (code, content, area) SELECT 'RegCompany', JSON_OBJECT('en_U
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '公司') WHERE LOWER(code) = LOWER('RegCompany') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegJobTitle', JSON_OBJECT('en_US', 'Job title', 'zh_CN', '职位'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegJobTitle') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '职位') WHERE LOWER(code) = LOWER('RegJobTitle') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegServiceInterest', JSON_OBJECT('en_US', 'Service interested in (optional)', 'zh_CN', '感兴趣的服务(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感兴趣的服务(可选)') WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegChooseService', JSON_OBJECT('en_US', 'Choose a service', 'zh_CN', '选择服务'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '选择服务') WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegNoticeSummary', JSON_OBJECT('en_US', 'How we use your details (English / Bahasa Malaysia)', 'zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)') WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegInterests', JSON_OBJECT('en_US', 'Interests (optional)', 'zh_CN', '兴趣(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegInterests') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '兴趣(可选)') WHERE LOWER(code) = LOWER('RegInterests') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegNoticeEn', JSON_OBJECT('en_US', 'English', 'zh_CN', '英文'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeEn') AND area = 'A');
@@ -1727,6 +1733,10 @@ INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesToolbar', JSON_OBJECT('en_US', 'Formatting', 'zh_CN', '格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '格式') WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesTextStyle', JSON_OBJECT('en_US', 'Text style', 'zh_CN', '文字样式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTextStyle') AND area = 'A');
@@ -0,0 +1,44 @@
# Proposal
## Why
The INS sign-up form on the standalone landing page is short: full name, email, phone, company, a single "service" dropdown and the button. Co-Lite's landing-page form is roughly three times as long. Most of that comes from three things: the full English and Malay privacy notice shown in the form, five interest checkboxes, and a job-title field that INS does not ask for. On the rebuilt Hotel technology page, the form card is taller than two screens.
The coloured sections at the end of the page have a second problem: they are separated by pale gaps. The dark call to action and the dark footer therefore read as two footers.
The owner chose the following on 2026-12-04: a collapsed privacy notice, one interest as a dropdown, and no job title on landing pages.
## What Changes
- **Landing-page forms are compact.** This covers the FORM block and a hero's form; QR, invitation and customer sign-up forms are unchanged.
- The interests are a single optional dropdown ("Service interested in"), so a submission carries at most one interest.
- There is no job-title field.
- The privacy notice is folded behind one line, "How we use your details (English / Bahasa Malaysia)", just above the consent box. It opens to the full bilingual notice.
- The consent box itself and its wording do not change.
- **Coloured sections join.** A block with a non-default look (light grey, dark or company colour) counts as full width, like Custom HTML and the full-width hero. Two such blocks next to each other join with no gap.
Not changing:
- The server: it already accepts a submission without a job title and with zero or one interest.
- The QR, invitation and customer forms.
- The notice text, which consent still covers.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`:
- modifies "Full-Width Blocks Join Without Gaps";
- adds "Compact Landing-Page Form".
## Impact
- Portal:
- `RegistrationForm.tsx` gains a `compact` option;
- `LandingForm.tsx` passes it;
- `CmsBlocks.tsx` extends `bleeds()` to banded looks;
- new labels.
- The compliance owner should confirm that a folded notice next to the consent box meets PDPA. The owner was told this when they chose it.
@@ -0,0 +1,45 @@
## ADDED Requirements
### Requirement: Compact Landing-Page Form
A landing page's sign-up form, in a FORM block or a hero, SHALL show name, mobile, email and company, the event's interests as one optional dropdown, the privacy notice folded behind a single line that opens it in full, and the consent box. It SHALL NOT show a job-title field. QR, invitation and customer sign-up forms SHALL keep their full layout.
#### Scenario: Short form on the page
- **GIVEN** a page whose hero has an event with five interests
- **WHEN** a visitor opens the page
- **THEN** the form shows name, mobile, email, company, a "Service interested in" dropdown and the consent box, with no job title and no interest checkboxes
- **AND** the privacy notice is folded behind "How we use your details"
#### Scenario: Pick one service
- **WHEN** the visitor chooses "Cloud IP PABX" in the dropdown and submits
- **THEN** the submission carries that one interest
#### Scenario: Read the notice
- **WHEN** the visitor opens "How we use your details"
- **THEN** the full English and Malay notice shows above the consent box
#### Scenario: QR form unchanged
- **WHEN** a visitor opens an event's QR sign-up form
- **THEN** it shows job title, the interest checkboxes and the full notice as before
## MODIFIED Requirements
### Requirement: Full-Width Blocks Join Without Gaps
A full-width HERO, a Custom HTML block, and a block with a non-default look SHALL join with no gap when two of them are next to each other. Other blocks SHALL keep their usual spacing.
#### Scenario: Top bar runs straight into the hero
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
- **WHEN** a visitor opens the page
- **THEN** the hero starts directly under the top bar, with no gap
#### Scenario: Dark call to action runs into a dark footer
- **GIVEN** a CTA block with the Dark look followed by a text block with the Dark look
- **WHEN** a visitor opens the page
- **THEN** the two bands join with no gap between them
@@ -0,0 +1,9 @@
-- The labels added by add-compact-landing-form, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'RegServiceInterest', JSON_OBJECT('en_US', 'Service interested in (optional)', 'zh_CN', '感兴趣的服务(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感兴趣的服务(可选)') WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegChooseService', JSON_OBJECT('en_US', 'Choose a service', 'zh_CN', '选择服务'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '选择服务') WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegNoticeSummary', JSON_OBJECT('en_US', 'How we use your details (English / Bahasa Malaysia)', 'zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)') WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A';
@@ -0,0 +1,39 @@
# Tasks
## 1. Portal
- [x] 1.1 `RegistrationForm` `compact` option, passed by `LandingForm`:
- no job title;
- interests in one optional `<select>` ("Service interested in", first option "Choose a service"), which sets `interestIds` to `[]` or `[id]`;
- the notice inside a `<details>` with the summary "How we use your details (English / Bahasa Malaysia)", just above the consent box.
Verify: tests for the landing form (fields, one interest posted, the notice folded and openable) and for the QR form (unchanged) fail first, then pass.
- [x] 1.2 `CmsBlocks.tsx` `bleeds()`: a block with a non-default look counts too. Verify: a render test (a dark CTA followed by a dark text block has no gap) fails first, then passes.
- [x] 1.3 Add the labels (`RegServiceInterest`, `RegChooseService`, `RegNoticeSummary`) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-compact-form-labels.sql`, and regenerate the local seed.
## 2. Verification
- [x] 2.1 Use Playwright on port 3001 for `/p/INS/hotel-technology-native` at 1280 px and 390 px:
- check the short form;
- check that the notice opens;
- check that the closing bands join;
- check that an event's QR form (opened from Events) still shows the full form.
- [x] 2.2 Run the full vitest (exit 0), tsc, lint and `openspec validate --strict`. Add a release note.
## Notes (2026-12-04)
- **Red first:**
- the compact-form tests (fields, one service posted, the notice folded) and the band-join test failed first;
- the full-form test passed from the start, as the baseline it guards.
- **Live check** on `/p/INS/hotel-technology-native` (port 3001):
- the hero form shows name, mobile, email, company and "Service interested in", with no job title;
- the notice opens from "How we use your details";
- the hero runs into the trust strip;
- the dark call to action and the dark footer join into one ending.
- **Fix from the live check:** joined bands had lost their colour. `Section` treated every joining block as a full-width hero. Now only a full-width hero skips the page width, and the band test also checks the colour.
- **Not checked live:** the QR form staying full. The `RegistrationForm` test covers it (job title, checkboxes, notice open).
- **Results:** vitest 2002 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,44 @@
# Proposal
## Why
Custom HTML blocks hold whole designed sections, such as the INS Hotel technology page. Their images must be served from somewhere. Today the only way to get an image link is to upload it as a hero image and read its id back, or to ask a developer. Marketing staff need to upload an image from the Custom HTML block itself and get a link they can paste into their HTML.
## What Changes
- The Custom HTML block's panel gains an **Upload image** file picker. Choosing a file uploads it at once, for the page's company, with the same checks as every page image:
- PNG, JPEG or WebP;
- at most 2 MB;
- the type is checked by the file's content.
- Each upload made while the panel is open shows:
- a small preview;
- its link (`/api/public/page-images/<id>`) in a read-only box;
- a **Copy link** button.
- A refused upload shows its reason under the picker.
- A new page with no company chosen yet asks for one first.
- The link is relative, so it works on the published page and inside the sealed frame. The INS top bar's logo already loads this way.
Not changing:
- The server. The existing `POST /api/pages/images` upload and the public image address are used as they are.
- Saving. The upload does not touch the page's HTML; staff paste the link where they want it.
- Unused images. They stay stored, as an unused hero upload would. Clean-up is left for later.
- The list of uploads, which is not saved. It shows this session's uploads only.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Image Upload For Custom HTML".
## Impact
- Portal:
- `BlockFields.tsx`, the HTML block panel;
- the editor passes the page's company to the panel (or the panel reads it from the draft hook);
- `uploadPageImage` already exists.
- New labels in `defaultMessages.ts` and `zh_CN.seed.json`, a regenerated local seed, and a SQL label file in this change folder.
- No server or schema change.
@@ -0,0 +1,23 @@
## ADDED Requirements
### Requirement: Image Upload For Custom HTML
A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML.
#### Scenario: Upload an image for the HTML
- **GIVEN** staff editing an INS page with a Custom HTML block
- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel
- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/<id>`
- **AND** "Copy link" copies that link, and the block's HTML is unchanged
#### Scenario: Refused upload
- **WHEN** staff choose a 3 MB JPEG under "Upload image"
- **THEN** the panel shows that the image is too large, and no link appears
#### Scenario: New page without a company
- **GIVEN** a super admin's new page with no company chosen
- **WHEN** they choose a file under "Upload image"
- **THEN** nothing is uploaded and the panel asks them to choose a company
@@ -0,0 +1,7 @@
-- The labels added by add-html-image-upload, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A';
@@ -0,0 +1,34 @@
# Tasks
## 1. Portal
- [x] 1.1 HTML block panel: an "Upload image" file picker (`image/png,image/jpeg,image/webp`) uploads at once through `uploadPageImage(companyId, base64)`.
- Each success adds a row: preview, a read-only link `/api/public/page-images/<id>`, and a "Copy link" button that uses the clipboard.
- A refusal shows the translated server reason under the picker.
- With no company, the panel shows "Choose a company." and does not upload.
- The block's HTML is never changed.
Verify: editor tests (success row and copy, refusal, no company, HTML unchanged) fail first, then pass; vitest exit 0; tsc; lint.
- [x] 1.2 Add the labels (`PagesUploadImage`, `PagesUploadImageHint`; the copy button reuses the page-address copy button) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-html-image-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
## 2. Verification
- [x] 2.1 Use Playwright on port 3001, signing in through the form and opening Hotel technology from Pages.
- In a Custom HTML block, upload an image, copy the link, and check that the panel shows the preview and the link.
- Upload a file that is not an image and see the refusal.
- Do not change the published page.
- [x] 2.2 Run the full portal vitest (exit 0), tsc, lint, and `openspec validate add-html-image-upload --strict`. Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:** the success, refusal and no-company editor tests all failed, because there was no "Upload image" picker yet. They pass now.
- **Live check** (port 3001): signed in through the form, then opened Hotel technology from Pages.
- In block 3 (Custom HTML), uploaded `hero-bg.webp`. The panel showed the preview and `/api/public/page-images/7` with a copy button.
- A text file named `.png` was refused with "Use a PNG, JPEG or WebP image."
- The page was not saved or published.
- **Fix from the live check:** the link was shown twice (a read-only box and the copy button's text). It now shows once, beside its copy button, which reuses the page-address copy button with a `relative` option.
- **Results:** vitest 1997 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
+91 -1
View File
@@ -278,7 +278,7 @@ The public frame address SHALL be `/p/<company>/<slug>/frame/<block index>` and
### Requirement: Custom HTML Frame Height
The frame SHALL grow to fit its content, between 100 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall.
The frame SHALL grow or shrink to fit its content, between 20 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall. The frame SHALL report the height of its content, not of its own window, and SHALL report again whenever the page asks, which the page SHALL do once it listens and when the frame loads.
#### Scenario: A tall paste grows the frame
@@ -286,6 +286,12 @@ The frame SHALL grow to fit its content, between 100 and 20000 pixels, using hei
- **WHEN** a visitor opens the page
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
#### Scenario: A short top bar shrinks the frame
- **GIVEN** a published HTML block holding only a 68 pixel top bar
- **WHEN** a visitor opens the page, even if the frame loaded before the page was ready
- **THEN** the frame is 68 pixels tall, with no blank space below the bar
#### Scenario: Another frame cannot resize it
- **WHEN** a different window posts a height report to the page
@@ -605,3 +611,87 @@ A HERO block MAY name an event. When it does, the hero SHALL show Co-Lite's sign
- **WHEN** they pick `INS website enquiries` under the hero's sign-up form setting
- **THEN** the canvas shows the form card beside the hero text
- **AND** choosing "No form" removes it
### Requirement: Full-Width Hero
A HERO block MAY be marked full width. A full-width hero SHALL span the whole window with square corners, show its heading larger and centred top to bottom in the hero's opening height (not beside a long form), and use a shade that is darker on the text side than on the far side. A hero that is not marked full width SHALL look as it did before. The server SHALL refuse a `fullWidth` value that is not true or false.
#### Scenario: Hero runs edge to edge under a Custom HTML top bar
- **GIVEN** page `/p/INS/hotel-technology` with a Custom HTML top bar followed by a full-width HERO with an image and an event
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the hero spans the full window width
- **AND** the form card sits beside the heading
#### Scenario: Existing hero unchanged
- **WHEN** a visitor opens a page whose HERO block is not marked full width
- **THEN** the hero sits inside the page width with rounded corners, as before
#### Scenario: Turn on full width in the editor
- **GIVEN** staff editing a page with a HERO block
- **WHEN** they switch on "Full width" in the hero's settings
- **THEN** the canvas shows the hero across the full width
### Requirement: Full-Width Blocks Join Without Gaps
A full-width HERO and a Custom HTML block next to each other SHALL join with no gap between them, and so SHALL two Custom HTML blocks next to each other. Other blocks SHALL keep their usual spacing.
#### Scenario: Top bar runs straight into the hero
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
- **WHEN** a visitor opens the page
- **THEN** the hero starts directly under the top bar, with no gap
### Requirement: Hero Points
A HERO block MAY carry up to 6 points, each a non-empty title of at most 80 characters, with no icon and no text. The hero SHALL show its points as a bulleted list under its text. The server SHALL refuse more than 6 points, an empty or over-long point, and a point with an icon or text, naming the field.
#### Scenario: Points under the hero text
- **GIVEN** a HERO block with points "One accountable partner instead of five vendors" and "Local support team in Malaysia"
- **WHEN** a visitor opens the page
- **THEN** both points show as a bulleted list under the hero text
#### Scenario: Too many points refused
- **WHEN** staff save a HERO block with 7 points
- **THEN** the save is refused at `blocks[n].cards`
### Requirement: Hero Form Heading
A HERO block with an event MAY carry a form heading of at most 80 characters and a form text of at most 200 characters. The hero SHALL show them at the top of its form card, above the form. The server SHALL refuse either on a hero without an event. On the canvas, staff SHALL be able to type both in place.
#### Scenario: Card shows its heading
- **GIVEN** a HERO block with an event, form heading "Get a free consultation" and form text "Tell us about your property. It takes under a minute."
- **WHEN** a visitor opens the page
- **THEN** the form card starts with that heading and text, followed by the form
#### Scenario: Form heading without a form refused
- **WHEN** staff save a HERO block with a form heading and no event
- **THEN** the save is refused at `blocks[n].formHeading`
### Requirement: Image Upload For Custom HTML
A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML.
#### Scenario: Upload an image for the HTML
- **GIVEN** staff editing an INS page with a Custom HTML block
- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel
- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/<id>`
- **AND** "Copy link" copies that link, and the block's HTML is unchanged
#### Scenario: Refused upload
- **WHEN** staff choose a 3 MB JPEG under "Upload image"
- **THEN** the panel shows that the image is too large, and no link appears
#### Scenario: New page without a company
- **GIVEN** a super admin's new page with no company chosen
- **WHEN** they choose a file under "Upload image"
- **THEN** nothing is uploaded and the panel asks them to choose a company
@@ -1,6 +1,6 @@
"use client";
import type { ReactNode } from "react";
import { useState, type ReactNode } from "react";
import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
import { BLOCK_LABELS, ICONS, LOOKS, imageSrc, type CmsBlock, type CmsCard, type Look } from "@/app/lib/cmsPages";
import { Button } from "@/app/components/ui/button";
@@ -10,6 +10,7 @@ import { Switch } from "@/app/components/ui/switch";
import { Textarea } from "@/app/components/ui/textarea";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import { RichTextEditor } from "./RichTextEditor";
import { CopyAddress } from "./CopyAddress";
// One block of the page editor, ported from babyboo's BlockFields: a fieldset with move/remove and its type's fields.
@@ -79,6 +80,8 @@ export function BlockFields(props: {
onMove: (delta: -1 | 1) => void;
onRemove: () => void;
onChooseImage: (file: File) => void;
/** Uploads an image for a Custom HTML block at once (add-html-image-upload); rejects with the reason to show. */
onUploadImage?: (file: File) => Promise<number>;
}) {
const { block, id, index, count, errors, saving, events, pendingImage, onChange, onMove, onRemove } = props;
const t = useT();
@@ -98,6 +101,24 @@ export function BlockFields(props: {
</Field>
);
// add-html-image-upload: this panel's uploads, newest first; their links are pasted into the HTML by hand.
const [uploads, setUploads] = useState<number[]>([]);
const [uploadError, setUploadError] = useState<string | null>(null);
const [uploading, setUploading] = useState(false);
async function upload(file: File) {
if (!props.onUploadImage) return;
setUploadError(null);
setUploading(true);
try {
const imageId = await props.onUploadImage(file);
setUploads((u) => [imageId, ...u]);
} catch (err) {
setUploadError(err instanceof Error ? err.message : String(err));
} finally {
setUploading(false);
}
}
const preview = pendingImage?.preview ?? (block.imageId ? imageSrc(block.imageId) : undefined);
// The FORM block's event, and the hero's optional sign-up form (add-hero-signup-form): the same picker and hint.
const eventPicker = (labelCode: string, emptyCode: string) => (
@@ -274,6 +295,24 @@ export function BlockFields(props: {
<p className="text-xs text-muted-foreground">{t("PagesHtmlHint")}</p>
</Field>
)}
{block.type === "HTML" && props.onUploadImage && (
<Field id={fid("upload")} label={t("PagesUploadImage")} error={uploadError ?? undefined}>
<Input id={fid("upload")} type="file" accept="image/png,image/jpeg,image/webp" disabled={saving || uploading}
onChange={(e) => {
const file = e.target.files?.[0];
e.target.value = "";
if (file) void upload(file);
}} />
<p className="text-xs text-muted-foreground">{t("PagesUploadImageHint")}</p>
{uploads.map((imageId) => (
<div key={imageId} className="flex items-center gap-2 rounded-md border p-2">
{/* eslint-disable-next-line @next/next/no-img-element -- an uploaded image of unknown size */}
<img src={imageSrc(imageId)} alt={t("PagesImagePreview")} className="size-12 rounded object-cover" />
<CopyAddress address={imageSrc(imageId)} relative />
</div>
))}
</Field>
)}
{block.type === "FORM" && (
<>
@@ -143,6 +143,26 @@ describe("LandingPage full-width hero", () => {
});
});
// add-compact-landing-form: a page's form is the short one, and coloured bands join.
describe("LandingPage compact form and bands", () => {
it("a page's form has no job title and a service dropdown", () => {
render(<LandingPage company={company} page={page([{ type: "FORM", form: { ...info, interests: [{ id: 3, name: "Cloud IP PABX" }] } }])} />);
expect(screen.queryByLabelText("Job title")).not.toBeInTheDocument();
expect(screen.getByRole("combobox", { name: "Service interested in (optional)" })).toBeInTheDocument();
});
it("joins a dark call to action and a dark text block with no gap", () => {
render(<LandingPage company={company} page={page([
{ type: "RICH_TEXT", html: "<p>Intro</p>" },
{ type: "CTA", heading: "Talk to us", look: "DARK" },
{ type: "RICH_TEXT", html: "<p>Footer</p>", look: "DARK" },
])} />);
const rows = Array.from(document.querySelector("main > div")!.children);
expect(rows.map((r) => r.classList.contains("mt-10"))).toEqual([false, true, false]);
expect(rows.slice(1).map((r) => r.querySelector("[data-look]")?.getAttribute("data-look"))).toEqual(["DARK", "DARK"]);
});
});
describe("utmTags", () => {
it("reads the three tags, capped at 100 characters", () => {
expect(utmTags("?utm_source=" + "x".repeat(150))).toEqual({ utmSource: "x".repeat(100), utmMedium: undefined, utmCampaign: undefined });
@@ -228,14 +228,17 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
const WIDTH = "mx-auto w-full max-w-5xl px-4";
/** Blocks that run the full window width: Custom HTML, and a full-width hero. Two of them in a row join with no gap. */
const bleeds = (block: PublicBlock) => block.type === "HTML" || (block.type === "HERO" && !!block.fullWidth);
/**
* Blocks that run the full window width: Custom HTML, a full-width hero, and a coloured band (add-compact-landing-form).
* Two of them in a row join with no gap.
*/
const bleeds = (block: PublicBlock) => block.type === "HTML" || (block.type === "HERO" && !!block.fullWidth) || !!bandOf(block.look);
/** A block in the page width; with a non-default look, inside a full-width band of that colour. */
function Section({ block, index, children }: { block: PublicBlock; index: number; children: ReactNode }) {
const band = bandOf(block.look);
// add-hero-full-width: a full-width hero sets its own width.
if (bleeds(block)) return <EditSection index={index}><div id={anchorId(block.anchor)}>{children}</div></EditSection>;
if (block.type === "HERO" && block.fullWidth) return <EditSection index={index}><div id={anchorId(block.anchor)}>{children}</div></EditSection>;
if (!band) return <EditSection index={index}><div id={anchorId(block.anchor)} className={WIDTH}>{children}</div></EditSection>;
return (
<EditSection index={index}>
@@ -5,14 +5,14 @@ import { Check, Copy } from "lucide-react";
import { Button } from "@/app/components/ui/button";
import { useT } from "@/app/lib/i18n/MessagesProvider";
/** A page address with a button that copies its full URL (this site's origin plus the path). */
export function CopyAddress({ address }: { address: string }) {
/** A page address with a button that copies its full URL (this site's origin plus the path), or the path itself when `relative`. */
export function CopyAddress({ address, relative }: { address: string; relative?: boolean }) {
const t = useT();
const [state, setState] = useState<"idle" | "copied" | "failed">("idle");
async function copy() {
try {
await navigator.clipboard.writeText(`${window.location.origin}${address}`);
await navigator.clipboard.writeText(relative ? address : `${window.location.origin}${address}`);
setState("copied");
setTimeout(() => setState("idle"), 2000);
} catch {
@@ -33,5 +33,5 @@ export function LandingForm({ companyCode, slug, index, info, preview }: { compa
method: "POST",
body: JSON.stringify({ ...body, ...utmTags(window.location.search) }),
});
return <RegistrationForm info={info} submit={submit} onDone={() => setPhase("done")} onInactive={() => setPhase("closed")} />;
return <RegistrationForm info={info} submit={submit} onDone={() => setPhase("done")} onInactive={() => setPhase("closed")} compact />;
}
@@ -64,4 +64,42 @@ describe("PageEditor: Custom HTML", () => {
expect(box.closest("div")).toHaveTextContent("Too long.");
expect(box).toHaveAttribute("aria-invalid", "true");
});
// add-html-image-upload: upload an image from the block's panel and copy its link; the HTML stays as it was.
it("uploads an image at once for the page's company and shows its link to copy", async () => {
mocks.uploadPageImage.mockResolvedValueOnce({ id: 42 });
const user = userEvent.setup();
render(<PageEditor pageId={5} />);
await screen.findByLabelText("HTML");
await user.upload(screen.getByLabelText("Upload image"), new File(["png"], "lobby.png", { type: "image/png" }));
expect(await screen.findByText("/api/public/page-images/42")).toBeInTheDocument();
expect(mocks.uploadPageImage).toHaveBeenCalledWith(2, btoa("png"));
expect(screen.getByRole("img", { name: "Image preview" })).toHaveAttribute("src", "/api/public/page-images/42");
const write = vi.spyOn(navigator.clipboard, "writeText");
await user.click(screen.getByRole("button", { name: "Copy link /api/public/page-images/42" }));
expect(write).toHaveBeenCalledWith("/api/public/page-images/42");
expect(screen.getByLabelText("HTML")).toHaveValue("<h1>Designed</h1>");
expect(mocks.savePage).not.toHaveBeenCalled();
});
it("shows a refused upload's reason and no link", async () => {
mocks.uploadPageImage.mockRejectedValueOnce(new ApiError("x", 422, { code: "PagesImageTooLarge" }));
const user = userEvent.setup();
render(<PageEditor pageId={5} />);
await screen.findByLabelText("HTML");
await user.upload(screen.getByLabelText("Upload image"), new File(["big"], "big.jpg", { type: "image/jpeg" }));
expect(await screen.findByText("The image is larger than 2 MB.")).toBeInTheDocument();
expect(screen.queryByText(/\/api\/public\/page-images\//)).not.toBeInTheDocument();
});
it("asks a super admin's new page for a company before uploading", async () => {
mocks.useAdminAuth.mockReturnValue({ isSuper: true, companyCode: null });
memoryRouter.reset("/pages/new");
const user = userEvent.setup();
render(<PageEditor />);
await user.click(screen.getByRole("button", { name: "Add Custom HTML" }));
await user.upload(await screen.findByLabelText("Upload image"), new File(["png"], "lobby.png", { type: "image/png" }));
expect(await screen.findByText("Choose a company.")).toBeInTheDocument();
expect(mocks.uploadPageImage).not.toHaveBeenCalled();
});
});
@@ -223,6 +223,7 @@ function FormEditor({ p, ask }: { p: Draft; ask: Ask }) {
onMove={(delta) => p.moveBlock(index, delta)}
onRemove={() => p.removeBlock(row.key)}
onChooseImage={(file) => p.chooseImage(row.key, file)}
onUploadImage={p.uploadImage}
/>
))}
<FieldError message={errors.blocks} />
@@ -325,6 +325,20 @@ export function usePageDraft({ pageId, fromId, initialBlocks }: { pageId?: numbe
}
}
/**
* add-html-image-upload: uploads an image for a Custom HTML block at once, for the page's company. Resolves to its id;
* rejects with the reason to show (no company yet, or the server's refusal).
*/
async function uploadImage(file: File): Promise<number> {
if (isSuper && !draft.companyId) throw new Error(t("ChooseCompany"));
try {
return (await uploadPageImage(draft.companyId, (await readDataUrl(file)).split(",")[1])).id;
} catch (err) {
const code = err instanceof ApiError ? (err.data as { code?: string } | undefined)?.code : undefined;
throw new Error(t(code ?? "PagesSaveFailed"));
}
}
/** Saves the current edits, then makes the draft live. */
async function publishChanges() {
if (draft.id == null || !(await save())) return;
@@ -384,7 +398,7 @@ export function usePageDraft({ pageId, fromId, initialBlocks }: { pageId?: numbe
selected, select: setSelected, revealed, frameVersion, stale,
canUndo: past.length > 0, canRedo: future.length > 0, undo, redo, endTyping,
patch, setTitle, changeCompany, updateBlock, text, html, moveBlock, moveBlockTo, removeBlock, addBlock, insertBlock, duplicateBlock,
chooseImage, blockErrors,
chooseImage, uploadImage, blockErrors,
save, publishChanges, discardChanges, remove,
};
}
@@ -198,6 +198,7 @@ export function VisualEditor({ p, ask }: { p: Draft; ask: Ask }) {
onMove={(delta) => p.moveBlock(selected, delta)}
onRemove={() => p.removeBlock(row.key)}
onChooseImage={(f) => p.chooseImage(row.key, f)}
onUploadImage={p.uploadImage}
/>
</>
) : (
@@ -0,0 +1,49 @@
import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { RegistrationForm } from "./RegistrationForm";
// add-compact-landing-form: landing pages use a short form; QR, invitation and customer forms keep the full one.
const info = {
eventName: "INS enquiries", startDate: "2026-12-01", endDate: "2099-12-31", location: "KL", companyName: "INS",
notice: { id: 1, textEn: "English text", textMs: "Teks Melayu" },
interests: [{ id: 11, name: "WiFi Managed Services" }, { id: 12, name: "Cloud IP PABX" }],
};
const base = { info, onDone: () => {}, onInactive: () => {} };
describe("RegistrationForm compact", () => {
it("has no job title, one service dropdown, and the notice folded above the consent box", async () => {
const user = userEvent.setup();
render(<RegistrationForm {...base} submit={async () => undefined} compact />);
expect(screen.queryByLabelText("Job title")).not.toBeInTheDocument();
expect(screen.queryByRole("checkbox", { name: "WiFi Managed Services" })).not.toBeInTheDocument();
const service = screen.getByRole("combobox", { name: "Service interested in (optional)" });
expect(service).toHaveValue("");
expect(screen.getByRole("option", { name: "Choose a service" })).toBeInTheDocument();
const notice = screen.getByText("English text").closest("details")!;
expect(notice).not.toHaveAttribute("open");
await user.click(screen.getByText("How we use your details (English / Bahasa Malaysia)"));
expect(notice).toHaveAttribute("open");
expect(notice.compareDocumentPosition(screen.getByRole("checkbox")) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
});
it("posts the one chosen service", async () => {
const submit = vi.fn().mockResolvedValue(undefined);
const user = userEvent.setup();
render(<RegistrationForm {...base} submit={submit} compact />);
await user.type(screen.getByLabelText("Your name"), "Tan");
await user.type(screen.getByLabelText("Mobile number"), "0125550101");
await user.selectOptions(screen.getByRole("combobox", { name: "Service interested in (optional)" }), "12");
await user.click(screen.getByRole("checkbox"));
await user.click(screen.getByRole("button", { name: "Register" }));
expect(submit.mock.calls[0][0]).toMatchObject({ interestIds: [12], jobTitle: "" });
});
it("keeps the full form without the option", () => {
render(<RegistrationForm {...base} submit={async () => undefined} />);
expect(screen.getByLabelText("Job title")).toBeInTheDocument();
expect(screen.getByRole("checkbox", { name: "WiFi Managed Services" })).toBeInTheDocument();
expect(screen.queryByRole("combobox")).not.toBeInTheDocument();
expect(screen.getByText("English text").closest("details")).toBeNull();
});
});
@@ -15,6 +15,7 @@ const FIELDS = ["name", "mobile", "email", "companyName", "jobTitle", "consent"]
const ROW = "flex min-h-11 w-full cursor-pointer items-center gap-3 rounded-md border p-3";
const CONSENT_ROW = "flex min-h-11 w-full cursor-pointer items-start gap-3 rounded-md border p-3 leading-normal";
const BOX = "size-6";
const NOTICE = "rounded-md bg-muted p-3 text-xs text-muted-foreground";
export function apiData(err: unknown): { status?: number; code?: string; error?: string; field?: string } {
if (!(err instanceof ApiError)) return {};
@@ -40,11 +41,13 @@ interface Props {
onDone: () => void;
/** The code or invitation was switched off: the page shows its own message. */
onInactive: () => void;
/** add-compact-landing-form: a landing page's short form: no job title, one service dropdown, the notice folded. */
compact?: boolean;
}
// The visitor registration form shared by /r, /i and /c: fields, bilingual privacy notice and consent.
// The event header comes from the VisitorCard around it.
export function RegistrationForm({ tooManyKey, info, initial, submit, onDone, onInactive }: Props) {
export function RegistrationForm({ tooManyKey, info, initial, submit, onDone, onInactive, compact }: Props) {
const t = useT();
const [form, setForm] = useState<RegistrationBody>({ ...EMPTY, ...initial });
const [errors, setErrors] = useState<Record<string, string>>({});
@@ -94,6 +97,42 @@ export function RegistrationForm({ tooManyKey, info, initial, submit, onDone, on
);
};
const interestBoxes = (
<fieldset className="space-y-2">
<legend className="text-sm font-medium">{t("RegInterests")}</legend>
{info.interests.map((i) => (
<Label key={i.id} htmlFor={`reg-interest-${i.id}`} className={ROW}>
<Checkbox
className={BOX}
id={`reg-interest-${i.id}`}
checked={form.interestIds.includes(i.id)}
onCheckedChange={(on) => set({ interestIds: on ? [...form.interestIds, i.id] : form.interestIds.filter((x) => x !== i.id) })}
/>
{i.name}
</Label>
))}
</fieldset>
);
// add-compact-landing-form: a landing page asks for at most one service.
const serviceDropdown = (
<div className="space-y-1.5">
<Label htmlFor="reg-service">{t("RegServiceInterest")}</Label>
<select id="reg-service" className="flex h-11 w-full rounded-md border border-input bg-transparent px-3 text-base shadow-sm disabled:opacity-50"
value={form.interestIds[0] ?? ""} disabled={saving} onChange={(e) => set({ interestIds: e.target.value ? [Number(e.target.value)] : [] })}>
<option value="">{t("RegChooseService")}</option>
{info.interests.map((i) => <option key={i.id} value={i.id}>{i.name}</option>)}
</select>
</div>
);
const notice = (
<>
<h2 className="font-semibold text-foreground">{t("RegNoticeEn")}</h2>
<p className="whitespace-pre-line">{info.notice.textEn}</p>
<h2 className="font-semibold text-foreground">{t("RegNoticeMs")}</h2>
<p className="whitespace-pre-line">{info.notice.textMs}</p>
</>
);
return (
<form onSubmit={onSubmit} className="space-y-4" noValidate>
{formError && <p role="alert" className="text-sm text-destructive">{formError}</p>}
@@ -101,29 +140,16 @@ export function RegistrationForm({ tooManyKey, info, initial, submit, onDone, on
{field("mobile", t("RegMobile"), "tel", t("RegContactHint"))}
{field("email", t("RegEmail"), "email")}
{field("companyName", t("RegCompany"))}
{field("jobTitle", t("RegJobTitle"))}
{info.interests.length > 0 && (
<fieldset className="space-y-2">
<legend className="text-sm font-medium">{t("RegInterests")}</legend>
{info.interests.map((i) => (
<Label key={i.id} htmlFor={`reg-interest-${i.id}`} className={ROW}>
<Checkbox
className={BOX}
id={`reg-interest-${i.id}`}
checked={form.interestIds.includes(i.id)}
onCheckedChange={(on) => set({ interestIds: on ? [...form.interestIds, i.id] : form.interestIds.filter((x) => x !== i.id) })}
/>
{i.name}
</Label>
))}
</fieldset>
{compact ? null : field("jobTitle", t("RegJobTitle"))}
{info.interests.length > 0 && (compact ? serviceDropdown : interestBoxes)}
{compact ? (
<details className={NOTICE}>
<summary className="cursor-pointer font-medium text-foreground">{t("RegNoticeSummary")}</summary>
<div className="mt-2 space-y-2">{notice}</div>
</details>
) : (
<div className={`space-y-2 ${NOTICE}`}>{notice}</div>
)}
<div className="space-y-2 rounded-md bg-muted p-3 text-xs text-muted-foreground">
<h2 className="font-semibold text-foreground">{t("RegNoticeEn")}</h2>
<p className="whitespace-pre-line">{info.notice.textEn}</p>
<h2 className="font-semibold text-foreground">{t("RegNoticeMs")}</h2>
<p className="whitespace-pre-line">{info.notice.textMs}</p>
</div>
<Label htmlFor="reg-consent" className={CONSENT_ROW}>
<Checkbox id="reg-consent" className={`${BOX} mt-0.5`} checked={form.consent} onCheckedChange={(on) => set({ consent: on === true })} aria-invalid={!!errors.consent} aria-describedby={errors.consent ? "reg-consent-error" : undefined} />
<span className="space-y-1 font-normal">
@@ -568,6 +568,9 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
RegContactHint: "Mobile or email is required",
RegCompany: "Company",
RegJobTitle: "Job title",
RegServiceInterest: "Service interested in (optional)",
RegChooseService: "Choose a service",
RegNoticeSummary: "How we use your details (English / Bahasa Malaysia)",
RegInterests: "Interests (optional)",
RegNoticeEn: "English",
RegNoticeMs: "Bahasa Malaysia",
@@ -875,6 +878,8 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
PagesAddPoint: "Add point",
PagesFormHeading: "Form heading",
PagesFormText: "Form text",
PagesUploadImage: "Upload image",
PagesUploadImageHint: "PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag's src.",
PagesToolbar: "Formatting",
PagesTextStyle: "Text style",
PagesParagraph: "Paragraph",
@@ -552,6 +552,9 @@
"RegContactHint": "手机或电子邮件为必填项",
"RegCompany": "公司",
"RegJobTitle": "职位",
"RegServiceInterest": "感兴趣的服务(可选)",
"RegChooseService": "选择服务",
"RegNoticeSummary": "我们如何使用您的资料(English / Bahasa Malaysia)",
"RegInterests": "兴趣(可选)",
"RegNoticeEn": "英文",
"RegNoticeMs": "马来文",
@@ -860,6 +863,8 @@
"PagesAddPoint": "添加要点",
"PagesFormHeading": "表单标题",
"PagesFormText": "表单说明",
"PagesUploadImage": "上传图片",
"PagesUploadImageHint": "PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。",
"PagesToolbar": "格式",
"PagesTextStyle": "文字样式",
"PagesParagraph": "段落",