import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { Banner, Button, HStack, Stack, Text } from 'soapbox/components/ui'; import { useAppSelector, 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 soapbox = useSoapboxConfig(); const isLoggedIn = useAppSelector(state => !!state.me); const siteTitle = useAppSelector(state => state.instance.title); const handleAccept = () => { localStorage.setItem('soapbox:gdpr', 'true'); setShown(true); }; const showBanner = soapbox.gdpr && !isLoggedIn && !shown; if (!showBanner) { return null; } return ( ); }; export default GdprBanner;