Repository navigation
Closed
Description
Summary
The event filters (/filters drawer) let visitors narrow the map + list by format, frequency, day of week, time of day, and language — but not by when an event happens. Someone planning a trip or a specific weekend can't ask "show me classes between these two dates." Add a date-range filter: pick a start and/or end date within the next 12 months and keep only events with an upcoming occurrence in that window. Like every other filter it lives in the URL (so a dated view is linkable/shareable) and drives the map, results list, active-filter pills, and FilterButton badge through the single matchesFilters predicate.
Proposed changes
Filter model & predicate — src/lib/shape/filters.ts
- Add a
dateRangegroup toEventFiltersandDEFAULT_FILTERS(frozen like the other defaults): a start/end pair of calendar dates (yyyy-MM-dd), each bound independently optional, defaulting to no restriction. Add anisDateRestricted(dateRange)helper mirroringisTimeRestricted. - Extend
matchesFiltersto apply the range inside the existing per-occurrenceupcomingDatesloop, so one occurrence must satisfy weekday and time-of-day and date-range together (a Jul-20 occurrence and a Jul-27 occurrence must not combine). Evaluate each occurrence's calendar date in the event's own frame viaeventTimeZone(viewer's zone for online, UTC whenfirstDate_tzis null) — the same rule day/time already use. When the date filter is active, an event with noupcomingDatesis excluded, matching day/time. - Include
dateRangeinactiveFilterCount/hasActiveFilters(one group) and infiltersKey(the React Query identity).
URL codec — src/lib/shape/filters.ts
- Add a compact
datesparam (e.g.dates=2026-07-20,2026-07-27; an empty side = open bound) toFILTER_PARAM_KEYS,filtersToParams, andfiltersFromParams. - Parse defensively like
parseTime/parseDays: reject malformed dates, enforcestart <= end, and clamp to[today, today + 12 months]so a hand-crafted URL can't escape the window. Omit the param when unrestricted so links stay clean.
Form — src/components/molecules/SearchFilters/SearchFilters.tsx (the form FilterView renders)
- Add a "Date"
FilterGroupwith two native<input type="date">controls (From / To) — zero new dependencies, browser-localized. Set each input'smin/maxto[today, today + 12 months], and keep the pair valid (the To input'sminfollows From, and vice-versa). The group's Clear link resetsdateRange; wire values through the existingpatch(...)draft flow.
Pills & setters — ActiveFilterPills.tsx + use-filters.ts
- Add
setDateRangetouseSetFilters(used by the pill's quick-clear, likesetDaysOfWeek). - Add one collapsed date pill showing the formatted window (locale-aware luxon
DateTime,DATE_MED; render "From …", "Until …", or "… – …"). Its X clears the whole group.
i18n — public/locales/<lng>/common.json (10 locales: cs de en es fr hu nl pt-BR ru uk)
- Add
filters.dates.*keys (label,from,to, pill/format string) across every locale viapnpm i18n:add. Use%{}interpolation; never name a variablecount(reserved plural trigger). New keys need a full dev reload, not just HMR.
Tests — src/lib/shape/filters.test.ts
- Occurrence inside vs. outside range; per-occurrence AND with day/time; exclusion on empty
upcomingDates; timezone-frame correctness (online / null-tz). - Codec round-trip + clamp (out-of-window / reversed / malformed
dates). activeFilterCount/filtersKeyinclude the new group.
Acceptance criteria
- The
/filtersdrawer shows a Date group with From/To native inputs bounded to today … today + 12 months; the Apply count and map/list update when a range is applied. - An event matches only when some upcoming occurrence's calendar date falls in range (in the event's own timezone), combined per-occurrence with any active day/time filter; events with no upcoming dates are excluded while the date filter is active.
- The range round-trips through the URL (
dates=…); an out-of-window, reversed, or malformed value is clamped/ignored, not trusted. - An active range shows as one removable pill whose X clears it; the FilterButton badge counts it; "Clear all" resets it.
-
filters.dates.*exists in every locale; pill + input labels render localized, no raw keys, nocount-plural misuse. - Unit tests cover the predicate (range, per-occurrence AND, tz, empty dates) and the codec (round-trip + clamp).
- Lint + typecheck +
test:run+ build +ladle:buildpass. - Verified in the running widget (range → map/list/pill/URL agree; check one non-en locale).
Files affected
src/lib/shape/filters.ts— model,matchesFilters, counts,filtersKey, URL codecsrc/hooks/use-filters.ts—setDateRangesrc/components/molecules/SearchFilters/SearchFilters.tsx— DateFilterGroupsrc/components/molecules/ActiveFilterPills/ActiveFilterPills.tsx— date pillpublic/locales/*/common.json—filters.dates.*src/lib/shape/filters.test.ts— predicate + codec testssrc/views/FilterView/FilterView.tsx— no change expected (already renders<SearchFilters>+ Apply count)
References
- Filters-in-URL architecture:
.claude/rules/i18n-and-state.md; occurrence semantics:matchesFilters(src/lib/shape/filters.ts:81) - Related recent work:
fix(search): keep active filters when searching a place(333d106)
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Hold Until
None yet
Activity
feat(search): filter events by a date range (#50)