import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { ArrowLeft, ChevronDown, ChevronUp } from 'lucide-react';
import { useWatchMovie } from '../../hooks/useWatchMovie';
import MovieRow from '../../components/MovieRow';
export const WatchPage = ({ slug, episode }: { slug: string, episode: string }) => {
const navigate = useNavigate();
const { movie, loading, currentEpisode, setCurrentEpisode, videoRef } = useWatchMovie(slug, episode);
const [expanded, setExpanded] = useState(false);
if (!movie) return (
);
// Helper for URL safety (same as Hero)
const getImageUrl = (url: string | undefined, width: number) => {
if (!url) return '';
const cleanUrl = url.replace('img.ophim1.com', 'ssl:img.ophim1.com');
return `https://wsrv.nl/?url=${encodeURIComponent(cleanUrl)}&w=${width}&output=webp`;
};
const episodes = movie.episodes || [];
const visibleEpisodes = expanded ? episodes : episodes.slice(0, 20);
return (
{/* Back Navigation */}
{/* 1. Cinema Player Section */}
{loading && (
)}
{(() => {
const activeEpisode = movie.episodes?.find(e => e.number === currentEpisode);
if (!activeEpisode?.url) {
return (
Coming Soon
We're busy uploading the best quality version of this movie.
);
}
return (
);
})()}
{/* 2. Content Info & Rows */}
{/* 2. Content Info & Rows */}
{/* Glass Info Card */}
{movie.title}
{/* Meta Tags */}
{movie.quality || 'HD'}
{movie.year || '2024'}
98% Match
{movie.original_title}
{/* Episodes Section - Compact Grid */}
{episodes.length > 0 && (
Episodes
{episodes.length} Items
{visibleEpisodes.map((ep) => (
))}
{episodes.length > 20 && (
)}
)}
{/* Related Content Section */}
);
};