Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Filters prefix #2014

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: Filters prefix #2014

wants to merge 5 commits into from

Conversation

stephenlago99
Copy link
Collaborator

Context

The current Filters architecture makes it impossible to have 2 sets of filters on the same page, because of how the filters are stored in the URL params.

Description

Added a new prop filtersNamePrefix which enables us to have multiple Filters on the same page by prefixing their name:

https://app.lago.dev/invoices/invoices?
  in_amount=isBetween%2C5%2C100
  &in_currency=USD
  &cn_amount=isBetween%2C5%2C6
  &cn_creditNoteCreditStatus=voided

To use this functionality, we need to pass the new prop in two places:

  • The Filters.Provider
  <Filters.Provider
    quickFiltersType={AvailableQuickFilters.InvoiceStatus}
    filtersNamePrefix="in"
    ...
  • When calling the formatFiltersForQuery function
  return formatFiltersForQuery({
    searchParams,
    availableFilters: InvoiceAvailableFilters,
    filtersNamePrefix: 'in',
  })

Implementation

I've tried to keep the existing structure, without changing too many things. Most of the work was done inside useFilters, since it assumed a single set of filters in most cases (for example when setting a quick filter, or when resetting filters, it was deleting everything from the search params).

Screenshot

image

@stephenlago99 stephenlago99 self-assigned this Feb 5, 2025
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.

3 participants