From bab4a1581dee11e3d37d6139777b5135583f24bc Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Thu, 30 May 2024 03:54:13 +0600 Subject: [PATCH] fix: show login popup for logged out user (#5764) --- .../EditorRoadmap/EditorRoadmapRenderer.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/EditorRoadmap/EditorRoadmapRenderer.tsx b/src/components/EditorRoadmap/EditorRoadmapRenderer.tsx index b964b2319..c2e83d64c 100644 --- a/src/components/EditorRoadmap/EditorRoadmapRenderer.tsx +++ b/src/components/EditorRoadmap/EditorRoadmapRenderer.tsx @@ -12,6 +12,8 @@ import { useToast } from '../../hooks/use-toast'; import type { Edge, Node } from 'reactflow'; import { Renderer } from '../../../editor/renderer'; import { slugify } from '../../lib/slugger'; +import { isLoggedIn } from '../../lib/jwt'; +import { showLoginPopup } from '../../lib/popup'; export type RoadmapRendererProps = { resourceId: string; @@ -104,6 +106,11 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) { if (e.shiftKey) { e.preventDefault(); + if (!isLoggedIn()) { + showLoginPopup(); + return; + } + updateTopicStatus( nodeId, isCurrentStatusLearning ? 'pending' : 'learning', @@ -111,6 +118,11 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) { return; } else if (e.altKey) { e.preventDefault(); + if (!isLoggedIn()) { + showLoginPopup(); + return; + } + updateTopicStatus(nodeId, isCurrentStatusSkipped ? 'pending' : 'skipped'); return; } @@ -143,6 +155,10 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) { return; } + if (!isLoggedIn()) { + showLoginPopup(); + return; + } const isCurrentStatusDone = targetGroup?.classList.contains('done'); updateTopicStatus(nodeId, isCurrentStatusDone ? 'pending' : 'done'); }, []);