From 2f0da9afe1b5ded4d9a72af6aeff8061ee96a146 Mon Sep 17 00:00:00 2001 From: Thom Lamb Date: Tue, 25 Aug 2026 15:30:27 -0500 Subject: [PATCH] refactor(admin): compose the inventory filters from dimensions (#188) --- frontend/src/admin/InventoryFilters.tsx | 59 +++++++------------------ 1 file changed, 15 insertions(+), 44 deletions(-) diff --git a/frontend/src/admin/InventoryFilters.tsx b/frontend/src/admin/InventoryFilters.tsx index 36f83d7..90e7163 100644 --- a/frontend/src/admin/InventoryFilters.tsx +++ b/frontend/src/admin/InventoryFilters.tsx @@ -1,10 +1,12 @@ -import { useState } from 'react'; -import Button from 'antd/es/button'; -import { FilterOutlined } from '@ant-design/icons'; import type { Category, Tag } from '../api'; -import { ItemFilters, activeFilterCount } from '../filters'; -import FilterDrawer from '../components/FilterDrawer'; -import ActiveFilterChips from '../components/ActiveFilterChips'; +import { ItemFilters } from '../filters'; +import FilterBar from '../components/filters/FilterBar'; +import { + categoryDimension, + priceDimension, + statusDimension, + tagDimension +} from '../components/filters/standardDimensions'; type Props = Readonly<{ categories: Category[]; @@ -15,16 +17,11 @@ type Props = Readonly<{ resultCount: number; }>; -// The same flyout the storefront uses, rather than the row of controls this -// used to be (#169). -// -// That row was deliberate — it carried a comment arguing that hiding the -// controls above a data table costs more than the space it saves, and that a -// drawer overlays the very rows being filtered. Both are true, and both are -// traded for the two screens asking the same questions through the same UI. -// The chips are what makes the trade bearable: the active filter stays readable -// beside the button without opening anything, which is what the always-visible -// row was really protecting. +// Status, and no favorites: pending is excluded from every public read, so +// Published and Unpublished are distinctions only the admin can draw, and +// favoriting is a customer's idea. +const DIMENSIONS = [categoryDimension, tagDimension, priceDimension, statusDimension]; + export default function InventoryFilters({ categories, tags, @@ -33,45 +30,19 @@ export default function InventoryFilters({ onClear, resultCount }: Props) { - const [drawerOpen, setDrawerOpen] = useState(false); - - // Status lives in the drawer here, unlike on the storefront, so it belongs in - // the button's tally — activeFilterCount leaves it out precisely because the - // storefront filters status outside the drawer. - const activeCount = activeFilterCount(filters) + (filters.status === null ? 0 : 1); - return (
- - - - - setDrawerOpen(false)} categories={categories} tags={tags} // No slider: the admin has no catalogue-wide price range to bound one // with, and inventing bounds would misreport where the prices are. priceRange={null} - filters={filters} - onChange={onChange} - onClear={onClear} resultCount={resultCount} - showStatus />
);