import { useState } from 'react' import { Link, useLocation } from 'react-router' import { twMerge } from 'tailwind-merge' import { CarouselNextIcon } from '~/components/icons/carousel-next' import { CarouselPreviousIcon } from '~/components/icons/carousel-previous' import type { TNews } from '~/types/news' import { Button } from './button' export const Carousel = (properties: TNews) => { const [currentIndex, setCurrentIndex] = useState(0) const location = useLocation() const hasCategory = location.pathname.includes('/category/') const { title, description, items, type } = properties const itemsPerPage = type === 'hero' ? 1 : 3 const totalPages = Math.ceil(items.length / itemsPerPage) const nextSlide = () => { setCurrentIndex((previousIndex) => (previousIndex + 1) % totalPages) } const previousSlide = () => { setCurrentIndex( (previousIndex) => (previousIndex - 1 + totalPages) % totalPages, ) } return ( //
//
//
//

// {title} //

//

// {description} //

//
// {!hasCategory && ( //
// // //
// )} //
//
// {items.map(({ featured, title, content, tags, slug }, index) => ( //
// {title} //
//
// {tags?.map((item, index) => ( // // {item} // // ))} //
//
//

// {title} //

//

// {content} //

//
// //
//
// ))} //
// {hasCategory && ( //
//
// // //
//
// )} //

{title}

{description}

{!hasCategory && (
)}
{items .slice(currentIndex * itemsPerPage, (currentIndex + 1) * itemsPerPage) .map(({ featured, title, content, tags, slug }, index) => (
{title}
{tags?.map((item, index) => ( {item} ))}

{title}

{content}

))}
{hasCategory && (
)}
) }