@@ -25,10 +25,24 @@ const EnhancedHeroSection = () => {
2525 const router = useRouter ( ) ;
2626 const [ mousePosition , setMousePosition ] = useState ( { x : 0 , y : 0 } ) ;
2727 const [ isVisible , setIsVisible ] = useState ( false ) ;
28+ const [ stats , setStats ] = useState < {
29+ activeLearners : number | null ;
30+ skillsAvailable : number | null ;
31+ successfulMatches : number | null ;
32+ totalMatches : number | null ;
33+ satisfactionRate : number | null ;
34+ } > ( {
35+ activeLearners : null ,
36+ skillsAvailable : null ,
37+ successfulMatches : null ,
38+ totalMatches : null ,
39+ satisfactionRate : null ,
40+ } ) ;
41+ const [ loadingStats , setLoadingStats ] = useState ( true ) ;
2842
2943 useEffect ( ( ) => {
3044 setIsVisible ( true ) ;
31-
45+
3246 const handleMouseMove = ( e : MouseEvent ) => {
3347 setMousePosition ( {
3448 x : ( e . clientX / window . innerWidth ) * 100 ,
@@ -40,6 +54,25 @@ const EnhancedHeroSection = () => {
4054 return ( ) => window . removeEventListener ( 'mousemove' , handleMouseMove ) ;
4155 } , [ ] ) ;
4256
57+ useEffect ( ( ) => {
58+ // Fetch hero stats from backend
59+ const fetchStats = async ( ) => {
60+ try {
61+ setLoadingStats ( true ) ;
62+ const res = await fetch ( '/api/stats/hero' ) ;
63+ const data = await res . json ( ) ;
64+ if ( data . success && data . data ) {
65+ setStats ( data . data ) ;
66+ }
67+ } catch ( err ) {
68+ // Optionally handle error
69+ } finally {
70+ setLoadingStats ( false ) ;
71+ }
72+ } ;
73+ fetchStats ( ) ;
74+ } , [ ] ) ;
75+
4376 return (
4477 < section className = "relative min-h-screen flex items-center justify-center overflow-hidden bg-gradient-to-br from-[#006699] via-blue-700 to-indigo-900" >
4578 { /* Animated Background Elements */ }
@@ -144,13 +177,32 @@ const EnhancedHeroSection = () => {
144177 { /* Stats */ }
145178 < div className = { `grid grid-cols-2 md:grid-cols-4 gap-8 transform transition-all duration-1000 delay-800 ${ isVisible ? 'translate-y-0 opacity-100' : 'translate-y-10 opacity-0' } ` } >
146179 { [
147- { number : '50K+' , label : 'Active Learners' , icon : Users } ,
148- { number : '1000+' , label : 'Skills Available' , icon : BookOpen } ,
149- { number : '25K+' , label : 'Successful Matches' , icon : Star } ,
150- { number : '95%' , label : 'Satisfaction Rate' , icon : Award }
180+ {
181+ number : loadingStats || stats . activeLearners === null ? '...' : stats . activeLearners . toLocaleString ( ) ,
182+ label : 'Active Learners' ,
183+ icon : Users
184+ } ,
185+ {
186+ number : loadingStats || stats . skillsAvailable === null ? '...' : stats . skillsAvailable . toLocaleString ( ) ,
187+ label : 'Skills Available' ,
188+ icon : BookOpen
189+ } ,
190+ {
191+ number :
192+ loadingStats || stats . totalMatches === null
193+ ? '...'
194+ : stats . totalMatches . toLocaleString ( ) ,
195+ label : 'Total Matches' ,
196+ icon : Star
197+ } ,
198+ {
199+ number : loadingStats || stats . satisfactionRate === null ? '...' : `${ stats . satisfactionRate } %` ,
200+ label : 'Satisfaction Rate' ,
201+ icon : Award
202+ }
151203 ] . map ( ( stat , index ) => (
152- < div
153- key = { stat . label }
204+ < div
205+ key = { stat . label }
154206 className = "text-center group"
155207 style = { { animationDelay : `${ index * 100 } ms` } }
156208 >
0 commit comments