import { useEffect, useRef, useState } from 'react'; import { ChevronLeft, ChevronRight, Play, Star, Calendar, Clock } from 'lucide-react'; export default function MovieSlider({ movies = [] }) { const containerRef = useRef(null); const [canScrollLeft, setCanScrollLeft] = useState(false); const [canScrollRight, setCanScrollRight] = useState(true); const checkScroll = () => { const el = containerRef.current; if (!el) return; setCanScrollLeft(el.scrollLeft > 0); setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 10); }; useEffect(() => { checkScroll(); const el = containerRef.current; if (el) { el.addEventListener('scroll', checkScroll); window.addEventListener('resize', checkScroll); return () => { el.removeEventListener('scroll', checkScroll); window.removeEventListener('resize', checkScroll); }; } }, [movies]); const scroll = (dir) => { const el = containerRef.current; if (!el) return; el.scrollBy({ left: dir * el.clientWidth * 0.8, behavior: 'smooth' }); }; if (!movies?.length) return null; return (