import { useEffect, useState } from 'react'
import cx from 'classnames'
import { useRouter } from 'next/router'
import { useMainContext } from 'components/context/MainContext'
import { Link } from 'components/Link'
import { useProductLandingContext } from 'components/context/ProductLandingContext'
import { useTranslation } from 'components/hooks/useTranslation'
import { useVersion } from 'components/hooks/useVersion'
import { Lead } from 'components/ui/Lead'
export const LandingHero = () => {
const { airGap } = useMainContext()
const { product_video, shortTitle, title, beta_product, intro, introLinks } =
useProductLandingContext()
const { t } = useTranslation('product_landing')
const [renderIFrame, setRenderIFrame] = useState(false)
// delay iFrame rendering so that dom ready happens sooner
useEffect(() => {
setRenderIFrame(true)
}, [])
return (
{shortTitle || title}{' '}
{beta_product && Beta}
{intro && {intro}}
{introLinks &&
Object.entries(introLinks)
.filter(([key, link]) => {
return link && !key.includes('raw')
})
.map(([key, link], i) => {
if (!link) {
return null
}
return (
{t(key)}
)
})}
{product_video && (
)}
)
}
// Fully Qualified Link - it includes the version and locale in the path
type Props = {
href: string
children: React.ReactNode
className?: string
}
export const FullLink = ({ href, children, className }: Props) => {
const router = useRouter()
const { currentVersion } = useVersion()
const locale = router.locale || 'en'
const fullyQualifiedHref = `/${locale}${
currentVersion !== 'free-pro-team@latest' ? `/${currentVersion}` : ''
}${href}`
return (
{children}
)
}