From 7c5860ce57a334b7ab4a501de78f1a7f41c8cdcc Mon Sep 17 00:00:00 2001 From: yyamashita Date: Tue, 19 May 2026 22:32:14 +0900 Subject: 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 --- app/lib/venue-filter.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/lib/venue-filter.ts (limited to 'app/lib') 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>(() => 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 }; +} -- cgit v1.2.3