/* eslint-disable @next/next/no-img-element */ import React, { useState } from 'react'; import { motion } from 'framer-motion'; import { Film, Tv, Star, Calendar, Clock, Users } from 'lucide-react'; import { useMediaQuery } from '@/hooks/use-media-query'; import { Dialog, DialogContent } from "@/components/ui/dialog"; import { Drawer, DrawerContent } from "@/components/ui/drawer"; import Image from 'next/image'; interface MediaDetails { id: number; media_type: 'movie' | 'tv'; title?: string; name?: string; overview: string; poster_path: string | null; backdrop_path: string | null; vote_average: number; vote_count: number; release_date?: string; first_air_date?: string; runtime?: number; episode_run_time?: number[]; genres: Array<{ id: number; name: string }>; credits: { cast: Array<{ id: number; name: string; character: string; profile_path: string | null; }>; }; origin_country?: string[]; original_language: string; production_companies?: Array<{ id: number; name: string; logo_path: string | null; }>; } interface TMDBResultProps { result: { result: MediaDetails | null; }; } const TMDBResult = ({ result }: TMDBResultProps) => { const [showDetails, setShowDetails] = useState(false); const isMobile = useMediaQuery("(max-width: 768px)"); if (!result.result) return null; const media = result.result; const formatDate = (dateStr: string) => { return new Date(dateStr).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); }; const formatRuntime = (minutes: number) => { const hours = Math.floor(minutes / 60); const mins = minutes % 60; return `${hours}h ${mins}m`; }; const DetailContent = () => (
{media.backdrop_path ? ( {media.title ) : (
)}

{media.title || media.name}

{media.vote_average.toFixed(1)}
{(media.release_date || media.first_air_date) && (
{formatDate(media.release_date || media.first_air_date || '')}
)} {(media.runtime || media.episode_run_time?.[0]) && (
{formatRuntime(media.runtime || media.episode_run_time?.[0] || 0)}
)}
{media.genres.map(genre => ( {genre.name} ))}

{media.overview}

{media.credits?.cast && media.credits.cast.length > 0 && (

Cast

{media.credits.cast.slice(0, media.credits.cast.length).map(person => (
{person.profile_path ? ( {person.name} ) : (
)}

{person.name}

{person.character}

))}
)}
); return (
setShowDetails(true)} >
{media.poster_path ? ( {media.title ) : (
{media.media_type === 'movie' ? ( ) : ( )}
)}

{media.title || media.name}

{media.media_type}
{media.vote_average.toFixed(1)}

{media.overview}

{media.credits?.cast && (

Cast: {media.credits.cast.slice(0, 3).map(person => person.name).join(', ')}

)}
{isMobile ? ( ) : ( )}
); }; export default TMDBResult;