import Image from "next/image"; import Link from "next/link"; import { Check } from "lucide-react"; import type { CmsServiceContent } from "@/types/cms-landing"; const DEFAULT_HEADING = "Innovative solutions for your business growth."; const DEFAULT_BODY = "Professional services tailored to your organization. Update this text from the CMS admin under Content Website → Our Services."; function cardImageUrl(s: CmsServiceContent) { return s.images?.[0]?.image_url?.trim() || "/image/s1.png"; } function resolveServiceLink(raw: string | undefined | null): string | null { const t = raw?.trim(); if (!t) return null; if (/^(https?:|\/|#|mailto:)/i.test(t)) return t; return `https://${t}`; } function LearnMoreCta({ href }: { href?: string | null }) { const resolved = resolveServiceLink(href); const className = "inline-flex text-sm font-semibold text-[#966314] hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#966314]"; if (!resolved) return null; if (resolved.startsWith("/")) { return ( Learn More → ); } return ( Learn More → ); } function BulletLine({ text }: { text: string }) { const idx = text.indexOf(":"); if (idx > 0 && idx < text.length - 1) { const label = text.slice(0, idx).trim(); const rest = text.slice(idx + 1).trim(); return ( <> {label}: {rest} ); } return <>{text}; } function ServiceImageBlock({ imgSrc, alt }: { imgSrc: string; alt: string }) { const external = /^https?:\/\//i.test(imgSrc); return (
{external ? ( // eslint-disable-next-line @next/next/no-img-element {alt} ) : ( {alt} )}
); } function ServiceTextBlock({ s }: { s: CmsServiceContent }) { const rawDesc = s.description?.trim(); const lines = rawDesc ? rawDesc.split(/\r?\n/).map((l) => l.trim()).filter(Boolean) : []; const useBullets = lines.length > 1; const bodyText = lines.length === 0 ? DEFAULT_BODY : rawDesc ?? ""; return (

{s.primary_title?.trim() || "Service"}

{s.secondary_title?.trim() ? (

{s.secondary_title.trim()}

) : null} {useBullets ? ( ) : (

{bodyText}

)}
); } export default function ServiceSection({ services, }: { services?: CmsServiceContent[] | null; }) { const list = services?.filter((s) => s.id) ?? []; if (list.length === 0) { return (

Our Services

{DEFAULT_HEADING}

Our services

{DEFAULT_BODY}

); } return (

Our Services

{DEFAULT_HEADING}

{list.map((s, index) => { const imgSrc = cardImageUrl(s); const alt = s.primary_title?.trim() || "Service"; const reverse = index % 2 === 1; return (
); })}
); }