import React, {useEffect, useState} from "react"; import CookieConsent from "react-cookie-consent"; import Link from "next/link"; const CookieConsentBanner = ({onConsentChange}: { onConsentChange: (consent: string) => void }) => { const [isVisible, setIsVisible] = useState(false); const [isFadingIn, setIsFadingIn] = useState(false); useEffect(() => { const consent = localStorage.getItem("CookieConsent"); if (!consent) { setIsVisible(true); setTimeout(() => setIsFadingIn(true), 10); // Delay to trigger CSS transition } }, []); const handleAccept = () => { setIsFadingIn(false); setTimeout(() => { localStorage.setItem("CookieConsent", "accepted"); setIsVisible(false); onConsentChange("accepted"); }, 500); // Match the duration of the fade-out transition }; const handleDecline = () => { setIsFadingIn(false); setTimeout(() => { localStorage.setItem("CookieConsent", "declined"); setIsVisible(false); onConsentChange("declined"); }, 500); // Match the duration of the fade-out transition }; if (!isVisible) { return null; } return (
This website uses cookies to enhance your experience. By using our website, you consent to the use of cookies. You can read more in our privacy policy.
); }; export default CookieConsentBanner;