1
0
mirror of https://github.com/XFox111/my-website.git synced 2026-04-22 07:28:01 +03:00

feat!: added cookie consent banner and management system

This commit is contained in:
2024-08-21 00:22:49 +00:00
parent dceb2e44b7
commit 67222999a9
10 changed files with 330 additions and 17 deletions
+30
View File
@@ -0,0 +1,30 @@
"use client";
import Button from "@/_components/Button";
import React, { useCallback, useEffect, useState } from "react";
import { getCookieChoice, rejectCookies } from "../_utils/analytics/client";
const RevokeConsentButton: React.FC = () =>
{
const [hasConsent, setHasConsent] = useState<boolean>(false);
useEffect(() =>
{
console.log("getCookieChoice", getCookieChoice());
setHasConsent(getCookieChoice() === "accepted");
}, []);
const revoke = useCallback(() =>
{
rejectCookies();
setHasConsent(false);
window.alert("Your consent has been revoked");
}, []);
if (!hasConsent)
return null;
return <Button onClick={ revoke }>Revoke my consent</Button>;
};
export default RevokeConsentButton;