2024-10-06 11:52:45 +08:00
|
|
|
"use client";
|
|
|
|
|
2024-10-08 14:46:18 +08:00
|
|
|
import { useState, useEffect, Suspense } from "react";
|
2024-10-06 11:52:45 +08:00
|
|
|
import Loading from '../Loading'
|
|
|
|
import Footer from '../Footer'
|
|
|
|
import ContactForm from "../ContactForm";
|
|
|
|
import AboutusContent from "./AboutusContent";
|
|
|
|
import Banner from "./Banner";
|
|
|
|
import Map from "./Map";
|
2024-10-08 15:11:16 +08:00
|
|
|
import { SettingsProps, AboutusProps } from "@/types";
|
2024-10-08 14:46:18 +08:00
|
|
|
|
2024-10-08 15:11:16 +08:00
|
|
|
const Home = ({ settings, aboutus }: { settings: SettingsProps, aboutus: AboutusProps[] }) => {
|
2024-10-06 11:52:45 +08:00
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
// const [courses, setCourses] = useState<CoursesProps[]>([]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const loadCourses = async () => {
|
|
|
|
setLoading(true);
|
2024-10-28 21:26:03 +08:00
|
|
|
await new Promise(resolve => setTimeout(resolve, 100)); // 0.5 second delay
|
2024-10-06 11:52:45 +08:00
|
|
|
setLoading(false);
|
|
|
|
}; loadCourses();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const startLoading = () => setLoading(true);
|
|
|
|
const stopLoading = () => setLoading(false);
|
|
|
|
|
|
|
|
return (
|
2024-10-08 21:49:58 +08:00
|
|
|
<div className='bg-[#F2D5D5] sm:bg-[#FFF9F9]'>
|
2024-10-06 11:52:45 +08:00
|
|
|
{loading ? (
|
|
|
|
<div className="flex justify-center items-center h-screen">
|
|
|
|
<Suspense fallback={<div>Loading...</div>}>
|
|
|
|
<Loading />
|
|
|
|
</Suspense>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div>
|
|
|
|
<Banner />
|
|
|
|
<AboutusContent aboutus={aboutus} />
|
|
|
|
<Map settings={settings} />
|
|
|
|
<ContactForm startLoading={startLoading} stopLoading={stopLoading} />
|
|
|
|
<Footer settings={settings} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
export default Home
|