import React from 'react' import type { FDTestimonialBlock as FDTestimonialBlockProps, Media } from '@/payload-types' import { FDImage } from '@/components/FDImage' const bgMap: Record = { gray: { section: 'bg-[#e5e5e5]', card: 'bg-white', quote: 'text-fd-navy', meta: 'text-fd-navy/60', name: 'text-fd-navy', company: 'text-fd-navy/50' }, white: { section: 'bg-white', card: 'bg-[#e5e5e5]', quote: 'text-fd-navy', meta: 'text-fd-navy/60', name: 'text-fd-navy', company: 'text-fd-navy/50' }, navy: { section: 'bg-fd-navy', card: 'bg-white/10', quote: 'text-white', meta: 'text-white/60', name: 'text-white', company: 'text-white/50' }, } export const FDTestimonialBlockComponent: React.FC = ({ heading, testimonials, layout = 'grid', sectionBackground = 'gray', }) => { const theme = bgMap[sectionBackground] || bgMap.gray const isFeatured = layout === 'featured' return (
{heading && (

{heading}

)} {isFeatured && testimonials && testimonials.length > 0 ? ( // ── Featured layout: first testimonial large, rest below ──────
{/* First testimonial — large */} {(() => { const t = testimonials[0] const avatar = t.avatar as Media | undefined return (

“{t.quote}”

{avatar?.url && (
)}

{t.authorName}

{t.authorRole}{t.authorRole && t.authorCompany ? ' · ' : ''}{t.authorCompany}

) })()} {/* Remaining testimonials — smaller grid */} {testimonials.length > 1 && (
{testimonials.slice(1).map((t, i) => { const avatar = t.avatar as Media | undefined return (

“{t.quote}”

{avatar?.url && (
)}

{t.authorName}

{t.authorRole}{t.authorRole && t.authorCompany ? ' · ' : ''}{t.authorCompany}

) })}
)}
) : ( // ── Grid layout ───────────────────────────────────────────────
{testimonials?.map((t, i) => { const avatar = t.avatar as Media | undefined return (
{/* Quote mark */}

{t.quote}

{avatar?.url && (
)}

{t.authorName}

{t.authorRole}{t.authorRole && t.authorCompany ? ' · ' : ''}{t.authorCompany}

) })}
)}
) }