diff --git a/src/components/GenerateRoadmap/GenerateRoadmap.tsx b/src/components/GenerateRoadmap/GenerateRoadmap.tsx index 80e19832c..5c0460c7d 100644 --- a/src/components/GenerateRoadmap/GenerateRoadmap.tsx +++ b/src/components/GenerateRoadmap/GenerateRoadmap.tsx @@ -281,12 +281,21 @@ export function GenerateRoadmap() { setGeneratedRoadmapContent(data); }; - const handleSvgClick = useCallback( + const handleNodeClick = useCallback( (e: MouseEvent) => { + if (isLoading) { + return; + } + const target = e.target as SVGElement; const { nodeId, nodeType, targetGroup, nodeTitle, parentTitle } = getNodeDetails(target) || {}; - if (!nodeId || !nodeType || !allowedClickableNodeTypes.includes(nodeType)) + if ( + !nodeId || + !nodeType || + !allowedClickableNodeTypes.includes(nodeType) || + !nodeTitle + ) return; if (nodeType === 'button' || nodeType === 'link-item') { @@ -307,7 +316,7 @@ export function GenerateRoadmap() { ...(nodeType === 'subtopic' && { parentTitle }), }); }, - [], + [isLoading], ); useEffect(() => { @@ -465,7 +474,7 @@ export function GenerateRoadmap() {
diff --git a/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx b/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx index 1737a912d..8facf5ad2 100644 --- a/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx +++ b/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx @@ -28,6 +28,12 @@ export function RoadmapTopicDetail(props: RoadmapTopicDetailProps) { setIsLoading(true); setError(''); + if (!roadmapId || !nodeTitle) { + setIsLoading(false); + setError('Invalid roadmap id or node title'); + return; + } + const response = await fetch( `${import.meta.env.PUBLIC_API_URL}/v1-genereate-ai-roadmap-content/${roadmapId}`, {