import React from 'react' import type { FDTestimonialBlock as FDTestimonialBlockProps, Media } from '@/payload-types' import { FDImage } from '@/components/FDImage' const bgMap: Record = { gray: { section: 'bg-fd-gray-light dark:bg-fd-navy', card: 'bg-white dark:bg-white/10', quote: 'text-fd-navy dark:text-white', meta: 'text-fd-navy/60 dark:text-white/60', name: 'text-fd-navy dark:text-white', accent: 'text-fd-navy dark:text-fd-yellow', }, white: { section: 'bg-white dark:bg-fd-navy', card: 'bg-fd-gray-light dark:bg-white/10', quote: 'text-fd-navy dark:text-white', meta: 'text-fd-navy/60 dark:text-white/60', name: 'text-fd-navy dark:text-white', accent: 'text-fd-navy dark:text-fd-yellow', }, navy: { section: 'bg-fd-navy', card: 'bg-white/10', quote: 'text-white', meta: 'text-white/60', name: 'text-white', accent: 'text-fd-yellow', }, } const cardRadius = 'rounded-[32px] md:rounded-[50px] lg:rounded-[70px]' const Avatar: React.FC<{ media: Media | undefined; name: string; size: number }> = ({ media, name, size }) => { if (!media?.url) return null return (
) } export const FDTestimonialBlockComponent: React.FC = ({ heading, testimonials, layout = 'grid', sectionBackground = 'gray', anchorId, }) => { const theme = bgMap[sectionBackground ?? 'gray'] || bgMap.gray const isFeatured = layout === 'featured' return (
{heading && (

{heading}

)} {isFeatured && testimonials && testimonials.length > 0 ? (
{/* First testimonial — large */} {(() => { const t = testimonials[0] const avatar = t.avatar as Media | undefined return (

“{t.quote}”

{t.authorName}

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

) })()} {testimonials.length > 1 && (
{testimonials.slice(1).map((t, i) => { const avatar = t.avatar as Media | undefined return (

“{t.quote}”

{t.authorName}

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

) })}
)}
) : (
{testimonials?.map((t, i) => { const avatar = t.avatar as Media | undefined return (

{t.quote}

{t.authorName}

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

) })}
)}
) }