2025-01-08 20:29:07 +08:00
|
|
|
// components/CourseSyllabus/LectureItem.tsx
|
|
|
|
|
2025-02-26 10:19:29 +08:00
|
|
|
import { Lecture, LectureType, LessonTypeLabel } from "@nice/common";
|
|
|
|
import React, { useMemo } from "react";
|
2025-02-24 08:51:44 +08:00
|
|
|
import {
|
|
|
|
ClockCircleOutlined,
|
|
|
|
FileTextOutlined,
|
|
|
|
PlayCircleOutlined,
|
|
|
|
} from "@ant-design/icons"; // 使用 Ant Design 图标
|
2025-02-24 11:50:33 +08:00
|
|
|
import { useParams } from "react-router-dom";
|
2025-01-08 20:29:07 +08:00
|
|
|
|
|
|
|
interface LectureItemProps {
|
|
|
|
lecture: Lecture;
|
|
|
|
onClick: (lectureId: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const LectureItem: React.FC<LectureItemProps> = ({
|
|
|
|
lecture,
|
|
|
|
onClick,
|
2025-02-24 11:50:33 +08:00
|
|
|
}) => {
|
|
|
|
const { lectureId } = useParams();
|
2025-02-26 10:19:29 +08:00
|
|
|
const isReading = useMemo(() => {
|
|
|
|
return lecture?.id === lectureId;
|
|
|
|
}, [lectureId, lecture]);
|
2025-02-24 11:50:33 +08:00
|
|
|
return (
|
|
|
|
<div
|
2025-02-26 10:19:29 +08:00
|
|
|
className="w-full flex items-center gap-4 p-4 hover:bg-gray-200 text-left transition-colors cursor-pointer"
|
2025-02-24 11:50:33 +08:00
|
|
|
onClick={() => onClick(lecture.id)}>
|
2025-02-26 10:19:29 +08:00
|
|
|
{lecture?.meta?.type === LectureType.VIDEO && (
|
|
|
|
<div className="text-blue-500 flex items-center">
|
|
|
|
<PlayCircleOutlined className="w-5 h-5 flex-shrink-0" />
|
|
|
|
<span>{LessonTypeLabel[lecture?.meta?.type]}</span>
|
|
|
|
</div>
|
2025-01-08 20:29:07 +08:00
|
|
|
)}
|
2025-02-26 10:19:29 +08:00
|
|
|
{lecture?.meta?.type === LectureType.ARTICLE && (
|
|
|
|
<div className="text-blue-500 flex items-center">
|
|
|
|
<FileTextOutlined className="w-5 h-5 text-blue-500 flex-shrink-0" />{" "}
|
|
|
|
<span>{LessonTypeLabel[lecture?.meta?.type]}</span>
|
|
|
|
</div>
|
2025-02-24 11:50:33 +08:00
|
|
|
)}
|
|
|
|
<div className="flex-grow">
|
|
|
|
<h4 className="font-medium text-gray-800">{lecture.title}</h4>
|
|
|
|
{lecture.subTitle && (
|
|
|
|
<p className="text-sm text-gray-500 mt-1">
|
|
|
|
{lecture.subTitle}
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|