feat(admin): products and categories pages (#45, PR 3) #146

Merged
amiryahaya merged 8 commits from feat/admin-products into main 2026-11-02 17:25:36 +01:00
Owner

PR 3 of #45 (admin catalogue): products and categories pages. Web only, no API change.

Design: docs/superpowers/specs/2026-11-02-admin-catalogue-design.md · Plan: docs/superpowers/plans/2026-11-02-admin-products-categories.md

What changes (all admin_portal.administration.manage)

  • Shared photos: the PR 2 park photos block moves to src/media as Photos({ owner }) for parks, products and categories, each on its own route. ConfirmRemove moves to src/.
  • Menu: Products and Categories join the "Catalogue" group.
  • /products: category and q are filtered by the server; resident type, age group, ticket type and active in the browser (a shortcut: comment names the limit).
  • /products/new and /products/:id:
    • every ProductRequest field, with labelled choices;
    • "Any" or "None" is sent as null, and duration as a JSON number with at most 2 decimals (numeric(10,2));
    • a soft delete that asks first, and the shared photos block.
  • /categories:
    • the tree is indented by parent, siblings by name, and a parent outside the list puts the row at the root;
    • a type filter; add and edit;
    • Parent never offers the category or its descendants, checked against every category, not only the filtered ones;
    • photos per row.
  • /category-types and /park-categories: one NamedListPage (name and active). There is no delete route, so rows are switched off instead.
  • Text limits count characters the way the server does, so emoji count as one.
  • A duplicate product shows on Name, because the server's only unique key is lower(name) + resident type + category (migration 0007).

Verification

  • make cover: 91.6 % total (minimum 80 %). make lint: 0 issues.
  • Web unit tests pass everywhere (admin 366, ticket 304, ui 47, auth 45), and typecheck is clean.
  • scripts/web-e2e.sh: ticket 207, admin 125. The admin count includes a new journey at 320, 768 and 1280 px: category type, category and sub-category; a product created, edited, given a photo and removed; axe checks on every page.
  • Real local run against the dev API:
    • the tree showed the right depths, and the parent select left out the category and its child;
    • a product saved with duration 1.5 and resident type Any;
    • the photo uploaded to the products route and its preview loaded;
    • an edit saved, then the photo and the product were removed;
    • after the test parent was switched off, its child stayed under it.
    • The run found one issue, fixed with tests: category choices were not sorted by path.
  • Review:
    • Pass 1 (complexity): no must-fix. Applied: dropped an unused field, fetched category types once, shared the name check.
    • Pass 2 (correctness): two Important findings, each fixed with a test that failed first:
      • the duplicate product error pointed at Code, which came from a plan mistake;
      • a type filter could let Parent offer a descendant.
    • I also fixed three more, each with a test that failed first: more than 2 decimals in duration (re-graded up, because the database rounds them silently), and the wrong access texts on the category pages and on photos.
    • The Pass 1 re-check of the fixes: Ship.

Known and deferred

  1. The products list shows bare category names, not paths.
  2. Saving or removing a product does not refresh a park's Products tab until it reloads.
  3. After removing a product, Back shows its cached form.
  4. A delete conflict says "use Reload" with no button nearby (pre-existing).
  5. A new category does not preselect the filtered type.
  6. Category labels are built in quadratic time (fine at hundreds of categories).
  7. The created product is kept in a result! variable.
  8. The product pages pass no-op callbacks.
  9. The Parent column uses filtered names.
  10. A stray categoryTypesKey export.
  11. The shared nameError lives in products/.
  • The dev database keeps two inactive test categories and one soft-deleted test product.

🤖 Generated with Claude Code

PR 3 of #45 (admin catalogue): products and categories pages. Web only, no API change. Design: `docs/superpowers/specs/2026-11-02-admin-catalogue-design.md` · Plan: `docs/superpowers/plans/2026-11-02-admin-products-categories.md` ## What changes (all `admin_portal.administration.manage`) - **Shared photos:** the PR 2 park photos block moves to `src/media` as `Photos({ owner })` for parks, products and categories, each on its own route. `ConfirmRemove` moves to `src/`. - **Menu:** Products and Categories join the "Catalogue" group. - **`/products`:** category and `q` are filtered by the server; resident type, age group, ticket type and active in the browser (a `shortcut:` comment names the limit). - **`/products/new` and `/products/:id`:** - every `ProductRequest` field, with labelled choices; - "Any" or "None" is sent as `null`, and duration as a JSON number with at most 2 decimals (`numeric(10,2)`); - a soft delete that asks first, and the shared photos block. - **`/categories`:** - the tree is indented by parent, siblings by name, and a parent outside the list puts the row at the root; - a type filter; add and edit; - Parent never offers the category or its descendants, checked against every category, not only the filtered ones; - photos per row. - **`/category-types` and `/park-categories`:** one `NamedListPage` (name and active). There is no delete route, so rows are switched off instead. - Text limits count characters the way the server does, so emoji count as one. - A duplicate product shows on Name, because the server's only unique key is lower(name) + resident type + category (migration 0007). ## Verification - `make cover`: **91.6 %** total (minimum 80 %). `make lint`: 0 issues. - Web unit tests pass everywhere (admin 366, ticket 304, ui 47, auth 45), and typecheck is clean. - `scripts/web-e2e.sh`: ticket 207, admin 125. The admin count includes a new journey at 320, 768 and 1280 px: category type, category and sub-category; a product created, edited, given a photo and removed; axe checks on every page. - Real local run against the dev API: - the tree showed the right depths, and the parent select left out the category and its child; - a product saved with duration 1.5 and resident type Any; - the photo uploaded to the products route and its preview loaded; - an edit saved, then the photo and the product were removed; - after the test parent was switched off, its child stayed under it. - The run found one issue, fixed with tests: category choices were not sorted by path. - Review: - **Pass 1 (complexity):** no must-fix. Applied: dropped an unused field, fetched category types once, shared the name check. - **Pass 2 (correctness):** two Important findings, each fixed with a test that failed first: - the duplicate product error pointed at Code, which came from a plan mistake; - a type filter could let Parent offer a descendant. - I also fixed three more, each with a test that failed first: more than 2 decimals in duration (re-graded up, because the database rounds them silently), and the wrong access texts on the category pages and on photos. - The Pass 1 re-check of the fixes: Ship. ## Known and deferred 1. The products list shows bare category names, not paths. 2. Saving or removing a product does not refresh a park's Products tab until it reloads. 3. After removing a product, Back shows its cached form. 4. A delete conflict says "use Reload" with no button nearby (pre-existing). 5. A new category does not preselect the filtered type. 6. Category labels are built in quadratic time (fine at hundreds of categories). 7. The created product is kept in a `result!` variable. 8. The product pages pass no-op callbacks. 9. The Parent column uses filtered names. 10. A stray `categoryTypesKey` export. 11. The shared `nameError` lives in `products/`. - The dev database keeps two inactive test categories and one soft-deleted test product. 🤖 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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also from the local run: category choices are sorted by their full path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(admin): review fixes for products and categories (#45)
All checks were successful
ci / changes (pull_request) Successful in 21s
ci / clients (pull_request) Has been skipped
ci / api (pull_request) Has been skipped
ci / web (pull_request) Successful in 5m32s
ci / ci-gate (pull_request) Successful in 3s
e4668066c5
- a duplicate product shows on Name (name + resident type + category is the server's rule)
- the parent check uses every category, so a type filter cannot hide a descendant
- duration allows at most 2 decimals (numeric(10,2))
- category and photo pages have their own access text
- drop the unused orphan flag, fetch category types once, share the name check

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!146
No description provided.