feat(filters): make the storefront filter panel searchable and multi-select (#139)

The filter drawer did not scale with the taxonomy behind it. Categories were a bare antd `Tree` rendered at whatever depth it had grown to, with no search and single selection, and tags were a wall of every tag in the system. Neither said what was selected except through highlighting and chip colour.

Both are now searchable multi-selects. Categories keep their hierarchy in a `TreeSelect`, matching the admin's `CategoryTreeSelect` so the two screens behave alike; tags become a multiple `Select` whose selected pills keep their colours, which is the only place a tag's colour was load-bearing.

Several categories combine as OR. A customer picking Furniture and Decor wants both, not the empty intersection, and each selected id still expands to its descendants, so the answer is the union of the subtrees. That is deliberately the opposite of the tag rule, which stays AND, and both headings now state their rule rather than leaving it to be discovered.

`ItemFilters.categoryId` becomes `categoryIds` end to end. The recursive CTE is seeded with `= ANY($n::int[])` rather than one id, which walks every selected root in one recursion and gives the OR for free; matching on `IN` keeps it a set test, so an item under two selected branches still appears once. The query parameter keeps its singular name and becomes comma-separated, the shape `tags` and `status` already use, so every `?category=1` link written before this still parses as a list of one. A list containing anything unreadable is still a 400, per decision 9 — honouring the readable half would answer a narrower question than the one asked and look indistinguishable from a filter that worked.

The admin's inventory filter stays single-select, since it asks what is in a category rather than in any of several, but reads and writes a list of at most one so there is one shared filter type rather than two that drift.

Closes #139
This commit is contained in:
2026-08-24 16:02:33 -05:00
parent 70cc3056e7
commit faf38be91a
9 changed files with 308 additions and 79 deletions
+10 -2
View File
@@ -65,8 +65,16 @@ export default function InventoryFilters({ categories, tags, filters, onChange,
aria-label="Filter by category"
style={{ minWidth: 200 }}
treeData={treeData}
value={filters.categoryId ?? undefined}
onChange={(value) => onChange({ ...filters, categoryId: value ?? null })}
// The filter shape went multi-valued for the storefront (#139). This
// control stays single-select — the admin asks "what is in this
// category", not "in any of these" — so it reads and writes a list of
// at most one rather than growing a second shape.
value={filters.categoryIds[0] ?? undefined}
// Annotated nullable because allowClear hands back undefined, which
// the control's own onChange type does not admit.
onChange={(value: number | undefined) =>
onChange({ ...filters, categoryIds: value === undefined ? [] : [value] })
}
/>
<Select