import CourseCard1 from '@/components/cards/course-card-1'; import { Button } from '@/components/ui/button'; import { Carousel, type CarouselApi, CarouselContent, CarouselItem } from '@/components/ui/carousel'; import { getPageSection } from '@/lib/page'; import { cn } from '@/lib/utils'; import { IntroPageProps } from '@/types/page'; import { usePage } from '@inertiajs/react'; import Autoplay from 'embla-carousel-autoplay'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useEffect, useState } from 'react'; import Section from '../section'; const TopCourses = () => { const { props } = usePage(); const { page, topCourses, customize } = props; const [api, setApi] = useState(); const [currentSlide, setCurrentSlide] = useState(0); const topCoursesSection = getPageSection(page, 'top_courses'); useEffect(() => { if (!api) { return; } const handleSelect = () => { setCurrentSlide(api.selectedScrollSnap()); }; api.on('select', handleSelect); return () => { api.off('select', handleSelect); }; }, [api]); return (

{topCoursesSection?.title}

{topCoursesSection?.sub_title}

{topCoursesSection?.description}

{topCourses.map((course) => (
))}
{api && topCourses.map(({ id }, index) => (
api.scrollTo(index)} >
))}
); }; export default TopCourses;