Movies get a theatre/stream/blu-ray icon in the info row, series get the latest aired episode as S03 E07. Both reveal the relevant dates on hover or tap through a shared Hint tooltip. Release dates ride along on the details request via append_to_response and the series fields are already in the tv payload, so neither indicator costs an extra call. Theatre state is only claimed while the run can still be current, otherwise a classic with no digital entry would read as in cinemas. The credits carousel now opens with the director, read from the crew array that the credits response already carries. A series has no single director, so the one behind most episodes stands in. Drop with_cast from the starring query: TMDB ANDs it with with_people, so every director link would have resolved to an empty list. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
'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';
|
|
import Airing from './components/Airing';
|
|
import Availability from './components/Availability';
|
|
|
|
interface Props {
|
|
show?: Show & Partial<Details>;
|
|
showType?: Show['type'];
|
|
showId?: Show['id'];
|
|
className?: string;
|
|
posterClassName?: string;
|
|
onClose?: () => void;
|
|
poster?: ReactNode;
|
|
externalLink?: boolean;
|
|
}
|
|
|
|
const Preview: FC<Props> = ({
|
|
show: baseShow,
|
|
showType,
|
|
showId,
|
|
className,
|
|
posterClassName,
|
|
onClose,
|
|
poster,
|
|
externalLink = true
|
|
}) => {
|
|
const { data: detailedShow } = useDetails({ showId: showId || baseShow?.id, showType: showType || baseShow?.type });
|
|
|
|
if (!baseShow && !detailedShow) return null;
|
|
|
|
const show: Show & Partial<Details> = (detailedShow || baseShow)!;
|
|
|
|
const isModal = Boolean(onClose);
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'flex flex-col md:flex-row gap-2 rounded-xl overflow-hidden',
|
|
{ 'gap-0 md:p-0 p-2': isModal },
|
|
className
|
|
)}
|
|
>
|
|
{poster || <Poster className={cn('mx-auto md:rounded-none md:rounded-l-xl', posterClassName)} show={show} />}
|
|
<div className={cn('flex grow flex-col bg-background', { 'p-0 pt-2 md:p-2': isModal })}>
|
|
<span className='order-3 mb-4 text-3xl md:order-1 md:line-clamp-2'>{show.title}</span>
|
|
|
|
<div className='order-3 mb-4 flex w-full flex-wrap items-center gap-5 whitespace-nowrap text-sm md:order-2'>
|
|
<span>{new Date(show.release).getFullYear()}</span>
|
|
{Boolean(show.availability) && (
|
|
<Availability availability={show.availability!} className='animate-fade-aside-slide-in opacity-0' />
|
|
)}
|
|
{Boolean(show.airing) && <Airing airing={show.airing!} className='animate-fade-aside-slide-in opacity-0' />}
|
|
{Boolean(show.runtime) && (
|
|
<span className='animate-fade-aside-slide-in opacity-0'>{show.runtime} minutes</span>
|
|
)}
|
|
{Boolean(show.genres) && (
|
|
<span className='animate-fade-aside-slide-in opacity-0'>
|
|
{show.genres
|
|
?.slice(0, 3)
|
|
.map(({ name }) => name)
|
|
.join(' | ')}
|
|
</span>
|
|
)}
|
|
</div>
|
|
|
|
<Actions externalLink={externalLink} className='order-1 mb-4 md:order-2' show={show} />
|
|
|
|
<p key={show.id} className='order-4 md:order-4 md:line-clamp-3' title={show.overview}>
|
|
{show.overview}
|
|
</p>
|
|
<div className='order-5 mt-5 grid grid-cols-1 rounded-lg md:order-5 md:mt-auto'>
|
|
<Credits showType={show.type} showId={show.id} onClick={onClose} />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const showPreviewModal = create(({ onResolve, onClose, show }: Props & InstanceProps<void>) => (
|
|
<Modal className='block bg-background p-0 md:bg-black' onClose={onResolve}>
|
|
<Preview
|
|
show={show}
|
|
onClose={() => {
|
|
onClose?.();
|
|
onResolve();
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
}}
|
|
/>
|
|
</Modal>
|
|
));
|
|
|
|
export default Preview;
|