31 lines
836 B
TypeScript
31 lines
836 B
TypeScript
'use client';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
export default function CookieBanner() {
|
|
const [showBanner, setShowBanner] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const cookieConsent = localStorage.getItem('cookieConsent');
|
|
if (!cookieConsent) {
|
|
setShowBanner(true);
|
|
}
|
|
}, []);
|
|
|
|
const handleAccept = () => {
|
|
localStorage.setItem('cookieConsent', 'true');
|
|
setShowBanner(false);
|
|
};
|
|
|
|
if (!showBanner) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className="fixed bottom-0 inset-x-0 bg-gray-800 text-white p-4 flex flex-col items-center z-50">
|
|
<p className="text-center max-w-prose mx-auto">Wir verwenden Cookies, um Ihre Erfahrung zu verbessern.</p>
|
|
<button onClick={handleAccept} className="bg-white text-black px-4 py-2 rounded-full mt-2">Akzeptieren</button>
|
|
</div>
|
|
);
|
|
}
|