'use client'; import { FC, ReactNode } from 'react'; import { create, InstanceProps } from 'react-modal-promise'; import Poster from '@/components/Poster'; import Credits from '@/components/Preview/components/Credits'; import useDetails from '@/components/Preview/useDetails'; import { Modal } from '@/components/ui/dialog'; import analytics from '@/lib/analytics'; import useTrackOnce from '@/lib/analytics/useTrackOnce'; import { cn } from '@/lib/utils'; import Actions from './components/Actions'; import Airing from './components/Airing'; import YearHint from './components/YearHint'; interface Props { show?: Show & Partial
; showType?: Show['type']; showId?: Show['id']; className?: string; posterClassName?: string; onClose?: () => void; poster?: ReactNode; externalLink?: boolean; heading?: boolean; } const Preview: FC = ({ show: baseShow, showType, showId, className, posterClassName, onClose, poster, externalLink = true, heading = false }) => { const { data: detailedShow } = useDetails({ showId: showId || baseShow?.id, showType: showType || baseShow?.type }); const show = (detailedShow || baseShow) as (Show & Partial
) | undefined; const isModal = Boolean(onClose); useTrackOnce(analytics.showViewed, show?.id, () => ({ showId: show!.id, showType: show!.type, showTitle: show!.title, surface: isModal ? ('modal' as const) : ('page' as const) })); if (!show) return null; const Title = heading ? 'h1' : 'span'; return (
{poster || }
{show.title}
{Boolean(show.availability) ? : {new Date(show.release).getFullYear()}} {Boolean(show.airing) && } {Boolean(show.runtime) && ( {show.runtime} minutes )} {Boolean(show.genres) && ( {show.genres ?.slice(0, 3) .map(({ name }) => name) .join(' | ')} )}

{show.overview}

); }; export const showPreviewModal = create(({ onResolve, onClose, show }: Props & InstanceProps) => ( { onClose?.(); onResolve(); window.scrollTo({ top: 0, behavior: 'smooth' }); }} /> )); export default Preview;