diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-05-19 22:32:14 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-05-19 22:32:14 +0900 |
| commit | 7c5860ce57a334b7ab4a501de78f1a7f41c8cdcc (patch) | |
| tree | 20d2236933b6e23765aef9c87612203ccbbf2cfc /app/lib/venue-filter.ts | |
| parent | 23afa26eeedf271081b4f369893f785b41d2fa0a (diff) | |
Add venue visibility toggles with localStorage persistence
Each venue on /venues can be toggled on/off; state persists in
localStorage. Hidden venues are filtered out of the event list,
with a notice linking back to the venues page to manage the setting.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app/lib/venue-filter.ts')
| -rw-r--r-- | app/lib/venue-filter.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/lib/venue-filter.ts b/app/lib/venue-filter.ts new file mode 100644 index 0000000..db41f0e --- /dev/null +++ b/app/lib/venue-filter.ts @@ -0,0 +1,28 @@ +import { useState, useEffect } from "react"; + +const STORAGE_KEY = "hidden_venue_ids"; + +export function useVenueFilter() { + const [hiddenIds, setHiddenIds] = useState<Set<string>>(() => new Set()); + + useEffect(() => { + try { + const stored = localStorage.getItem(STORAGE_KEY); + if (stored) setHiddenIds(new Set(JSON.parse(stored) as string[])); + } catch {} + }, []); + + function toggle(venueId: string) { + setHiddenIds((prev) => { + const next = new Set(prev); + if (next.has(venueId)) next.delete(venueId); + else next.add(venueId); + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify([...next])); + } catch {} + return next; + }); + } + + return { hiddenIds, toggle }; +} |
