import { useNavigate } from 'react-router-dom';
import { ArrowLeft, ChevronDown, Play, ChevronUp } from 'lucide-react';
import { useWatchMovie } from '../../hooks/useWatchMovie';
import { useState } from 'react';
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
Loading...
;
const episodes = movie.episodes || [];
return (
{/* Navigation */}
{/* Player Section - Sticky on larger screens for cinema feel */}
{loading && (
)}
{(() => {
const activeEpisode = movie.episodes?.find(e => e.number === currentEpisode);
if (!activeEpisode?.url) {
return (
Processing Content
This title is currently being prepared for streaming.
{/* Subtle Background */}
);
}
return (
);
})()}
{/* Content Section - Scrolls over the bottom of the player if sticky, or just below */}
{/* Movie Info */}
{movie.title}
HD
{movie.year || '2024'}
{movie.episodes?.length || 0} Episodes
{movie.description}
{/* Episodes Grid */}
Episodes
{episodes.length} available
{(expanded ? episodes : episodes.slice(0, 20)).map((ep) => (
))}
{episodes.length > 20 && (
)}
{/* Related Categories */}
More Like This
Trending Now
Top Movies
Animation
);
};