import React, { useState } from 'react' import { ChevronRight } from 'lucide-react' import AwardsGridSection, { type AwardsGridContent } from '@/spa/components/AwardsGridSection' import HomeWinnersSection, { type HomeWinnersContent } from '@/spa/components/HomeWinnersSection' import TestimonialsSection from '@/spa/components/TestimonialsSection' import MunichSkylineBg from '@/spa/components/ui/munich-skyline-bg' import Image from '@/spa/components/ui/UnoptimizedImage' import { mediaAlt, mediaUrl } from '@/spa/cmsMediaField' import { useCmsCollection, useCmsRoute, type CmsRouteDoc } from '@/spa/cmsRoute' import { useIsMobile } from '@/spa/hooks/useIsMobile' import { Link } from '@/spa/router' import { aboutContent } from '@/spa/aboutContent' const FF = '"IBM Plex Sans", sans-serif' const FB = '"Inter", sans-serif' const NAVY = '#111D55' const GOLD = '#EFBF04' const WHITE = '#fff' const HIDE_MEMBERSHIP_ABOUT_CTA = true type AboutCms = Partial & { hero?: Partial & { backgroundImage?: unknown } prize?: Partial & { image?: unknown } mittelstand?: Partial & { image?: unknown } } type TextRow = { text?: string | null } 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 ? (value as T[]) : fallback) const isMembershipCta = (cta?: { label?: string | null; url?: string | null } | null) => { const normalizedLabel = cta?.label?.trim().toLowerCase() return cta?.url === '/mitglied-werden' || normalizedLabel === 'mitglied werden' || normalizedLabel === 'vereinsmitglied werden' } function Lines({ text }: { text: string }) { return ( <> {text.split('\n').map((line, i) => ( {i > 0 &&
} {line}
))} ) } const paragraphs = (value: unknown, fallback: string[]) => Array.isArray(value) && value.length ? (value as Array).map((item) => (typeof item === 'string' ? item : fallbackText(item.text, ''))).filter(Boolean) : fallback const isParticipationPage = (page: CmsRouteDoc) => { const title = String(page.title || '').toLowerCase() return page.spaPath === '/teilnahme' || page.slug === 'teilnahme' || page.slug === 'participation' || title === 'teilnahme' || title === 'participation' } const isHomePage = (page: CmsRouteDoc) => { const title = String(page.title || '').toLowerCase() return page.spaPath === '/' || page.slug === 'startseite' || page.slug === 'home' || title === 'startseite' || title === 'home' } function HighlightedText({ text, highlight }: { text: string; highlight: string }) { const index = text.indexOf(highlight) if (!highlight || index < 0) return <>{text} return ( <> {text.slice(0, index)} {highlight} {text.slice(index + highlight.length)} ) } const About: React.FC = () => { const isMobile = useIsMobile() const cms = (useCmsRoute()?.doc?.about || {}) as AboutCms const cmsPages = useCmsCollection('pages') const hero = { ...aboutContent.hero, ...(cms.hero || {}) } const prize = { ...aboutContent.prize, ...(cms.prize || {}) } const mittelstand = { ...aboutContent.mittelstand, ...(cms.mittelstand || {}) } const testimonials = { ...aboutContent.testimonials, ...(cms.testimonials || {}) } const history = { ...aboutContent.history, ...(cms.history || {}) } const goals = { ...aboutContent.goals, ...(cms.goals || {}) } const values = { ...aboutContent.values, ...(cms.values || {}) } const cta = { ...aboutContent.cta, ...(cms.cta || {}) } const participationPage = cmsPages.find(isParticipationPage) const homePage = cmsPages.find(isHomePage) const participationAwardsGrid = (participationPage?.participation as { awardsGrid?: AwardsGridContent } | undefined)?.awardsGrid const homeWinners = (homePage?.home as { winners?: HomeWinnersContent } | undefined)?.winners const showSecondaryCta = !HIDE_MEMBERSHIP_ABOUT_CTA || !isMembershipCta(cta.secondaryCta) return (
{mediaAlt(hero.backgroundImage,
{fallbackText(hero.eyebrow, aboutContent.hero.eyebrow)}

{fallbackText(hero.heading, aboutContent.hero.heading).split('\n').map((line, index) => ( {index > 0 &&
} {line}
))}

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

{ e.currentTarget.style.background = GOLD; e.currentTarget.style.color = '#101828' }} onMouseLeave={(e) => { e.currentTarget.style.background = '#111D55'; e.currentTarget.style.color = '#fff' }} > {fallbackText(hero.primaryCta?.label, aboutContent.hero.primaryCta.label)} { e.currentTarget.style.background = '#FFD130'; e.currentTarget.style.boxShadow = '0 0 18px rgba(239,191,4,0.65), 0 0 40px rgba(239,191,4,0.3)' }} onMouseLeave={(e) => { e.currentTarget.style.background = GOLD; e.currentTarget.style.boxShadow = 'none' }} > {fallbackText(hero.secondaryCta?.label, aboutContent.hero.secondaryCta.label)}
{fallbackArray(hero.stats, aboutContent.hero.stats).map((item, i) => (
{fallbackText(item.value, '')}
{fallbackText(item.label, '')}
))}
{!isMobile && ( <> {fallbackText(prize.eyebrow, aboutContent.prize.eyebrow)}

)}
{paragraphs(prize.body, aboutContent.prize.body).map((text, index, arr) => (

{text}

))}
{fallbackArray(prize.facts, aboutContent.prize.facts).map((f, i, arr) => (
{fallbackText(f.value, '')}
{fallbackText(f.label, '')}
))}
{mediaAlt(prize.image,
{isMobile && (
{fallbackText(prize.eyebrow, aboutContent.prize.eyebrow)}

)} {!isMobile && (
{fallbackText(prize.imageLabel, aboutContent.prize.imageLabel)}
)}
{mediaAlt(mittelstand.image,
{!isMobile && (
)} {isMobile && (
{fallbackText(mittelstand.eyebrow, aboutContent.mittelstand.eyebrow)}

)}
{!isMobile && ( <> {fallbackText(mittelstand.eyebrow, aboutContent.mittelstand.eyebrow)}

)}
{paragraphs(mittelstand.body, aboutContent.mittelstand.body).map((text, index, arr) => (

{text}

))}
{!isMobile &&
{fallbackText(history.watermark, aboutContent.history.watermark)}
} {fallbackText(history.eyebrow, aboutContent.history.eyebrow)}

{fallbackText(history.heading, aboutContent.history.heading).split('\n').map((line, index) => ( {index > 0 &&
}
))}

{fallbackArray(history.items, aboutContent.history.items).map((item, i, arr) => (
{fallbackText(item.year, '')}
{fallbackText(item.title, '')}
{fallbackText(item.desc, '')}
))}
{fallbackText(goals.eyebrow, aboutContent.goals.eyebrow)}

{fallbackArray(goals.items, aboutContent.goals.items).map((item, i, arr) => (
{fallbackText(item.num, '')}
{fallbackText(item.title, '')}
{fallbackText(item.desc, '')}
))}
{fallbackText(values.eyebrow, aboutContent.values.eyebrow)}

{fallbackText(values.description, aboutContent.values.description)}

{fallbackArray(values.items, aboutContent.values.items).map((item, i, arr) => ( ))}
{fallbackText(cta.eyebrow, aboutContent.cta.eyebrow)}

{fallbackText(cta.description, aboutContent.cta.description)}

{ e.currentTarget.style.background = '#FFD130'; e.currentTarget.style.boxShadow = '0 0 18px rgba(239,191,4,0.65), 0 0 40px rgba(239,191,4,0.3)' }} onMouseLeave={(e) => { e.currentTarget.style.background = GOLD; e.currentTarget.style.boxShadow = 'none' }} > {fallbackText(cta.primaryCta?.label, aboutContent.cta.primaryCta.label)} {showSecondaryCta && (
{fallbackText(cta.secondaryPrefix, aboutContent.cta.secondaryPrefix)} { e.currentTarget.style.color = '#EFBF04'; e.currentTarget.style.borderBottomColor = '#EFBF04' }} onMouseLeave={(e) => { e.currentTarget.style.color = 'rgba(239,191,4,0.7)'; e.currentTarget.style.borderBottomColor = 'rgba(239,191,4,0.3)' }} > {fallbackText(cta.secondaryCta?.label, aboutContent.cta.secondaryCta.label)}
)}
) } function ValueRow({ item, last }: { item: { num?: string | null; title?: string | null }; last: boolean }) { const [hovered, setHovered] = useState(false) const isMobileRow = useIsMobile() return (
setHovered(true)} onMouseLeave={() => setHovered(false)} >
{fallbackText(item.num, '')}

{fallbackText(item.title, '')}

) } export default About