From 8488e0025406606320fcf6d8dd239566a1314ba1 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Fri, 8 Mar 2024 01:53:43 +0600 Subject: [PATCH] fix: roadmap topic details --- .../GenerateRoadmap/GenerateRoadmap.tsx | 17 +++++++++++++---- .../GenerateRoadmap/RoadmapTopicDetail.tsx | 6 ++++++ 2 files changed, 19 insertions(+), 4 deletions(-) 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}`, {