Skip to content

Comments

feat: add group filter to product listing and related hooks#71

Open
carlosmfreitas2409 wants to merge 1 commit intouseautumn:mainfrom
carlosmfreitas2409:feat/group-filter
Open

feat: add group filter to product listing and related hooks#71
carlosmfreitas2409 wants to merge 1 commit intouseautumn:mainfrom
carlosmfreitas2409:feat/group-filter

Conversation

@carlosmfreitas2409
Copy link

@carlosmfreitas2409 carlosmfreitas2409 commented Feb 12, 2026

Summary

Add optional group filter parameter to the product listing endpoint and related React hooks.

PR in Autumn: useautumn/autumn#735


Summary by cubic

Add an optional group filter to product listing to fetch and cache products by group. This helps pricing tables and product lists load only products for a specific group.

  • New Features
    • Backend: GET /products accepts ?group= and forwards it to autumn.products.list.
    • Client: products.list({ group }) builds the query string.
    • Hooks: usePricingTable, usePricingTableBase, and useProductsBase accept group and pass it through; SWR keys now include group.
    • Types: ListProductsParams updated in SDK and client with group.

Written for commit c04e2b3. Summary will update on new commits.

Greptile Overview

Greptile Summary

This PR adds an optional group filter parameter to the product listing functionality across the entire stack. The changes enable filtering products by group at the API level, backend routes, React client methods, and React hooks.

API changes

  • Added optional group parameter to ListProductsParams in both SDK and client type definitions
  • Updated backend route handler to extract and pass group from URL search parameters
  • Modified React client listProductsMethod to build query strings with the new parameter
  • Enhanced React hooks (usePricingTable, usePricingTableBase, useProductsBase) to accept and use the group parameter
  • Properly updated SWR cache keys to include group for correct cache invalidation

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, consistent, and follows existing patterns. All changes are additive (optional parameter), maintaining backward compatibility. SWR cache keys are correctly updated to include the new parameter for proper invalidation.
  • No files require special attention

Important Files Changed

Filename Overview
package/src/sdk/products/prodTypes.ts Added optional group field to ListProductsParams interface for filtering products by group
package/src/libraries/backend/routes/productRoutes.ts Extracts group from search params and passes it to the product list method in the backend route handler
package/src/libraries/react/client/clientProdMethods.ts Updated listProductsMethod to accept optional params and build query string using buildPathWithQuery utility
package/src/libraries/react/hooks/usePricingTableBase.tsx Passes group param to products.list call and includes it in SWR cache key for correct cache invalidation

Sequence Diagram

sequenceDiagram
    participant Client as React Client
    participant Hook as usePricingTable/useProductsBase
    participant Method as listProductsMethod
    participant Backend as Backend Route
    participant SDK as Autumn SDK

    Client->>Hook: usePricingTable({ group: "premium" })
    Hook->>Method: client.products.list({ group: "premium" })
    Method->>Method: buildPathWithQuery("/products", { group: "premium" })
    Method->>Backend: GET /products?group=premium
    Backend->>Backend: Extract group from searchParams
    Backend->>SDK: autumn.products.list({ customer_id, group })
    SDK-->>Backend: { list: Product[] }
    Backend-->>Method: { list: Product[] }
    Method-->>Hook: { data: { list: Product[] } }
    Hook->>Hook: Update SWR cache with key ["pricing-table", "premium", backendUrl]
    Hook-->>Client: { products: Product[] }
Loading

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

@vercel
Copy link

vercel bot commented Feb 12, 2026

@carlosmfreitas2409 is attempting to deploy a commit to the Autumn Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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