'use client' import React, { useState, useRef } from 'react' import type { FDServiceChooserBlock as Props } from '@/payload-types' export const FDServiceChooserBlockComponent: React.FC = ({ heading, description, categories = [], sectionBackground = 'gray', }) => { const [activeIndex, setActiveIndex] = useState(0) const [animating, setAnimating] = useState(false) const prevIndex = useRef(0) const isDark = sectionBackground === 'navy' const bgClass = isDark ? 'bg-fd-navy' : sectionBackground === 'gray' ? 'bg-fd-surface-alt' : 'bg-white' const titleClass = isDark ? 'text-fd-yellow' : 'text-fd-navy' const bodyClass = isDark ? 'text-white' : 'text-fd-navy' const cardBg = isDark ? 'bg-white/10 border border-white/10' : 'bg-white border border-fd-navy/10' const handleTabChange = (i: number) => { if (i === activeIndex) return setAnimating(true) prevIndex.current = activeIndex setTimeout(() => { setActiveIndex(i) setAnimating(false) }, 200) } const activeCategory = (categories ?? [])[activeIndex] return (
{heading && (

{heading}

)} {description && (

{description}

)}
{(categories ?? []).map((cat, i) => ( ))}
{activeCategory?.intro && (

{activeCategory.intro}

)}
{activeCategory?.services?.map((service, i) => (

{service.title}

{service.description && (

{service.description}

)} {service.ctaText && ( )}
))}
) }