import { useEffect, useState } from "react"; import AnthologyTocTree from "./AnthologyTocTree"; import { get } from "../../request"; import type { ICourseResponse } from "../../api/Course"; interface IWidget { courseId?: string | null; channels?: string[]; onClick?: (article: string, target: string) => void; } const TextBookTocWidget = ({ courseId, channels, onClick }: IWidget) => { const [anthologyId, setAnthologyId] = useState(); useEffect(() => { if (!courseId) { return; } const url = `/v2/course/${courseId}`; console.debug("course url", url); get(url).then((json) => { console.debug("course data", json.data); if (json.ok) { setAnthologyId(json.data.anthology_id); } }); }, [courseId]); return ( { console.debug("AnthologyTocTree onClick", article); if (typeof onClick !== "undefined") { onClick(article, target); } }} /> ); }; export default TextBookTocWidget;