import { CommentOutlined } from "@ant-design/icons"; import { Card, Flex, Input } from "antd"; import { Constants, getImageUrl } from "core/utils/utils"; import { Link } from "react-router-dom"; import MyUpload from "shared/components/MyUpload"; import styles from "./styles.module.css"; import { LessonSettings } from "core/types/lesson"; import { useTranslation } from "react-i18next"; export default function MyLessonPreviewCard({ mode = "view", lessonId, loading = false, lessonSettings, onEditTitle, onThumbnailChanged, }: { mode: "view" | "editable"; lessonId: string; loading?: boolean; lessonSettings: LessonSettings; onEditTitle?: (newTitle: string) => void; onThumbnailChanged?: () => void; }) { const { t } = useTranslation(); const LinkWrapper = ({ children }: { children: React.ReactNode }) => { if (mode === "editable") return <>{children}; return ( {children} ); }; const UploadWrapper = ({ children }: { children: React.ReactNode }) => { if (mode === "view") return <>{children}; return ( { if (info.file.status === "done") { onThumbnailChanged?.(); } }} imgCropProps={{ aspect: 5 / 4, children: <>, }} > {children} ); }; return (
lesson thumbnail {mode === "view" ? (
{lessonSettings.Title}
{lessonSettings.QuestionsCount}{" "} {t("lessonPage.questions")}
) : ( onEditTitle?.(event.target.value)} placeholder={t("lessonPageEditor.titlePlaceholder")} style={{ width: "100%", fontSize: 24, fontWeight: "bold" }} /> )}
); } /* onEditTitle?.(event), }} style={{ width: "100%", margin: 0, }} > {lessonSettings.Title} */