"use client"; import { useEffect, useState } from "react"; export type Shot = { id: string; name: string; setup: string; notes: string }; // Ticks live in this device's localStorage only (static site, no server). export default function ShotList({ shots, storeKey }: { shots: Shot[]; storeKey: string }) { const [done, setDone] = useState(null); // Storage is read after mount so the static HTML matches on first paint useEffect(() => { let saved: string[] = []; try { saved = JSON.parse(localStorage.getItem(storeKey) ?? "[]"); } catch {} setDone(Array.isArray(saved) ? saved : []); // eslint-disable-line react-hooks/set-state-in-effect }, [storeKey]); useEffect(() => { if (!done) return; try { localStorage.setItem(storeKey, JSON.stringify(done)); } catch {} }, [done, storeKey]); const ticked = done ?? []; const count = shots.filter((s) => ticked.includes(s.id)).length; const toggle = (id: string) => setDone((d) => ((d ?? []).includes(id) ? (d ?? []).filter((x) => x !== id) : [...(d ?? []), id])); return (

{count} / {shots.length} shot {count === shots.length && · All done}

{count > 0 && ( )}

Ticks are saved on this device only.

); }