From b9c589255090396f8761246c48f0d8914fd434f6 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Mon, 24 Mar 2025 23:12:15 +0600 Subject: [PATCH] fix: simplify module --- .../GenerateCourse/AICourseRoadmapView.tsx | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/components/GenerateCourse/AICourseRoadmapView.tsx b/src/components/GenerateCourse/AICourseRoadmapView.tsx index 2442dfcf1..b56080169 100644 --- a/src/components/GenerateCourse/AICourseRoadmapView.tsx +++ b/src/components/GenerateCourse/AICourseRoadmapView.tsx @@ -128,38 +128,11 @@ export function AICourseRoadmapView(props: AICourseRoadmapViewProps) { const nodeId = targetGroup?.dataset?.nodeId; const nodeType = targetGroup?.dataset?.type; - const nodeTitle = targetGroup?.dataset?.title; - const parentTitle = targetGroup?.dataset?.parentTitle; - if (!nodeId || !nodeType) { + if (!nodeId || !nodeType || nodeType !== 'subtopic') { return null; } - const filteredRoadmapStructure = roadmapStructure.filter( - (module) => module.type !== 'title', - ); - - const moduleIndex = filteredRoadmapStructure.findIndex( - (module) => module.label === parentTitle, - ); - - const module = filteredRoadmapStructure[moduleIndex]; - if (module?.type !== 'topic') { - return; - } - - const topicIndex = module.children?.findIndex( - (topic) => topic.label === nodeTitle, - ); - - if (topicIndex === undefined) { - return; - } - - const topic = module.children?.[topicIndex]; - if (topic?.type !== 'subtopic') { - return; - } - + const [moduleIndex, topicIndex] = nodeId.split('-').map(Number); setExpandedModules((prev) => { const newState: Record = {}; roadmapStructure.forEach((_, idx) => {