import React, { useEffect, useState } from 'react' import useGlobalConfig from '../Contexts/useGlobalConfig' import styles from './PhotoBanner.module.scss' import ActivateButton from '../Buttons/ActivateButton' import DismissBannerButton, { isBannerAlreadyDismissed } from '../Buttons/DismissBanner' import ExternalLinkButton from '../Buttons/ExternalLinkButton' import MainHeading from '../Titles/MainHeading' import ButtonWrapper from '../Buttons/ButtonWrapper' const PhotoBanner = () => { const bannerId = 'photoBanner' const { subscriptionStatus } = useGlobalConfig() // Figure out if banner is already dismissed const alreadyDismissed = isBannerAlreadyDismissed(bannerId) // Determines what type of mode we're in, we don't want this banner to display in the embed photo mode. const isPhotoEmbedView = typeof window !== 'undefined' && typeof window.envatoElements !== 'undefined' && typeof window.envatoElements.photoImportCompleteCallback !== 'undefined' // Figure out if we should show the banner or not const shouldWeShowTheBanner = !alreadyDismissed && !isPhotoEmbedView && subscriptionStatus !== 'paid' // Use local state here to decide if banner should display or not const [showBanner, setShowBanner] = useState(shouldWeShowTheBanner) useEffect(() => { // If our subscription status is updated from elsewhere, we need to close this modal. if (subscriptionStatus === 'paid') { setShowBanner(false) } }, [subscriptionStatus]) if (!showBanner) { // If our banner is dismissed we return nothing for this banner return null } return (