"use client"; import { useEffect } from "react"; import { useTranslations } from "next-intl"; import Button from "@/shared/components/Button"; export interface RiskNoticeModalProps { open: boolean; title: string; body: string; dontShowAgainKey: string; onAccept: () => void; onCancel: () => void; } /** * Generic risk notice modal (D16). * Persists "don't show again" preference to localStorage using `dontShowAgainKey`. */ export function RiskNoticeModal({ open, title, body, dontShowAgainKey, onAccept, onCancel, }: RiskNoticeModalProps) { const t = useTranslations("common"); useEffect(() => { if (!open) return; const handler = (e: KeyboardEvent) => { if (e.key === "Escape") onCancel(); }; document.addEventListener("keydown", handler); return () => document.removeEventListener("keydown", handler); }, [open, onCancel]); if (!open) return null; const handleAccept = () => { try { localStorage.setItem(dontShowAgainKey, "true"); } catch { // ignore storage errors } onAccept(); }; return (
{body}