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: handle static filters and refactor component #1990

Merged
merged 11 commits into from
Jan 15, 2025
Merged

Conversation

keellyp
Copy link
Collaborator

@keellyp keellyp commented Jan 14, 2025

Context

Related to Analytics revamp feature

Description

This PR improves the Filter component by:

  • renaming filters into availableFilters props
  • adding staticFilters props to handle "default" filters
  • creating a new FilterContext to avoid props drilling
  • creating a new useFilter hook accessible for all components inside filter context provider
  • refactoring QuickFilters by creating a more generic function to build URL params

How to use it

 <Filters.Provider
  quickFiltersType={AvailableQuickFilters.InvoiceStatus}
  availableFilters={[
    AvailableFiltersEnum.status,
    AvailableFiltersEnum.invoiceType
  ]}
  staticFilters={{
    [AvailableFiltersEnum.currency]: Currency.Eur
  }}
>
  <Filters.QuickFilters /> // Optional component
  <Filters.Component />
</Filters.Provider>

Fixes LAGO-652

@keellyp keellyp self-assigned this Jan 14, 2025
@keellyp keellyp merged commit d9c6fb8 into main Jan 15, 2025
4 checks passed
@keellyp keellyp deleted the lago-652-filters branch January 15, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants