import { useEffect, useState } from 'react'; import { httpGet, httpPatch, httpPost } from '../../lib/http'; import { sponsorHidden } from '../../stores/page'; import { useStore } from '@nanostores/react'; import { X } from 'lucide-react'; import { setViewSponsorCookie } from '../../lib/jwt'; import { isMobile } from '../../lib/is-mobile'; import Cookies from 'js-cookie'; import { getUrlUtmParams } from '../../lib/browser.ts'; export type BottomRightSponsorType = { id: string; company: string; description: string; gaLabel: string; imageUrl: string; pageUrl: string; title: string; url: string; }; type V1GetSponsorResponse = { id?: string; href?: string; sponsor?: BottomRightSponsorType; }; type BottomRightSponsorProps = { sponsor: BottomRightSponsorType; onSponsorClick: () => void; onSponsorImpression: () => void; onSponsorHidden: () => void; }; export function BottomRightSponsor(props: BottomRightSponsorProps) { const { sponsor, onSponsorImpression, onSponsorClick, onSponsorHidden } = props; const [isHidden, setIsHidden] = useState(false); useEffect(() => { if (!sponsor) { return; } onSponsorImpression(); }, []); const { url, title, imageUrl, description, company, gaLabel } = sponsor; const isRoadmapAd = title.toLowerCase() === 'advertise with us!'; if (isHidden) { return null; } return ( { e.preventDefault(); e.stopPropagation(); setIsHidden(true); onSponsorHidden(); }} > Sponsor Banner {title} {description} {!isRoadmapAd && ( <> Partner Content Partner Content )} ); }