diff --git a/src/app/(legal)/NavigationSidebar.tsx b/src/app/(legal)/NavigationSidebar.tsx index 8e52d5f..f921239 100644 --- a/src/app/(legal)/NavigationSidebar.tsx +++ b/src/app/(legal)/NavigationSidebar.tsx @@ -38,6 +38,13 @@ export function NavSidebar() { + + +
  • + Cookies +
    +
  • + ); diff --git a/src/app/(legal)/cookies/page.tsx b/src/app/(legal)/cookies/page.tsx new file mode 100644 index 0000000..d06ba6d --- /dev/null +++ b/src/app/(legal)/cookies/page.tsx @@ -0,0 +1,104 @@ +"use client"; + +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; +import TableOfContent from "../Toc"; +import { NavSidebar } from "../NavigationSidebar"; + +const UseOfCookies = () => { + const sections = [ + { id: "introduction", title: "Introduction" }, + { id: "what-are-cookies", title: "What Are Cookies?" }, + { id: "types-of-cookies", title: "Types of Cookies We Use" }, + { id: "why-we-use-cookies", title: "Why We Use Cookies" }, + { id: "managing-cookies", title: "Managing Your Cookie Preferences" }, + { id: "third-party-cookies", title: "Third-Party Cookies" }, + { id: "changes", title: "Changes to Cookie Policy" }, + { id: "contact", title: "Contact Information" }, + ]; + + return ( +
    +
    + + +
    + +
    + + + Use of Cookies + + Last Updated: November 17, 2024 + + + +
    +

    1. Introduction

    +

    + Our Website uses cookies to improve functionality, analyze performance, and personalize your experience. + This policy explains what cookies are, how we use them, and your options for managing them. +

    + +

    2. What Are Cookies?

    +

    + Cookies are small text files stored on your device when you visit a website. They help the website + remember your preferences, improve functionality, and provide analytical insights. +

    + +

    3. Types of Cookies We Use

    +
      +
    • + Essential Cookies Required for the core functionality of the + Website, such as navigating pages and accessing secure areas. +
    • +
    • + Analytics Cookies + Collect data on user behavior to improve Website performance and user experience. +
    • +
    • + Personalization Cookies Tailor content and features to match your + preferences. +
    • +
    + +

    4. Why We Use Cookies

    + + We use cookies to: +
      +
    • Ensure the Website functions properly.
    • +
    • Understand and analyze user behavior.
    • +
    • Provide a personalized browsing experience.
    • +
    • Deliver relevant advertisements and content.
    • +
    +
    + +

    5. Managing Your Cookie Preferences

    +

    + You can manage or disable cookies through your browser settings. Note that disabling cookies may affect + your experience on our Website. For detailed instructions, refer to your browser's help section. +

    + +

    6. Third-Party Cookies

    +

    + Some cookies are set by third-party services we use, such as analytics or advertising platforms. These + cookies are subject to the policies of the respective third parties. +

    + +

    7. Changes to Cookie Policy

    +

    + We may update this cookie policy periodically to reflect changes in technology or legal requirements. + Any updates will be posted on this page with the updated date. +

    + +

    8. Contact Information

    +

    For questions about this policy or to exercise your rights, contact us at privacy@b2dventure.com.

    +
    +
    + +
    +
    +
    + ); +}; + +export default UseOfCookies; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 56b810c..73e03e5 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -9,6 +9,8 @@ import { NavigationBar } from "@/components/navigationBar/nav"; import { Toaster } from "react-hot-toast"; import { SiteFooter } from "@/components/siteFooter"; +import CookieConsent from "@/components/CookieConsent"; + const montserrat = Montserrat({ subsets: ["latin"], display: "swap", @@ -44,6 +46,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
    {children}
    + diff --git a/src/components/CookieConsent.tsx b/src/components/CookieConsent.tsx new file mode 100644 index 0000000..0262749 --- /dev/null +++ b/src/components/CookieConsent.tsx @@ -0,0 +1,158 @@ +"use client"; + +import { CookieIcon } from "lucide-react"; +import { Button } from "./ui/button"; +import { useEffect, useState } from "react"; +import { cn } from "@/lib/utils"; +import Link from "next/link"; +import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; +import useSession from "@/lib/supabase/useSession"; + +export default function CookieConsent({ + variant = "default", + demo = false, + onAcceptCallback = () => {}, + onDeclineCallback = () => {}, +}) { + const [isOpen, setIsOpen] = useState(false); + const [hide, setHide] = useState(false); + const supabase = createSupabaseClient(); + + const { session, loading } = useSession(); + + const userId = session?.user?.id; + + const updateConsent = async (consent: boolean) => { + try { + if (!userId) { + return; + } + + const { error } = await supabase.from("profiles").update({ consent }).eq("id", userId); + + if (error) { + console.error("Failed to update consent:", error.message); + } + } catch (e) { + console.error("Unexpected error updating consent:", e); + } + }; + + const accept = () => { + setIsOpen(false); + document.cookie = "cookieConsent=true; expires=Fri, 31 Dec 9999 23:59:59 GMT"; + setTimeout(() => { + setHide(true); + }, 700); + onAcceptCallback(); + updateConsent(true); + }; + + const decline = () => { + setIsOpen(false); + setTimeout(() => { + setHide(true); + }, 700); + onDeclineCallback(); + updateConsent(false); + }; + + useEffect(() => { + try { + setIsOpen(true); + if (document.cookie.includes("cookieConsent=true")) { + if (!demo) { + setIsOpen(false); + setTimeout(() => { + setHide(true); + }, 700); + } + } + } catch (e) { + // console.log("Error: ", e); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + if (loading) { + return null; + } + + return variant == "default" ? ( +
    +
    +
    +
    +

    We use cookies

    + +
    +
    +

    + We use cookies to ensure you get the best experience on our website. For more information on how we use + cookies, please see our cookie policy. +
    +
    + + By clicking "Accept", you agree to our use of + cookies. + +
    + + Learn more. + +

    +
    +
    + + +
    +
    +
    +
    + ) : ( + variant == "small" && ( +
    +
    +
    +

    We use cookies

    + +
    +
    +

    + We use cookies to ensure you get the best experience on our website. For more information on how we use + cookies, please see our cookie policy. +

    +
    +
    + + +
    +
    +
    + ) + ); +}