From cabbf511500fd6b4a0f0adc2643fb5e8fc502645 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Wed, 27 Mar 2024 20:25:53 +0000 Subject: [PATCH] Make topic detail visible for logged in users --- .../GenerateRoadmap/RoadmapTopicDetail.tsx | 108 ++++++++++-------- 1 file changed, 58 insertions(+), 50 deletions(-) diff --git a/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx b/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx index 66fc1461e..6c97389db 100644 --- a/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx +++ b/src/components/GenerateRoadmap/RoadmapTopicDetail.tsx @@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import { useKeydown } from '../../hooks/use-keydown'; import { useOutsideClick } from '../../hooks/use-outside-click'; import { markdownToHtml } from '../../lib/markdown'; -import { Ban, Cog, FileText, X } from 'lucide-react'; +import {Ban, Cog, Contact, FileText, User, UserRound, X} from 'lucide-react'; import { Spinner } from '../ReactIcons/Spinner'; import type { RoadmapNodeDetails } from './GenerateRoadmap'; import { getOpenAIKey, isLoggedIn, removeAuthToken } from '../../lib/jwt'; @@ -43,12 +43,10 @@ export function RoadmapTopicDetail(props: RoadmapTopicDetailProps) { const generateAiRoadmapTopicContent = async () => { setIsLoading(true); setError(''); - // - // if (topicLimitUsed >= topicLimit) { - // setError('Maximum limit reached'); - // setIsLoading(false); - // return; - // } + + if (!isLoggedIn()) { + return; + } if (!roadmapId || !nodeTitle) { setIsLoading(false); @@ -133,50 +131,44 @@ export function RoadmapTopicDetail(props: RoadmapTopicDetailProps) { tabIndex={0} className="fixed right-0 top-0 z-40 h-screen w-full overflow-y-auto bg-white p-4 focus:outline-0 sm:max-w-[600px] sm:p-6" > -
- - - {topicLimitUsed} of {topicLimit} - {' '} - topics generated - - {!isLoggedIn() && ( - - )} - {isLoggedIn() && !openAIKey && ( - - )} - {isLoggedIn() && openAIKey && ( - - )} -
+ {isLoggedIn() && ( +
+ + + {topicLimitUsed} of {topicLimit} + {' '} + topics generated + + {!openAIKey && ( + + )} + {openAIKey && ( + + )} +
+ )} - {isLoading && ( + {isLoggedIn() && isLoading && (
)} + {!isLoggedIn() && ( +
+ +

You must be logged in

+

+ Sign up or login to generate topic content. +

+ +
+ )} + {!isLoading && !error && ( <>