'use client' import { useState } from 'react' import Image from 'next/image' import { cn } from '@/lib/utils' import type { TestimonialsBlock as TestimonialsBlockType, Testimonial } from '@/lib/types' type TestimonialsBlockProps = Omit & { testimonials?: Testimonial[] } export function TestimonialsBlock({ title, subtitle, displayMode, selectedTestimonials, layout = 'carousel', testimonials: externalTestimonials, }: TestimonialsBlockProps) { const items = displayMode === 'selected' ? selectedTestimonials : externalTestimonials if (!items || items.length === 0) return null return (
{/* Section Header */} {(title || subtitle) && (
{title &&

{title}

} {subtitle && (

{subtitle}

)}
)} {/* Testimonials */} {layout === 'carousel' ? ( ) : layout === 'grid' ? ( ) : ( )}
) } function CarouselLayout({ items }: { items: Testimonial[] }) { const [current, setCurrent] = useState(0) const prev = () => setCurrent((i) => (i === 0 ? items.length - 1 : i - 1)) const next = () => setCurrent((i) => (i === items.length - 1 ? 0 : i + 1)) return (
{items.map((testimonial, index) => (
))}
{/* Navigation */} {items.length > 1 && (
{items.map((_, index) => (
)}
) } function GridLayout({ items }: { items: Testimonial[] }) { return (
{items.map((testimonial) => ( ))}
) } function ListLayout({ items }: { items: Testimonial[] }) { return (
{items.map((testimonial) => ( ))}
) } interface TestimonialCardProps { testimonial: Testimonial variant?: 'default' | 'featured' | 'wide' } function TestimonialCard({ testimonial, variant = 'default' }: TestimonialCardProps) { return (
{/* Quote */}
“{testimonial.quote}”
{/* Author */}
{testimonial.authorImage?.url && ( {testimonial.authorName} )}

{testimonial.authorName}

{(testimonial.authorTitle || testimonial.authorCompany) && (

{[testimonial.authorTitle, testimonial.authorCompany] .filter(Boolean) .join(', ')}

)}
{/* Rating */} {testimonial.rating && (
{Array.from({ length: 5 }).map((_, i) => ( ))}
)}
) }