import React, { ReactElement, useState } from 'react' import { useConsent, CookieConsentStatus } from '@context/CookieConsent' import styles from './PrivacyPreferenceCenter.module.css' import { useGdprMetadata } from '@hooks/useGdprMetadata' import Markdown from '@shared/atoms/Markdown' import CookieModule from './CookieModule' import Button from '@shared/atoms/Button' import { useUserPreferences } from '@context/UserPreferences' import classNames from 'classnames/bind' const cx = classNames.bind(styles) export default function CookieBanner({ style }: { style?: 'small' | 'default' }): ReactElement { const { resetConsentStatus } = useConsent() const cookies = useGdprMetadata() const { showPPC, setShowPPC } = useUserPreferences() const [smallBanner, setSmallBanner] = useState(style === 'small') function closeBanner() { setShowPPC(false) // Wait for CSS animations to finish setTimeout(() => { setSmallBanner(style === 'small') }, 300) } function handleAllCookies(accepted: boolean) { resetConsentStatus( accepted ? CookieConsentStatus.APPROVED : CookieConsentStatus.REJECTED ) closeBanner() } const styleClasses = cx(styles.wrapper, { hidden: !showPPC, small: smallBanner // style === 'small' }) return (
{cookies.optionalCookies && ( <>
{cookies.optionalCookies.map((cookie) => { return })}
)}
{(!smallBanner || !cookies.optionalCookies) && ( )}
) }