import { FC } from 'react'; import { AnimatePresence, motion } from 'framer-motion'; import { Play } from 'lucide-react'; import { useRouter } from 'next/navigation'; import useTrailer from '@/app/(site)/useTrailer'; import Credits from '@/components/Movie/components/Credits'; import { showTrailerModal } from '@/components/Movie/components/Trailer'; import { Separator } from '@/components/ui/separator'; import { Button } from '../ui/button'; import { showTorrentsModal } from './components/Torrents'; import Card from './Card'; interface Props { movie?: Movie; className?: string; direction?: number; onClose?: () => void; } const variants = { enter: (direction: number) => ({ scale: 0.8, opacity: 0, [direction === 0 ? 'y' : 'x']: direction === 0 ? -100 : direction * -320 }), center: { x: 0, opacity: 1, y: 0, scale: 1 }, exit: (direction: number) => ({ scale: 0.8, opacity: 1, x: direction * 320 }) }; const Preview: FC = ({ movie, className, onClose, direction }) => { const { data: trailer } = useTrailer({ movieId: movie?.id }); const router = useRouter(); if (!movie) return null; return (
{trailer && ( showTrailerModal({ trailerKey: trailer?.key })} title='Play trailer' className='absolute w-full h-full left-0 top-0 bg-black cursor-pointer overflow-hidden rounded-lg transition-opacity opacity-0 hover:opacity-70 flex items-center justify-center' > )}
{movie.overview}
onClose?.()} />
); }; export default Preview;