"use client"; import { useEffect, useState } from "react"; import { useSession } from "@/lib/store"; import { Sheet, Button } from "@/components/ui"; import { Clock } from "lucide-react"; /** Responsible-play reminder: "You've been playing for N minutes. Take a break anytime." */ export function SessionReminder() { const settings = useSession((s) => s.settings); const status = useSession((s) => s.status); const startedAt = useSession((s) => s.sessionStartedAt); const [shownFor, setShownFor] = useState(null); const [open, setOpen] = useState(false); const interval = settings?.sessionReminderMinutes ?? 0; useEffect(() => { if (status !== "authenticated" || !interval) return; const t = setInterval(() => { const minutes = Math.floor((Date.now() - startedAt) / 60_000); const step = Math.floor(minutes / interval) * interval; if (step > 0 && step !== shownFor) { setShownFor(step); setOpen(true); } }, 15_000); return () => clearInterval(t); }, [status, interval, startedAt, shownFor]); return ( setOpen(false)} side="center" title="Time check">

You've been playing for {shownFor} minutes.

Take a break anytime. Spinza credits are fictional and your progress is always saved.

); }