import React, { useState } from 'react'; import { MapPin, Mail, Phone, Clock, ChevronDown } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import KontaktForm from '@/spa/components/forms/KontaktForm'; import { useIsMobile } from '@/spa/hooks/useIsMobile'; import { mediaAlt, mediaUrl } from '@/spa/cmsMediaField'; import { useCmsRoute } from '@/spa/cmsRoute'; import Image from '@/spa/components/ui/UnoptimizedImage' import type { Page } from '@/payload-types'; import { contactContent } from '@/spa/contactContent'; const NAVY = '#111D55'; const GOLD = '#EFBF04'; const WHITE = '#fff'; const INK = '#3A3A3A'; type ContactCms = NonNullable; type ContactItem = NonNullable['items']>[number] | { icon: string; title: string; lines: string | string[]; }; type DeadlineItem = NonNullable['items']>[number]; type FaqItem = NonNullable['items']>[number]; const fallbackText = (value: unknown, fallback: string) => typeof value === 'string' && value.length > 0 ? value : fallback; const fallbackArray = (value: unknown, fallback: T[]) => Array.isArray(value) && value.length > 0 ? (value as T[]) : fallback; function Lines({ text }: { text: string }) { return <>{text.split('\n').map((line, i) => {i > 0 &&
}{line}
)}; } const ICONS = { mapPin: MapPin, mail: Mail, phone: Phone, clock: Clock, }; const Contact: React.FC = () => { const [openFaq, setOpenFaq] = useState(0); const isMobile = useIsMobile(); const contact = (useCmsRoute()?.doc?.contact || {}) as ContactCms; const hero = contact.hero || {}; const info = contact.info || {}; const deadlines = contact.deadlines || {}; const faq = contact.faq || {}; const contactItems = fallbackArray(info.items, contactContent.info.items); const deadlineItems = fallbackArray(deadlines.items, contactContent.deadlines.items); const faqItems = fallbackArray(faq.items, contactContent.faq.items); return (
{/* ── Hero ───────────────────────────────────────────────────────── */}
{mediaAlt(hero.backgroundImage, {/* Diagonal overlay */}
{/* Bottom fade to navy contact section */}

{fallbackText(hero.eyebrow, contactContent.hero.eyebrow)}

{fallbackText(hero.description, contactContent.hero.description)}

{/* ── Contact + Form ─────────────────────────────────────────────── */}
{/* Decorative circles */}
{/* Left – info panel */}

{fallbackText(info.eyebrow, contactContent.info.eyebrow)}

{contactItems.map(({ icon, title, lines }, i) => { const Icon = ICONS[icon as keyof typeof ICONS] || MapPin; const normalizedLines = typeof lines === 'string' ? lines.split('\n').filter(Boolean) : fallbackArray<{ line?: string | null } | string>(lines, []) .map((line) => typeof line === 'string' ? line : line.line) .filter((line): line is string => Boolean(line)); return (
{fallbackText(title, '')}
{normalizedLines.map((l: string, j: number) =>
{l}
)}
); })}

{fallbackText(info.nextAwardLabel, contactContent.info.nextAwardLabel)} {fallbackText(info.nextAwardDate, contactContent.info.nextAwardDate)}

{/* Divider */} {!isMobile &&
} {/* Right – gold form panel */}
{!isMobile && (
{mediaAlt(info.formImage,
{fallbackText(info.formImageLabel, contactContent.info.formImageLabel)}
)}
{fallbackText(info.formEyebrow, contactContent.info.formEyebrow)}

{fallbackText(info.formTitle, contactContent.info.formTitle)}

{/* ── Deadlines ──────────────────────────────────────────────────── */}
{fallbackText(deadlines.watermark, contactContent.deadlines.watermark)}
{fallbackText(deadlines.eyebrow, contactContent.deadlines.eyebrow)}
{deadlineItems.map((item, i) => (
0 ? 36 : 0, paddingBottom: i < deadlineItems.length - 1 ? 36 : 0, borderBottom: i < deadlineItems.length - 1 ? '1px solid rgba(255,255,255,0.10)' : 'none', } : { paddingRight: i < deadlineItems.length - 1 ? 48 : 0, paddingLeft: i > 0 ? 48 : 0, borderRight: i < deadlineItems.length - 1 ? '1px solid rgba(255,255,255,0.10)' : 'none', }}>
{fallbackText(item.step, '')}
{fallbackText(item.label, '')}
{fallbackText(item.date, '')}
{fallbackText(item.desc, '')}
))}
{/* ── FAQ ────────────────────────────────────────────────────────── */}
{/* Left – sticky label */}

{fallbackText(faq.eyebrow, contactContent.faq.eyebrow)}

{/* Right – accordion */}
{faqItems.map((faq, idx) => { const isOpen = openFaq === idx; return (
{isOpen && (
{fallbackText(faq.a, '')}
)}
); })}
); }; export default Contact;