my code :
Home.tsx :
"use client";
import "@/styles/website/pages/Home.scss";
import {Award, Earth, Hotel, User} from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import {useEffect, useState} from "react";
import CookiesConsent from "@/app/componens/website/Banners/CookiesConsent";
export default function Home() {
const [showCookiesConsentBanner, setShowCookiesConsentBanner] = useState(true);
const sendEmail = () => {
fetch('/api/emails/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({})
})
.then(response => response.json())
.then(data => console.log('data mail', data))
.catch(error => console.error('error mail', error));
};
useEffect(() => {
fetch('/api/users/consent/cookies/has')
.then(response => response.json())
.then(data => setShowCookiesConsentBanner(!data.has))
.catch(error => console.error('error fetching cookies consent', error));
}, []);
const handleCookiesAccepted = () => {
setShowCookiesConsentBanner(false);
};
return (
<main className="wrapper-home">
{showCookiesConsentBanner && <CookiesConsent onAccept={handleCookiesAccepted} />}
</main>
);
}