'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 & Partial
; showType?: Show['type']; showId?: Show['id']; className?: string; posterClassName?: string; onClose?: () => void; poster?: ReactNode; } const Preview: FC = ({ show: baseShow, showType, showId, className, posterClassName, onClose, poster }) => { const { data: detailedShow } = useDetails({ showId: showId || baseShow?.id, showType: showType || baseShow?.type }); if (!baseShow && !detailedShow) return null; const show: Show & Partial
= (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;