From fd85fd894b2e2a721a8cb029666d605f07763a1c Mon Sep 17 00:00:00 2001 From: Hai Nguyen <2nguyen.work@gmail.com> Date: Wed, 19 Aug 2026 21:15:42 +0700 Subject: [PATCH] feat: add page course details --- src/App.jsx | 2 + src/components/CourseCard.jsx | 29 ++++++-- src/pages/Course/CourseDetails.jsx | 114 +++++++++++++++++++++++++++++ src/pages/Course/CoursesPage.jsx | 33 +++++---- 4 files changed, 155 insertions(+), 23 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 17037ac..af3bfe5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,6 +1,7 @@ import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; import MainLayout from './layouts/MainLayout.jsx'; import CoursesPage from './pages/Course/CoursesPage.jsx'; +import CourseDetail from './pages/Course/CourseDetails.jsx'; import StudentsPage from './pages/StudentsPage.jsx'; import ClassesPage from './pages/ClassesPage.jsx'; import ReportsPage from './pages/ReportsPage.jsx'; @@ -13,6 +14,7 @@ function App() { }> } /> } /> + } /> } /> } /> } /> diff --git a/src/components/CourseCard.jsx b/src/components/CourseCard.jsx index 7a884df..4b37992 100644 --- a/src/components/CourseCard.jsx +++ b/src/components/CourseCard.jsx @@ -2,12 +2,11 @@ import { Card, Button } from '@heroui/react'; import { PencilIcon, EllipsisVerticalIcon } from '@heroicons/react/24/outline'; const statusStyles = { - Published: 'bg-green-100 text-green-700', - Draft: 'bg-yellow-100 text-yellow-700', - Archived: 'bg-gray-100 text-gray-600' + Active: 'bg-green-100 text-green-700', + Inactive: 'bg-gray-100 text-gray-600' }; -function CourseCard({ course, image }) { +function CourseCard({ course, image, handleClick }) { const { code, title, description, status, lastUpdate } = course; const formattedDate = new Date(lastUpdate).toLocaleDateString('en-GB', { @@ -20,19 +19,19 @@ function CourseCard({ course, image }) { {/* Image */} -
+
{title} - {/* Course code */}
{code}
{/* Content */} - +

{title}

@@ -43,7 +42,13 @@ function CourseCard({ course, image }) {
{/* Footer */} - + { + e.stopPropagation(); + // handle edit + }} + >
{ + e.stopPropagation(); + // handle edit + }} > @@ -71,6 +80,10 @@ function CourseCard({ course, image }) { variant="ghost" size="sm" aria-label={`More actions for ${title}`} + onClick={(e) => { + e.stopPropagation(); + // handle edit + }} > diff --git a/src/pages/Course/CourseDetails.jsx b/src/pages/Course/CourseDetails.jsx index e69de29..d15d7da 100644 --- a/src/pages/Course/CourseDetails.jsx +++ b/src/pages/Course/CourseDetails.jsx @@ -0,0 +1,114 @@ +import { + Card, + Button, + Typography, + TextField, + Input, + Label, + Chip, + TextArea +} from '@heroui/react'; +import PageHeader from '../../components/PageHeader'; +import { useParams } from 'react-router-dom'; + +const data = [ + { + code: 'LDR-101', + title: 'Foundations of Modern Leadership', + description: + 'An introductory course covering essential leadership principles for new managers.', + status: 'Active', + lastUpdate: '2026-08-19', + image: + 'https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=800&q=80' + }, + { + code: 'TEC-204', + title: 'Advanced Cloud Architecture Patterns', + description: + 'Deep dive into scalable cloud infrastructure design and implementation strategies.', + status: 'Inactive', + lastUpdate: '2026-08-19', + image: + 'https://images.unsplash.com/photo-1533090161767-e6ffed986c88?auto=format&fit=crop&w=800&q=80' + }, + { + code: 'CMP-099', + title: '2022 Annual Compliance Review', + description: 'Outdated compliance materials from the previous fiscal year.', + status: 'Inactive', + lastUpdate: '2026-08-19', + image: + 'https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=800&q=80' + } +]; + +function CourseDetail() { + const { courseId } = useParams(); + const course = data.find((e) => e.code === courseId); + + if (!course) { + return
Course not found
; + } + return ( + <> + +
+ {course?.title} +
+ + +
+
+
+ + + Course Details + + + + + + + + {course?.status === 'Active' ? ( + + Active + + ) : ( + Inactive + )} + + +