"use client"; import { useEffect, useRef, useState } from "react"; import { ReactElement } from "react"; interface Feature { icon: ReactElement; title: string; description: string; bgColor: string; borderColor: string; hoverBg: string; } interface Stat { prefix: string; number: number; suffix: string; label: string; } const features: Feature[] = [ { icon: ( ), title: "Product Catalogs", description: "Showcase your seasonal produce with rich media galleries, detailed specs, and real-time availability updates.", bgColor: "#f0f5f1", borderColor: "#6b8f71", hoverBg: "#e8f0e9", }, { icon: ( ), title: "Route Planning", description: "Optimize delivery routes across your farm network with intelligent mapping and scheduling tools.", bgColor: "#fdf6f0", borderColor: "#c97a3e", hoverBg: "#fbeeda", }, { icon: ( ), title: "Order Management", description: "Track orders from placement through delivery with automated status updates and seamless integrations.", bgColor: "#f5f0f8", borderColor: "#7a5c9e", hoverBg: "#ece6f5", }, { icon: ( ), title: "Wholesale Portal", description: "Give buyers a dedicated space to browse pricing, request quotes, and place bulk orders on their schedule.", bgColor: "#f0f5f5", borderColor: "#5c8a8f", hoverBg: "#e5f0f2", }, { icon: ( ), title: "Harvest Reach", description: "Send email and SMS campaigns that keep buyers informed about seasonal availability and new harvests.", bgColor: "#faf5f0", borderColor: "#c97a3e", hoverBg: "#f5ebe0", }, { icon: ( ), title: "Smart Analytics", description: "Uncover sales trends, buyer behavior, and operational insights with real-time dashboards and reports.", bgColor: "#f5f8f0", borderColor: "#6b8f71", hoverBg: "#eaf3e5", }, ]; const stats: Stat[] = [ { prefix: "", number: 500, suffix: "+", label: "Produce Brands" }, { prefix: "", number: 50000, suffix: "+", label: "Orders Delivered" }, { prefix: "", number: 98, suffix: "%", label: "On-Time Delivery" }, { prefix: "$", number: 2, suffix: "M+", label: "Weekly Sales" }, ]; export default function FeaturesAndStats() { const [countersStarted, setCountersStarted] = useState(false); const [counters, setCounters] = useState(stats.map(() => 0)); const statsRef = useRef(null); useEffect(() => { const observer = new IntersectionObserver( (entries) => { if (entries[0].isIntersecting && !countersStarted) { setCountersStarted(true); } }, { threshold: 0.3 } ); if (statsRef.current) { observer.observe(statsRef.current); } return () => observer.disconnect(); }, [countersStarted]); useEffect(() => { if (!countersStarted) return; const duration = 2000; const steps = 60; const interval = duration / steps; let step = 0; const timer = setInterval(() => { step++; const progress = step / steps; const easeOut = 1 - Math.pow(1 - progress, 3); setCounters( stats.map((stat) => { if (stat.number >= 1000) { return Math.floor(stat.number * easeOut); } else if (stat.number >= 100) { return Math.floor(stat.number * easeOut); } else if (stat.number >= 10) { return Math.floor(stat.number * easeOut); } else { return Math.floor(stat.number * easeOut); } }) ); if (step >= steps) { clearInterval(timer); setCounters(stats.map((stat) => stat.number)); } }, interval); return () => clearInterval(timer); }, [countersStarted]); return (
{/* ─── FEATURES SECTION ─── */}
{/* Header */}
Platform Features

Everything You Need

From farm to table, manage your entire produce supply chain in one place.

{/* Feature Cards Grid */}
{features.map((feature, index) => (
{ e.currentTarget.style.backgroundColor = feature.hoverBg; e.currentTarget.style.borderColor = feature.borderColor; }} onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = feature.bgColor; e.currentTarget.style.borderColor = `rgba(${ index % 2 === 0 ? "107,143,113" : "201,122,62" }, 0.15)`; }} >
{feature.icon}

{feature.title}

{feature.description}

))}
{/* ─── STATS SECTION ─── */}
{/* Subtle background pattern */}
{/* Decorative top line */}
{/* Header */}
Our Reach

Growing Together

{/* Stats Grid */}
{stats.map((stat, index) => (
{stat.prefix && ( {stat.prefix} )} {counters[index].toLocaleString()} {stat.suffix}

{stat.label}

{/* Divider between stats */} {index < stats.length - 1 && (
)}
))}
); }