frondend/components/Course/Course.tsx

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-10-06 11:52:45 +08:00
"use client"
import React, { useEffect, useState, lazy, Suspense } from 'react'
2024-10-05 15:04:17 +08:00
import Banner from './Banner'
import LongDesc from './LongDesc'
import CourseImagesSilder from './CourseImagesSilder'
import Accordion from './Accordion'
2024-10-06 11:52:45 +08:00
import { CoursesProps, SettingsProps } from '@/types'
2024-10-05 15:04:17 +08:00
import Footer from '../Footer'
2024-10-06 11:52:45 +08:00
import Loading from '../Loading'
const Course = ({ course, settings }: { course: CoursesProps, settings: SettingsProps }) => {
const [loading, setLoading] = useState(true);
// const [courses, setCourses] = useState<CoursesProps[]>([]);
useEffect(() => {
const loadCourses = async () => {
setLoading(true);
await new Promise(resolve => setTimeout(resolve, 300)); // 0.5 second delay
setLoading(false);
}; loadCourses();
}, []);
const startLoading = () => setLoading(true);
const stopLoading = () => setLoading(false);
2024-10-05 15:04:17 +08:00
return (
<div className='bg-[#F6E8E8]'>
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 courseData={course} />
<LongDesc courseData={course} />
<CourseImagesSilder courseData={course} />
<Accordion courseData={course} />
<Footer settings={settings} />
</div>
)}
2024-10-05 15:04:17 +08:00
</div>
)
}
export default Course