feat(admin): promo codes, places and visitor forms pages (#45, PR 4) #147

Merged
amiryahaya merged 6 commits from feat/admin-promos-places-forms into main 2026-11-03 01:31:55 +01:00
Owner

PR 4 of #45 (admin catalogue): promo codes, places and visitor forms pages. Web only, no API change. Closes the last slice of #45.

Design: docs/superpowers/specs/2026-11-02-admin-catalogue-design.md · Plan: docs/superpowers/plans/2026-11-03-admin-promos-places-forms.md

What changes (all admin_portal.administration.manage, in the Catalogue menu group)

  • /promo-codes, /promo-codes/new, /promo-codes/:id:
    • the list shows code, discount, park, valid from and to, used / max, and active;
    • the form has percentage or fixed (Currency only for fixed, sent as null otherwise), park ("All parks"), and "All products" or a product checklist that shows the resident type and an "(inactive)" mark;
    • Nairobi datetime-local dates are sent as +03:00 instants, and an untouched date is sent back exactly as stored, seconds included (helper shared with rates);
    • maximum uses, active, "Used: N", and a remove that asks first;
    • value checks are text compares that mirror promos/validate.go (no float parsing);
    • a duplicate code shows on Code.
  • /places:
    • countries, then states, then cities on one page, with the choice in the URL (?country=&state=); choosing another country clears the state;
    • add and edit at each level (there is no delete route); ISO codes are upper-cased;
    • a duplicate country is a form message, and a duplicate state or city shows on Name.
  • /forms, /forms/new, /forms/:id:
    • a form has a name, columns (1..12) and active;
    • its inputs table is sorted by display order, with an inline editor for the 18 input types and 5 purposes; blank numbers are sent as null;
    • removing a form that products still use shows "used by products" instead of the stale-version text, through a new optional conflict hook on ConfirmRemove.
  • Products' form picker and the currency form's country list refresh after these writes.

Verification

  • make cover: 91.6 % total (minimum 80 %).
  • Web unit tests: admin 397, ticket 304, ui 47, auth 45, all passing; typecheck is clean.
  • scripts/web-e2e.sh: ticket 207, admin 128. The admin count includes a new journey at 320, 768 and 1280 px (a promo code; a country, state and city; a form with two inputs, one removed, then the form removed), with axe checks.
  • Real local run against the dev API:
    • a promo saved with Nairobi times and the database held the right UTC;
    • the places drill-down worked, and switching the country cleared the state;
    • a duplicate input purpose showed the fixed text;
    • the products' form picker listed the new form;
    • removing an input, the form and the promo through the UI worked.
    • The run found the places panels cramped side by side; they are now stacked, with each list scrolling.
  • Review:
    • Pass 1 (complexity):
      • Must fix: the product picker could not tell same-named products apart. Fixed: each box now shows the resident type.
      • Applied cleanups: reuse nameError/chars, t() for "None", one NEW map, no TITLE map, one Form type.
      • The re-check of the fixes: Ship.
    • Pass 2 (correctness):
      • One Important finding, fixed with a test that failed first: saving any edit cut the promo dates to the minute.
      • A Minor finding re-graded up and fixed under the same test: a removed product stayed in a promo with no visible box.

Known and deferred

  1. The value field reads "Amount" for a percentage too.
  2. A hand-edited ?state= from another country shows that state's cities.
  3. The product picker's error is not linked to its checkboxes for screen readers.
  4. The "form in use" text may wrap in the inputs table.
  5. The axe helper is copied in four e2e specs.
  6. A places panel prop type is written out by hand.
  7. Removing a form fetches it once more and gets an unseen 404.
  8. A removed product disappears once unticked and cannot be ticked again without a reload.
  9. The date helper is imported under an alias.
  10. The countries list has no search.
  11. The product picker is not narrowed by park.
  • The dev database keeps the test country, state and city (there is no delete route), plus a soft-deleted test form and promo.

🤖 Generated with Claude Code

PR 4 of #45 (admin catalogue): promo codes, places and visitor forms pages. Web only, no API change. Closes the last slice of #45. Design: `docs/superpowers/specs/2026-11-02-admin-catalogue-design.md` · Plan: `docs/superpowers/plans/2026-11-03-admin-promos-places-forms.md` ## What changes (all `admin_portal.administration.manage`, in the Catalogue menu group) - **`/promo-codes`, `/promo-codes/new`, `/promo-codes/:id`:** - the list shows code, discount, park, valid from and to, used / max, and active; - the form has percentage or fixed (Currency only for fixed, sent as `null` otherwise), park ("All parks"), and "All products" or a product checklist that shows the resident type and an "(inactive)" mark; - Nairobi `datetime-local` dates are sent as `+03:00` instants, and an untouched date is sent back exactly as stored, seconds included (helper shared with rates); - maximum uses, active, "Used: N", and a remove that asks first; - value checks are text compares that mirror `promos/validate.go` (no float parsing); - a duplicate code shows on Code. - **`/places`:** - countries, then states, then cities on one page, with the choice in the URL (`?country=&state=`); choosing another country clears the state; - add and edit at each level (there is no delete route); ISO codes are upper-cased; - a duplicate country is a form message, and a duplicate state or city shows on Name. - **`/forms`, `/forms/new`, `/forms/:id`:** - a form has a name, columns (1..12) and active; - its inputs table is sorted by display order, with an inline editor for the 18 input types and 5 purposes; blank numbers are sent as `null`; - removing a form that products still use shows "used by products" instead of the stale-version text, through a new optional `conflict` hook on `ConfirmRemove`. - Products' form picker and the currency form's country list refresh after these writes. ## Verification - `make cover`: **91.6 %** total (minimum 80 %). - Web unit tests: admin 397, ticket 304, ui 47, auth 45, all passing; typecheck is clean. - `scripts/web-e2e.sh`: ticket 207, admin 128. The admin count includes a new journey at 320, 768 and 1280 px (a promo code; a country, state and city; a form with two inputs, one removed, then the form removed), with axe checks. - Real local run against the dev API: - a promo saved with Nairobi times and the database held the right UTC; - the places drill-down worked, and switching the country cleared the state; - a duplicate input purpose showed the fixed text; - the products' form picker listed the new form; - removing an input, the form and the promo through the UI worked. - The run found the places panels cramped side by side; they are now stacked, with each list scrolling. - Review: - **Pass 1 (complexity):** - Must fix: the product picker could not tell same-named products apart. Fixed: each box now shows the resident type. - Applied cleanups: reuse `nameError`/`chars`, `t()` for "None", one `NEW` map, no `TITLE` map, one `Form` type. - The re-check of the fixes: Ship. - **Pass 2 (correctness):** - One Important finding, fixed with a test that failed first: saving any edit cut the promo dates to the minute. - A Minor finding re-graded up and fixed under the same test: a removed product stayed in a promo with no visible box. ## Known and deferred 1. The value field reads "Amount" for a percentage too. 2. A hand-edited `?state=` from another country shows that state's cities. 3. The product picker's error is not linked to its checkboxes for screen readers. 4. The "form in use" text may wrap in the inputs table. 5. The axe helper is copied in four e2e specs. 6. A places panel prop type is written out by hand. 7. Removing a form fetches it once more and gets an unseen 404. 8. A removed product disappears once unticked and cannot be ticked again without a reload. 9. The date helper is imported under an alias. 10. The countries list has no search. 11. The product picker is not narrowed by park. - The dev database keeps the test country, state and city (there is no delete route), plus a soft-deleted test form and promo. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(admin): keep promo seconds, label and keep products in the picker (#45)
All checks were successful
ci / changes (pull_request) Successful in 12s
ci / clients (pull_request) Has been skipped
ci / api (pull_request) Has been skipped
ci / web (pull_request) Successful in 6m20s
ci / ci-gate (pull_request) Successful in 3s
06aa3ff822
Review fixes: an untouched promo date is sent as stored (shared instantOf
with rates), product boxes show the resident type and a product the list
lacks stays shown. Cleanups: reuse nameError/chars, t() for None, one NEW
map, no TITLE map, one Form type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!147
No description provided.