'use client'; import React from 'react'; import { getSectionTitle } from '@/lib/homepageDefaults'; interface FeatureItem { id: string; title: string; desc: string; icon: 'shipping' | 'return' | 'support' | 'payment' | 'wrench' | 'clock' | string; } interface FeaturesSectionProps { config?: any; } /** TechShop reference strip — matches admin Homepage Layout defaults */ const REFERENCE_FEATURES: FeatureItem[] = [ { id: 'shipping', icon: 'shipping', title: 'Free Shipping', desc: 'On order over $100', }, { id: 'return', icon: 'return', title: 'Flexible & Easy Return', desc: 'Return within 14 days', }, { id: 'support', icon: 'support', title: '24/7 Support Services', desc: 'Any Time Customer Support', }, { id: 'payment', icon: 'payment', title: 'Secure payment', desc: '100% Fast & Secure Payment', }, ]; const ICON_ALIAS: Record = { Truck: 'shipping', shipping: 'shipping', RefreshCcw: 'return', RefreshCw: 'return', RotateCcw: 'return', return: 'return', Headphones: 'support', Headset: 'support', support: 'support', CreditCard: 'payment', ShieldCheck: 'payment', payment: 'payment', Wrench: 'wrench', wrench: 'wrench', Clock: 'clock', clock: 'clock', ThumbsUp: 'payment', }; /** Custom line icons matching TechShop reference artwork */ function FeatureIcon({ type, className = '', }: { type: string; className?: string; }) { const kind = ICON_ALIAS[type] || type; const common = { fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const, }; if (kind === 'shipping') { return ( {/* motion lines */} {/* truck body */} ); } if (kind === 'return') { return ( $ ); } if (kind === 'support') { return ( {/* speech bubble */} ); } if (kind === 'wrench') { return ( ); } if (kind === 'clock') { return ( ); } // payment — card + shield return ( ); } function resolveIconKey(raw: string | undefined, idx: number): string { if (raw && ICON_ALIAS[raw]) return ICON_ALIAS[raw] as string; if ( raw === 'shipping' || raw === 'return' || raw === 'support' || raw === 'payment' || raw === 'wrench' || raw === 'clock' ) { return raw; } return REFERENCE_FEATURES[idx]?.icon || 'shipping'; } /** * Prefer CMS features from admin Homepage Layout. * Fall back to TechShop reference badges when CMS has none. */ function buildTiles(config?: any): FeatureItem[] { const fromConfig = config?.metadata_json?.features || config?.metadata?.features; if (!Array.isArray(fromConfig) || fromConfig.length === 0) { return REFERENCE_FEATURES; } return fromConfig.slice(0, 8).map((item: any, idx: number) => { const ref = REFERENCE_FEATURES[idx] || REFERENCE_FEATURES[0]; return { id: String(item.id || `feature-${idx + 1}`), title: String(item.title || ref.title), desc: String(item.desc || item.description || item.subtitle || ref.desc), icon: resolveIconKey(item.icon, idx), }; }); } export const FeaturesSection: React.FC = ({ config }) => { const tiles = buildTiles(config); const title = getSectionTitle(config, 'trust_badges', ''); return (
{title ? (

{title}

) : null}
= 4 ? 'xl:grid-cols-4' : 'xl:grid-cols-3' }`} > {tiles.map((item) => (

{item.title}

{item.desc}

))}
); };