import { useEffect, useRef, useState } from 'react' import { statsData, serviceListData, commonDescriptions } from '../../data/siteData' function useCountUp(end: number, duration: number = 2000, startCounting: boolean = false) { const [count, setCount] = useState(0) useEffect(() => { if (!startCounting) return let startTime: number let animationFrame: number const animate = (currentTime: number) => { if (!startTime) startTime = currentTime const progress = Math.min((currentTime - startTime) / duration, 1) setCount(Math.floor(progress * end)) if (progress < 1) { animationFrame = requestAnimationFrame(animate) } } animationFrame = requestAnimationFrame(animate) return () => cancelAnimationFrame(animationFrame) }, [end, duration, startCounting]) return count } function StatItem({ value, label, startCounting }: { value: number; label: string; startCounting: boolean }) { const count = useCountUp(value, 2000, startCounting) return (

{count}

{label}
) } export default function Stats() { const sectionRef = useRef(null) const [startCounting, setStartCounting] = useState(false) useEffect(() => { const observer = new IntersectionObserver( (entries) => { if (entries[0].isIntersecting) { setStartCounting(true) observer.disconnect() } }, { threshold: 0.3 } ) if (sectionRef.current) { observer.observe(sectionRef.current) } return () => observer.disconnect() }, []) return (
{/* Overlay */}
{/* Section Header */}

{commonDescriptions.statsTitle}

{commonDescriptions.sectionDesc}

{/* Left Content */}

{commonDescriptions.statsSubtitle}

{commonDescriptions.statsDesc}

{commonDescriptions.statsDesc2}

{/* Stats Grid */}
{statsData.map((stat) => ( ))}
{/* Right Content - Service List */}
{serviceListData.map((service) => (
{service.title}

{service.description}

))}
) }