import ProductCard from './ProductCard'; import { useRef } from 'react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { getLocalizedField } from '../utils/localization'; import { getSectionPaddingClasses } from '../utils/spacing'; interface DynamicProductCarouselProps { payload: any; } export default function DynamicProductCarousel({ payload }: DynamicProductCarouselProps) { const { i18n } = useTranslation(); const lang = i18n.language; const p = payload || {}; const { products = [] } = p; const title = getLocalizedField(p.title, lang); const description = getLocalizedField(p.description, lang); const carouselRef = useRef(null); const scrollLeft = () => carouselRef.current?.scrollBy({ left: -300, behavior: 'smooth' }); const scrollRight = () => carouselRef.current?.scrollBy({ left: 300, behavior: 'smooth' }); return (
{(title || description) && (
{title &&

{title}

} {description &&

{description}

}
)} {products.length === 0 ? (
No products to display.
) : (
{products.map((p: any) => (
))}
)}
); }