import Image from "next/image"; import { Check } from "lucide-react"; import type { CmsProductContent } from "@/types/cms-landing"; const DEFAULT_TITLE = "The product we offer is designed to meet your business needs."; const DEFAULT_BODY = "Social media marketing services are provided by companies or individuals who specialize in marketing strategies through social media platforms."; function cardImageUrl(p: CmsProductContent) { return p.images?.[0]?.image_url?.trim() || "/image/p1.png"; } export default function ProductSection({ products, }: { products?: CmsProductContent[] | null; }) { const list = products?.filter((p) => p.id) ?? []; if (list.length === 0) { return (

Our Product

{DEFAULT_TITLE}

Product illustration

MediaHUB Content Aggregator

{DEFAULT_BODY}

); } const first = list[0]; const sectionTitle = first?.primary_title?.trim() || "Products tailored to your business"; const subtitle = first?.secondary_title?.trim(); return (

Our Product

{list.length > 1 ? "Our Products" : sectionTitle}

{subtitle && list.length > 1 ? (

{subtitle}

) : null}
{list.map((p) => { const imgSrc = cardImageUrl(p); const external = /^https?:\/\//i.test(imgSrc); const rawDesc = p.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 (
{external ? ( // eslint-disable-next-line @next/next/no-img-element ) : ( )}

{p.primary_title?.trim() || "Product"}

{p.secondary_title?.trim() ? (

{p.secondary_title.trim()}

) : null} {useBullets ? (
    {lines.map((item) => (
  • {item}
  • ))}
) : (

{bodyText}

)}
); })}
); }