import { Button, Card, Flex, Typography } from "antd"; import img from "./pexels-photo-302902.webp"; import { MyContainer } from "../../../shared/components/MyContainer"; import { CheckOutlined } from "@ant-design/icons"; import HeaderBar from "../../../core/components/Header"; import { useLocation, useNavigate } from "react-router-dom"; import { Constants } from "../../../core/utils/utils"; export type LessonContent = { id: string; position: number; type: number; data: string; }; const LessonContents = [ { id: "0", position: 1, type: 0, data: "How to clean the coffee machine", }, { id: "1", position: 1, type: 2, data: img, }, { id: "2", position: 2, type: 1, data: "The proper cleaning of the coffee machine", }, { id: "3", position: 3, type: 1, data: "Think a moment in silence. What makes you really happy? Are you the only one with this? Probably you could sell this knowledge to others! Think about it", }, ] as LessonContent[]; export function Converter({ mode, lessonContent, onEdit, }: { mode: "view" | "edititable"; lessonContent: LessonContent; onEdit?: (newData: string) => void; }) { // const dispatch = useDispatch(); // const contents = useSelector(lessonContents); switch (lessonContent.type) { case 0: return mode === "view" ? (
{lessonContent.data}
) : ( onEdit?.(event), }} level={1} style={{ margin: 0, width: "100%", }} > {lessonContent.data} ); case 1: return mode === "view" ? (
{lessonContent.data}
) : ( onEdit?.(event), }} style={{ margin: 0, width: "100%", }} > {lessonContent.data} ); case 2: return ( img ); case 3: return (
{lessonContent.data}
); case 4: return
{lessonContent.data}
; default: return
Unknown type
; } } export default function LessonPage() { const location = useLocation() const navigate = useNavigate() return ( <> navigate(`${location.pathname}/editor`)} /> {LessonContents.map((lessonContent) => (
))}
); }