@@ -6,22 +6,15 @@ import HomepageMap from '@/components/Homepage/HomepageMap';
66import LocationDropdown from '@/components/Homepage/LocationDropdown' ;
77import Hero from '@/components/ui/Hero' ;
88import { generateSEOMetadata } from '@/utils/seo' ;
9+ import { statsRepository } from '@/repositories/stats' ;
10+
11+ export const revalidate = 60 ;
912
1013async function getStatistics ( ) {
1114 try {
12- const baseUrl = process . env . NEXT_PUBLIC_BASE_URL || 'http://localhost:3000' ;
13- const response = await fetch ( `${ baseUrl } /api/stats` , {
14- next : { revalidate : 60 } // Revalidate every 60 seconds
15- } ) ;
16-
17- if ( ! response . ok ) {
18- throw new Error ( 'Failed to fetch statistics' ) ;
19- }
20-
21- return await response . json ( ) ;
15+ return await statsRepository . getStats ( ) ;
2216 } catch ( error ) {
2317 console . error ( 'Error fetching statistics:' , error ) ;
24- // Return default values if fetch fails
2518 return {
2619 organisations : 0 ,
2720 services : 0 ,
@@ -140,25 +133,25 @@ export default async function Home() {
140133 </ section >
141134
142135 { /* Statistics Section */ }
143- < section className = "section-spacing px-4 bg-brand-a text-white" >
136+ < section className = "section-spacing px-4 bg-brand-a text-white" aria-label = "Key statistics" >
144137 < div className = "max-w-4xl mx-auto" >
145- < dl className = "grid grid-cols-1 md:grid-cols-3 gap-8 text-center" >
138+ < div className = "grid grid-cols-1 md:grid-cols-3 gap-8 text-center" >
146139 < div >
147- < dd className = "statistics-value text-5xl md:text-6xl font-bold mb-2 text-brand-d" > { stats . organisations } </ dd >
148- < dt className = "statistics-title text-xl md:text-2xl font-light " > Organisations</ dt >
149- < dd className = "statistics-title text-lg md:text-xl font-light text-brand-k " > Listed</ dd >
140+ < div className = "statistics-value text-5xl md:text-6xl font-bold mb-2 text-brand-d" > { stats . organisations } </ div >
141+ < div className = "statistics-title text-xl md:text-2xl font-medium " > Organisations</ div >
142+ < div className = "statistics-subtitle text-lg md:text-xl" > Listed</ div >
150143 </ div >
151144 < div >
152- < dd className = "statistics-value text-5xl md:text-6xl font-bold mb-2 text-brand-d" > { stats . services } </ dd >
153- < dt className = "statistics-title text-xl md:text-2xl font-light " > Services</ dt >
154- < dd className = "statistics-title text-lg md:text-xl font-light text-brand-k " > Provided</ dd >
145+ < div className = "statistics-value text-5xl md:text-6xl font-bold mb-2 text-brand-d" > { stats . services } </ div >
146+ < div className = "statistics-title text-xl md:text-2xl font-medium " > Services</ div >
147+ < div className = "statistics-subtitle text-lg md:text-xl" > Provided</ div >
155148 </ div >
156149 < div >
157- < dd className = "statistics-value text-5xl md:text-6xl font-bold mb-2 text-brand-d" > { stats . partnerships } </ dd >
158- < dt className = "statistics-title text-xl md:text-2xl font-light" > Homelessness Partnerships</ dt >
159- < dd className = "statistics-title text-lg md:text-xl font-light text-brand-k " > Supported</ dd >
150+ < div className = "statistics-value text-5xl md:text-6xl font-bold mb-2 text-brand-d" > { stats . partnerships } </ div >
151+ < div className = "statistics-title text-xl md:text-2xl font-medium" > Partnerships</ div >
152+ < div className = "statistics-subtitle text-lg md:text-xl" > Supported</ div >
160153 </ div >
161- </ dl >
154+ </ div >
162155 </ div >
163156 </ section >
164157
0 commit comments