Skip to content

feat(catalog): two-level category tree (subcategory UI) #1340

Open

Description

@khaira777

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_id has 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?root and ?parent_id= exist and nest one level. Tests: tests/issue-247-catalog-invariants.test.ts.
  • There is no UI. parent_id appears only in frontend/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): a parent column 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.ts and the menu CSV tests, plus an e2e for create and POS navigation.
  • npm run lint && npm test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendBackend (Express/SQLite)area:frontendFrontend (React/Next.js)enhancementNew feature or requeststate:readyScoped and ready for implementationtype:featureNew capability or enhancement request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions