39 lines
984 B
TypeScript
39 lines
984 B
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import Link from "next/link";
|
|
import { useI18n } from "@/lib/i18n";
|
|
|
|
export default function CookieConsent() {
|
|
const { t } = useI18n();
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
useEffect(() => {
|
|
if (!localStorage.getItem("nomad-cookie-consent")) {
|
|
const timer = setTimeout(() => setVisible(true), 2000);
|
|
return () => clearTimeout(timer);
|
|
}
|
|
}, []);
|
|
|
|
const accept = () => {
|
|
localStorage.setItem("nomad-cookie-consent", "1");
|
|
setVisible(false);
|
|
};
|
|
|
|
if (!visible) return null;
|
|
|
|
return (
|
|
<div className="cookie-consent" role="dialog" aria-live="polite">
|
|
<p>
|
|
{t.cookies.body}{" "}
|
|
<Link href="/privacy">{t.cookies.privacy}</Link>
|
|
{" · "}
|
|
<Link href="/cookies">{t.cookies.cookies}</Link>
|
|
</p>
|
|
<button type="button" className="btn btn-primary btn-sm" onClick={accept}>
|
|
{t.cookies.ok}
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|