fix: show login popup for logged out user (#5764)

pull/5767/head
Arik Chakma 6 months ago committed by GitHub
parent bb6d34407d
commit bab4a1581d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      src/components/EditorRoadmap/EditorRoadmapRenderer.tsx

@ -12,6 +12,8 @@ import { useToast } from '../../hooks/use-toast';
import type { Edge, Node } from 'reactflow'; import type { Edge, Node } from 'reactflow';
import { Renderer } from '../../../editor/renderer'; import { Renderer } from '../../../editor/renderer';
import { slugify } from '../../lib/slugger'; import { slugify } from '../../lib/slugger';
import { isLoggedIn } from '../../lib/jwt';
import { showLoginPopup } from '../../lib/popup';
export type RoadmapRendererProps = { export type RoadmapRendererProps = {
resourceId: string; resourceId: string;
@ -104,6 +106,11 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) {
if (e.shiftKey) { if (e.shiftKey) {
e.preventDefault(); e.preventDefault();
if (!isLoggedIn()) {
showLoginPopup();
return;
}
updateTopicStatus( updateTopicStatus(
nodeId, nodeId,
isCurrentStatusLearning ? 'pending' : 'learning', isCurrentStatusLearning ? 'pending' : 'learning',
@ -111,6 +118,11 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) {
return; return;
} else if (e.altKey) { } else if (e.altKey) {
e.preventDefault(); e.preventDefault();
if (!isLoggedIn()) {
showLoginPopup();
return;
}
updateTopicStatus(nodeId, isCurrentStatusSkipped ? 'pending' : 'skipped'); updateTopicStatus(nodeId, isCurrentStatusSkipped ? 'pending' : 'skipped');
return; return;
} }
@ -143,6 +155,10 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) {
return; return;
} }
if (!isLoggedIn()) {
showLoginPopup();
return;
}
const isCurrentStatusDone = targetGroup?.classList.contains('done'); const isCurrentStatusDone = targetGroup?.classList.contains('done');
updateTopicStatus(nodeId, isCurrentStatusDone ? 'pending' : 'done'); updateTopicStatus(nodeId, isCurrentStatusDone ? 'pending' : 'done');
}, []); }, []);

Loading…
Cancel
Save