import React, { useEffect, useState } from "react"; import { Image, ProgressBar } from "antd-mobile"; import { useNavigate } from "react-router-dom"; import styles from "./courses-model.module.scss"; import mediaIcon from "../../../assets/images/commen/icon-medal.png"; interface PropInterface { id: number; title: string; thumb: string; isRequired: number; record: any; } export const CoursesModel: React.FC = ({ id, title, thumb, isRequired, record, }) => { const navigate = useNavigate(); const [userCourseProgress, setUserCourseProgress] = useState(0); useEffect(() => { if (record?.progress) { setUserCourseProgress(Math.floor(record.progress / 100)); } else { setUserCourseProgress(1); } }, [record]); return ( <>
{ navigate(`/course/${id}`); }} >
{title}
{isRequired === 1 &&
必修课
} {isRequired === 0 && (
选修课
)} {userCourseProgress == 1 && ( )} {userCourseProgress > 1 && userCourseProgress < 100 && ( )} {userCourseProgress >= 100 && (
恭喜你学完此课程!
)}
); };