Skip to content

feat(categories): nested store and menu categories - #82

Merged
roncodes merged 1 commit into
release/v0.1.0from
feat/nested-categories
Oct 16, 2026
Merged

roncodes merged 1 commit into
release/v0.1.0from
feat/nested-categories

Conversation

@roncodes

Copy link
Copy Markdown
Member

Summary

The app side of nested categories (fleetbase/storefront#156). Storefront now nests product and catalog categories up to three levels, for example Drinks › Coffee › Cold brew. Every category carries its parent (public id), and products?category= returns a category's products together with those of every category under it.

Changes

  • New src/commerce/categories.ts: builds the tree from the flat list, with categoryIndex, ancestorAt, descendantIds and groupByCategory.
  • Store page (NetworkStoreScreen):
    • top-level categories are the tabs;
    • each section loads its products in one query, replacing one query per category;
    • products show in headings by subcategory: a level-2 heading, then level-3 subheadings;
    • a chip row under the tabs jumps to a subcategory;
    • categoryId links resolve at any level.
  • Category list (StoreCatalogScreen): top-level rows with their subcategories as pills. A pill now opens that subcategory's heading, where before it opened the parent's section.
  • Search (StoreSearchScreen): the chips show top-level categories only.
  • Food trucks:
    • truckCategories lists top-level menu categories only;
    • truckProducts gives each product's top-level category and its place below it;
    • TruckMenuScreen uses tabs for top-level categories, with subcategory headings inside;
    • truck search also matches the top-level category's name.

Compatibility

Against an API without parent, every category is top-level and the screens behave as before. The catalog list still reads a category's subcategories when an older API lists them.

Tests

  • New __tests__/commerce/categories.test.ts (6 tests): the tree, SDK resources, loops, ancestorAt and grouping.
  • __tests__/commerce/food-trucks.test.ts: menus offer top-level categories only, and products carry their place in the menu.
  • jest: 46 suites, 302 tests passed.
  • eslint on the changed files: no errors. The warnings are inline styles, matching the surrounding code.
  • tsc: no new errors. The one error in NetworkStoreScreen (line 435, formatCurrency) is already on the base branch.

Not run on a device or simulator.

Storefront nests product and catalog categories up to three levels
(Drinks › Coffee › Cold brew); each category carries its parent.

- Store page: top-level categories are the tabs; each section loads its
  products once (the API rolls up the subcategories' products, replacing one
  query per category) and shows them in headings by subcategory, with chips to
  jump to a subcategory. A link to any category opens its heading.
- Category list: top-level rows with their subcategories as pills; a pill
  opens that subcategory on the store page.
- Search chips list top-level categories only.
- Truck menus: tabs by top-level menu category, subcategory headings inside;
  the trucks map's category tiles are top-level only; truck search also
  matches the top-level category.

Against an API without parents every category is at the top, as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant