Repository navigation
feat(catalog): two-level category tree (subcategory UI) #1340
Copy link
Copy link
Open
Labels
area:backendBackend (Express/SQLite)Backend (Express/SQLite)area:frontendFrontend (React/Next.js)Frontend (React/Next.js)enhancementNew feature or requestNew feature or requeststate:readyScoped and ready for implementationScoped and ready for implementationtype:featureNew capability or enhancement requestNew capability or enhancement request
Description
Parent: #830 (S5). Verified against main @ 8e39053.
Problem
Stores with large menus want subcategories, for example Drinks > Hot / Cold (+44, 21 Sep).
Current behavior (verified)
- The backend already supports it.
categories.parent_idhas been in the schema since the start (main/db.ts~L7883).main/routes/categories.ts~L111-140 validates the parent and blocks cycles on create and update.GET /categories?rootand?parent_id=exist and nest one level. Tests:tests/issue-247-catalog-invariants.test.ts. - There is no UI.
parent_idappears only infrontend/src/lib/types.ts. The category form (frontend/src/app/(dashboard)/products/page.tsx~L695-701) never sends it, and POS loads a flat list (pos/page.tsx~L1065).
Decisions (made)
- Max depth 2 (category > subcategory). The API should reject a parent that itself has a parent, which matches the one-level nesting GET already returns.
- POS: tapping a parent shows its subcategory chips and the parent's own products. "All" still shows everything.
- Sort order (feat(pos): configurable category and item sort order #1311) applies among siblings.
Scope
- Products page category form: an optional "Parent category" select limited to root categories, and an indented tree in the categories list.
- POS category bar and
components/pos/ProductGrid.tsx: subcategory navigation. - Menu CSV import/export (
main/routes/menu-csv.ts): aparentcolumn by name, resolved on import. - Menu printing (
main/printers/document-menu.ts): print subcategories under their parent. - Backend: enforce depth 2 in
categories.ts. Deleting or deactivating a parent with children must be refused or must re-parent the children (choose refuse, with a clear message).
Acceptance criteria
- Create a subcategory from the UI, and see it under its parent in management, POS and the printed menu.
- Setting a grandchild parent is rejected (400).
- A CSV round-trip preserves the hierarchy.
- Stores with no subcategories look exactly as before.
Verification
- Extend
tests/issue-247-catalog-invariants.test.tsand the menu CSV tests, plus an e2e for create and POS navigation. npm run lint && npm test
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:backendBackend (Express/SQLite)Backend (Express/SQLite)area:frontendFrontend (React/Next.js)Frontend (React/Next.js)enhancementNew feature or requestNew feature or requeststate:readyScoped and ready for implementationScoped and ready for implementationtype:featureNew capability or enhancement requestNew capability or enhancement request
Activity