import { Button, Card, Flex, Typography } from "antd"; import { MyContainer } from "../../../shared/components/MyContainer"; import { CheckOutlined } from "@ant-design/icons"; import HeaderBar from "../../../core/components/Header"; import { useLocation, useNavigate, useParams } from "react-router-dom"; import { Constants } from "../../../core/utils/utils"; import React from "react"; import MySpin from "shared/components/MySpin"; import MyErrorResult from "shared/components/MyResult"; import MyEmpty from "shared/components/MyEmpty"; import { useGetLessonContentsQuery } from "core/services/lessons"; 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
; } } const LessonContents: React.FC = () => { const { lessonId } = useParams(); const { data, error, isLoading } = useGetLessonContentsQuery( lessonId as string, { refetchOnMountOrArgChange: true, } ); if (isLoading) return ; if (error) return ; if (!data || data.length === 0) return ; return ( <> {data.map((lessonContent) => (
))} ); }; export default function LessonPage() { const location = useLocation(); const navigate = useNavigate(); return ( <> navigate(`${location.pathname}/editor`)} /> ); }