"use client"; import React, { useState, useEffect } from 'react'; import Link from 'next/link'; import { catalogService, BrandResponse } from '../services/api/catalogService'; import { getImageUrl } from '../lib/utils'; import { BrandTileSkeleton } from '../components/ui/Skeleton'; import { getSectionTitle } from '../lib/homepageDefaults'; interface BrandItem { id: string; name: string; slug: string; logo?: string; fontClass?: string; } /** Real brands from catalog / CMS only — no fake filler brands */ const FALLBACK_FONT = 'font-bold tracking-wide text-[15px]'; interface BrandsSectionProps { config?: any; initialBrands?: BrandResponse[]; } function toBrandItem(b: any, idx: number): BrandItem { return { id: String(b.brand_id || b.id || b.slug || idx), name: b.name || 'Brand', slug: b.slug || String(b.brand_id || b.id || idx), logo: getImageUrl(b.logo_url || b.logo || b.image) || undefined, fontClass: FALLBACK_FONT, }; } export const BrandsSection: React.FC = ({ config, initialBrands, }) => { const [brands, setBrands] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const rawConfig = config?.metadata_json?.brands || config?.metadata?.brands; const applyList = (list: any[]) => { if (list && list.length > 0) { setBrands(list.slice(0, 10).map(toBrandItem)); } else { setBrands([]); } setLoading(false); }; if (rawConfig && Array.isArray(rawConfig) && rawConfig.length > 0) { applyList(rawConfig); return; } if (initialBrands && initialBrands.length > 0) { applyList(initialBrands); return; } catalogService .getBrands() .then((res) => applyList(res || [])) .catch(() => applyList([])); }, [config, initialBrands]); const title = getSectionTitle(config, 'official_brands', 'Official Tech Brands'); if (!loading && brands.length === 0) { return (

{title}

Brand partners will appear here once logos are configured.
); } return (
{/* Header + full-width divider */}

{title}

{loading ? (
{Array.from({ length: 10 }).map((_, i) => ( ))}
) : (
{brands.map((brand) => ( {brand.logo ? ( {brand.name} ) : ( {brand.name} )} ))}
)}
); };