1- import React , { useState } from "react" ;
2- import MagazineArchive from "./Searchbar" ; // Assuming this is your search bar component
1+ import React , { useState , useEffect } from "react" ;
2+ import MagazineArchive from "./Searchbar" ; // Search bar component
33import ContentGrid from "./ContentGrid" ;
44
55function MagazineApp ( ) {
6- const [ selectedYear , setSelectedYear ] = useState ( null ) ;
7-
8- // console.log('Selected Year:', selectedYear); // Check if the selected year is logged
9-
10- return (
11- < div className = "bg-gray-900 min-h-screen" >
12- < MagazineArchive onYearSelect = { setSelectedYear } />
13-
14- { /* Content Grid Component */ }
15- { selectedYear && < ContentGrid selectedYear = { selectedYear } /> }
16- </ div >
17- ) ;
18- }
19-
6+ const [ selectedYear , setSelectedYear ] = useState ( null ) ;
7+ const [ loading , setLoading ] = useState ( true ) ; // State for loader
8+
9+ // Simulate API or content loading
10+ useEffect ( ( ) => {
11+ setTimeout ( ( ) => setLoading ( false ) , 1500 ) ; // Simulate loading for 1.5s
12+ } , [ ] ) ;
13+
14+ return (
15+ < div className = "bg-gray-900 min-h-screen" >
16+ { /* Show loader while loading */ }
17+ { loading ? (
18+ < div className = "fixed inset-0 flex items-center justify-center bg-gray-900 z-50" >
19+ < div className = "w-12 h-12 border-4 border-gray-300 border-t-blue-500 rounded-full animate-spin" > </ div >
20+ </ div >
21+ ) : (
22+ < >
23+ < MagazineArchive onYearSelect = { setSelectedYear } />
24+ { /* Show ContentGrid only when a year is selected */ }
25+ { selectedYear && < ContentGrid selectedYear = { selectedYear } /> }
26+ </ >
27+ ) }
28+ </ div >
29+ ) ;
30+ }
2031
2132export default MagazineApp ;
0 commit comments