frondend/components/Course/Course.tsx

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-10-06 11:52:45 +08:00
"use client"
2024-10-08 14:58:04 +08:00
import React, { useEffect, useState, 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);
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();
}, []);
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