Skip to content

Add category filtering to catalog - #50

Merged
benhalverson merged 1 commit into
mainfrom
categories-ui
Jul 7, 2026
Merged

Add category filtering to catalog#50
benhalverson merged 1 commit into
mainfrom
categories-ui

Conversation

@benhalverson

Copy link
Copy Markdown
Owner

Summary

  • add API-backed category chips to the home catalog page
  • load the small catalog with a high product limit and filter/paginate client-side by URL-backed categoryId
  • add category/product response typing and ProductList coverage for URL initialization, All reset, null-category products, and category fetch failure
  • record the storefront/domain decisions from the planning session

Validation

  • pnpm biome check src/pages/ProductList.tsx src/pages/ProductList.test.tsx src/interfaces/category.ts src/interfaces/index.ts src/interfaces/productResponse.ts
  • pnpm test -- ProductList.test.tsx
  • pnpm run build
  • git diff --check

Notes

  • Full pnpm run check still reports unrelated pre-existing formatting issues in ErrorBoundary.test.tsx, Product.test.tsx, Profile.test.tsx, and webauthn.test.ts.

Copilot AI review requested due to automatic review settings July 7, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds API-backed category filtering to the storefront catalog (ProductList), keeping the selected category in the URL (categoryId) while filtering and paginating client-side over a larger “small catalog” fetch. It also introduces category typing, tests around URL initialization/reset and failure handling, and adds ADR/context documentation capturing the storefront/domain decisions.

Changes:

  • Fetch a larger product catalog once, fetch categories in parallel, and filter/paginate client-side based on URL categoryId.
  • Add category/product response typing updates (including nullable/optional categoryId).
  • Add Vitest coverage for category chips, URL sync/reset, uncategorized products, and category-fetch failure; add ADR/context docs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/pages/ProductList.tsx Adds category chips driven by /categories, URL-backed categoryId, and client-side filtering/pagination over a larger catalog fetch.
src/pages/ProductList.test.tsx New tests for URL initialization/reset, single-select category behavior, uncategorized products, and category fetch failure/toast behavior.
src/interfaces/productResponse.ts Extends product typing with categoryId?: number | null.
src/interfaces/index.ts Re-exports category interface.
src/interfaces/category.ts Adds CategoryResponse typing for /categories.
docs/adr/0002-client-side-category-filtering-first.md Records the client-side-first filtering decision and failure behavior expectations.
docs/adr/0001-keep-storefront-customer-facing.md Captures the “storefront is customer-facing” decision.
CONTEXT.md Adds shared vocabulary/definitions (storefront, category filter, uncategorized product, etc.).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pages/ProductList.tsx
Comment on lines +29 to +30
const selectedCategoryId = parseCategoryId(searchParams.get("categoryId"));

@benhalverson
benhalverson marked this pull request as ready for review July 7, 2026 06:20
@benhalverson
benhalverson merged commit 10d5ee2 into main Jul 7, 2026
2 checks passed
@benhalverson
benhalverson deleted the categories-ui branch July 7, 2026 06:21
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.

2 participants