'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 { cn } from '@/lib/utils'; import Actions from './components/Actions'; interface Props { show?: Show; className?: string; onClose?: () => void; poster?: ReactNode; } const Preview: FC = ({ show: baseShow, className, onClose, poster }) => { const { data: detailedShow } = useDetails({ showId: baseShow?.id, showType: baseShow?.type }); if (!baseShow) return null; const show: (Show & Partial
) | undefined = detailedShow || baseShow; const isModal = Boolean(onClose); return (
{poster || }
{show.title}
{new Date(show.release).getFullYear()} {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;