Skip to content

feat(search): filter events by a date range #48

Closed

Description

@Ardnived

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 dateRange group to EventFilters and DEFAULT_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 an isDateRestricted(dateRange) helper mirroring isTimeRestricted.
  • Extend matchesFilters to apply the range inside the existing per-occurrence upcomingDates loop, 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 via eventTimeZone (viewer's zone for online, UTC when firstDate_tz is null) — the same rule day/time already use. When the date filter is active, an event with no upcomingDates is excluded, matching day/time.
  • Include dateRange in activeFilterCount/hasActiveFilters (one group) and in filtersKey (the React Query identity).

URL codec — src/lib/shape/filters.ts

  • Add a compact dates param (e.g. dates=2026-07-20,2026-07-27; an empty side = open bound) to FILTER_PARAM_KEYS, filtersToParams, and filtersFromParams.
  • Parse defensively like parseTime/parseDays: reject malformed dates, enforce start <= 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" FilterGroup with two native <input type="date"> controls (From / To) — zero new dependencies, browser-localized. Set each input's min/max to [today, today + 12 months], and keep the pair valid (the To input's min follows From, and vice-versa). The group's Clear link resets dateRange; wire values through the existing patch(...) draft flow.

Pills & setters — ActiveFilterPills.tsx + use-filters.ts

  • Add setDateRange to useSetFilters (used by the pill's quick-clear, like setDaysOfWeek).
  • 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 via pnpm i18n:add. Use %{} interpolation; never name a variable count (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/filtersKey include the new group.

Acceptance criteria

  • The /filters drawer 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, no count-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:build pass.
  • 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 codec
  • src/hooks/use-filters.ts — setDateRange
  • src/components/molecules/SearchFilters/SearchFilters.tsx — Date FilterGroup
  • src/components/molecules/ActiveFilterPills/ActiveFilterPills.tsx — date pill
  • public/locales/*/common.json — filters.dates.*
  • src/lib/shape/filters.test.ts — predicate + codec tests
  • src/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)

Activity

  1. added a commit that references this issue on Jul 14, 2026
    2f10267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions