import clsx from 'clsx'; import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { Banner, Button, HStack, Stack, Text } from 'soapbox/components/ui'; import { useAppSelector, useInstance, useSoapboxConfig } from 'soapbox/hooks'; const acceptedGdpr = !!localStorage.getItem('soapbox:gdpr'); /** Displays a cookie consent banner. */ const GdprBanner: React.FC = () => { /** Track whether the banner has already been displayed once. */ const [shown, setShown] = useState(acceptedGdpr); const [slideout, setSlideout] = useState(false); const instance = useInstance(); const soapbox = useSoapboxConfig(); const isLoggedIn = useAppSelector(state => !!state.me); const handleAccept = () => { localStorage.setItem('soapbox:gdpr', 'true'); setSlideout(true); setTimeout(() => setShown(true), 200); }; const showBanner = soapbox.gdpr && !isLoggedIn && !shown; if (!showBanner) { return null; } return (
{soapbox.gdprUrl && ( )}
); }; export default GdprBanner;