dressed_for_succes_store/frontend old/components/CookieNotification.tsx
2025-03-11 22:42:30 +07:00

43 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client"
import { useState, useEffect } from "react"
export default function CookieNotification() {
const [isVisible, setIsVisible] = useState(false);
// Проверяем, было ли уже показано уведомление
useEffect(() => {
const cookieAccepted = localStorage.getItem('cookieAccepted');
if (!cookieAccepted) {
// Показываем уведомление с небольшой задержкой
const timer = setTimeout(() => {
setIsVisible(true);
}, 2000);
return () => clearTimeout(timer);
}
}, []);
const acceptCookies = () => {
localStorage.setItem('cookieAccepted', 'true');
setIsVisible(false);
};
if (!isVisible) return null;
return (
<div className="fixed bottom-4 right-4 bg-white p-4 shadow-lg rounded-lg max-w-sm z-50 animate-fade-in">
<h3 className="font-bold mb-2">Уведомление о Cookies</h3>
<p className="text-sm mb-4">
Наш сайт использует файлы cookie. Продолжая пользоваться сайтом, вы соглашаетесь на использование наших файлов
cookie.
</p>
<button
onClick={acceptCookies}
className="bg-black text-white px-4 py-2 rounded hover:bg-gray-800 transition-colors"
>
Хорошо, спасибо
</button>
</div>
);
}