Files
calendar/packages/features/data-table/contexts
Eunjae LeeGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Claude Opus 4.5
c58e1f4ae5 feat: add filter segment validation with useActiveFiltersValidator hook and refactor DataTableProvider (#27208)
* feat: add activeFilters validator to DataTableProvider for filter segment validation

- Add validateActiveFilters prop to DataTableProvider to filter out inaccessible values
- Create useActiveFiltersValidator hook in bookings module to validate filter values
- Integrate validator in bookings-view.tsx to validate userId, eventTypeId, teamId filters
- Add comprehensive tests for the filter validation logic

This provides a scalable solution for handling stale filter segment data by validating
filters at the caller level using already-fetched accessible resource IDs.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: add type guard for eventTypeIds to ensure number[] type

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: delay segment filter application until validator is ready

- Change useActiveFiltersValidator to return 'loading' state while data is fetching
- Add pending segment handling in DataTableProvider to delay filter application
- Expose isValidatorPending in context for consumers to disable queries
- Update BookingListContainer to disable bookings query while validator is pending

This prevents both errors from invalid filters and flash from fetching without filters.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor: extract useSegmentManagement hook from DataTableProvider

- Extract segment management logic into dedicated useSegmentManagement hook
- Reduces DataTableProvider from ~500 lines to ~330 lines
- Use NuqsSetter type to match nuqs useQueryState setter signatures
- Maintains all existing functionality and type safety

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: export ActiveFiltersValidator types from data-table lib/types

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: import ActiveFiltersValidatorState from lib/types instead of hook

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* Revert "refactor: extract useSegmentManagement hook from DataTableProvider"

This reverts commit dd588ac4cfb1d709c71d1f621994a7e8f3118f33.

* refactor: split DataTableProvider into fine-grained context providers

- Create DataTableStateContext for raw nuqs state management
- Create DataTableSegmentContext for segment management
- Create DataTableFiltersContext for filter manipulation
- DataTableProvider now composes all providers with a bridge component
- Maintains backward compatibility via combined DataTableContext

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: apply segment filters when navigating back to page with existing URL state

When navigating back to a page with a segment already selected in the URL,
the segment was being marked as selected but its filters were not being
applied. This caused non-deterministic behavior where the filter segment
would sometimes not take effect.

The fix ensures that when segmentIdRaw exists in the URL and segments are
fetched, we also call applySegmentFilters() (with validator timing support)
instead of just setting the selectedSegment state.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor: simplify filter validator to only handle multi-select

These filters are always multi-select, so remove unnecessary
single-select handling code and tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: cancel debounced search term on unmount

Cancel the debounced search term on unmount/dependency change to avoid
queued updates firing after the provider unmounts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 10:38:12 +01:00
..