// src/components/VideoCarousel.js import React from 'react'; import { Swiper, SwiperSlide } from 'swiper/react'; import { Navigation, Pagination, FreeMode } from 'swiper/modules'; import 'swiper/css'; import 'swiper/css/navigation'; import 'swiper/css/pagination'; import 'swiper/css/free-mode'; const VideoCarousel = ({ videos, id, width = '100%', names = [] }) => { const [activeIndex, setActiveIndex] = React.useState(0); const getCurrentVideoName = () => { if (Array.isArray(names) && names.length > activeIndex && names[activeIndex]) { return names[activeIndex]; } return ''; }; return (
{getCurrentVideoName() && (

{getCurrentVideoName()}

)} setActiveIndex(swiper.activeIndex)} > {videos.map((video, index) => (
{video.type === 'iframe' ? ( ) : (
{(video.description || video.duration) && (
{video.description && {video.description}} {video.duration && ( • {video.duration} )}
)}
))}
); }; export default VideoCarousel;