@@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
33import { useKeydown } from '../../hooks/use-keydown' ;
44import { useOutsideClick } from '../../hooks/use-outside-click' ;
55import { markdownToHtml } from '../../lib/markdown' ;
6- import { Ban , Cog , FileText , X } from 'lucide-react' ;
6+ import { Ban , Cog , Contact , FileText , User , UserRound , X } from 'lucide-react' ;
77import { Spinner } from '../ReactIcons/Spinner' ;
88import type { RoadmapNodeDetails } from './GenerateRoadmap' ;
99import { getOpenAIKey , isLoggedIn , removeAuthToken } from '../../lib/jwt' ;
@@ -43,12 +43,10 @@ export function RoadmapTopicDetail(props: RoadmapTopicDetailProps) {
4343 const generateAiRoadmapTopicContent = async ( ) => {
4444 setIsLoading ( true ) ;
4545 setError ( '' ) ;
46- //
47- // if (topicLimitUsed >= topicLimit) {
48- // setError('Maximum limit reached');
49- // setIsLoading(false);
50- // return;
51- // }
46+
47+ if ( ! isLoggedIn ( ) ) {
48+ return ;
49+ }
5250
5351 if ( ! roadmapId || ! nodeTitle ) {
5452 setIsLoading ( false ) ;
@@ -133,50 +131,44 @@ export function RoadmapTopicDetail(props: RoadmapTopicDetailProps) {
133131 tabIndex = { 0 }
134132 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"
135133 >
136- < div className = "flex flex-col items-start gap-2 sm:flex-row" >
137- < span >
138- < span
139- className = { cn (
140- 'mr-0.5 inline-block rounded-xl border px-1.5 text-center text-sm tabular-nums text-gray-800' ,
141- {
142- 'animate-pulse border-zinc-300 bg-zinc-300 text-zinc-300' :
143- ! topicLimit ,
144- } ,
145- ) }
146- >
147- { topicLimitUsed } of { topicLimit }
148- </ span > { ' ' }
149- topics generated
150- </ span >
151- { ! isLoggedIn ( ) && (
152- < button
153- className = "rounded-xl border border-current px-1.5 py-0.5 text-left text-sm font-medium text-blue-500 sm:text-center"
154- onClick = { showLoginPopup }
155- >
156- Generate more by < span className = "font-semibold" > logging in</ span >
157- </ button >
158- ) }
159- { isLoggedIn ( ) && ! openAIKey && (
160- < button
161- className = "rounded-xl border border-current px-1.5 py-0.5 text-left text-sm font-medium text-blue-500 sm:text-center"
162- onClick = { onConfigureOpenAI }
163- >
164- Need to generate more?{ ' ' }
165- < span className = "font-semibold" > Click here.</ span >
166- </ button >
167- ) }
168- { isLoggedIn ( ) && openAIKey && (
169- < button
170- className = "flex items-center gap-1 rounded-xl border border-current px-1.5 py-0.5 text-left text-sm font-medium text-blue-500 sm:text-center"
171- onClick = { onConfigureOpenAI }
172- >
173- < Cog className = "-mt-0.5 inline-block h-4 w-4" />
174- Configure OpenAI Key
175- </ button >
176- ) }
177- </ div >
134+ { isLoggedIn ( ) && (
135+ < div className = "flex flex-col items-start gap-2 sm:flex-row" >
136+ < span >
137+ < span
138+ className = { cn (
139+ 'mr-0.5 inline-block rounded-xl border px-1.5 text-center text-sm tabular-nums text-gray-800' ,
140+ {
141+ 'animate-pulse border-zinc-300 bg-zinc-300 text-zinc-300' :
142+ ! topicLimit ,
143+ } ,
144+ ) }
145+ >
146+ { topicLimitUsed } of { topicLimit }
147+ </ span > { ' ' }
148+ topics generated
149+ </ span >
150+ { ! openAIKey && (
151+ < button
152+ className = "rounded-xl border border-current px-1.5 py-0.5 text-left text-sm font-medium text-blue-500 sm:text-center"
153+ onClick = { onConfigureOpenAI }
154+ >
155+ Need to generate more?{ ' ' }
156+ < span className = "font-semibold" > Click here.</ span >
157+ </ button >
158+ ) }
159+ { openAIKey && (
160+ < button
161+ className = "flex items-center gap-1 rounded-xl border border-current px-1.5 py-0.5 text-left text-sm font-medium text-blue-500 sm:text-center"
162+ onClick = { onConfigureOpenAI }
163+ >
164+ < Cog className = "-mt-0.5 inline-block h-4 w-4" />
165+ Configure OpenAI Key
166+ </ button >
167+ ) }
168+ </ div >
169+ ) }
178170
179- { isLoading && (
171+ { isLoggedIn ( ) && isLoading && (
180172 < div className = "mt-6 flex w-full justify-center" >
181173 < Spinner
182174 outerFill = "#d1d5db"
@@ -186,6 +178,22 @@ export function RoadmapTopicDetail(props: RoadmapTopicDetailProps) {
186178 </ div >
187179 ) }
188180
181+ { ! isLoggedIn ( ) && (
182+ < div className = "flex h-full flex-col items-center justify-center" >
183+ < Contact className = "h-14 w-14 text-gray-200 mb-3.5" />
184+ < h2 className = 'font-medium text-xl' > You must be logged in</ h2 >
185+ < p className = "text-base text-gray-400" >
186+ Sign up or login to generate topic content.
187+ </ p >
188+ < button
189+ className = "mt-3.5 text-base font-medium text-white bg-black px-3 py-2 rounded-md w-full max-w-[300px]"
190+ onClick = { showLoginPopup }
191+ >
192+ Sign up / Login
193+ </ button >
194+ </ div >
195+ ) }
196+
189197 { ! isLoading && ! error && (
190198 < >
191199 < div className = "mb-2" >
0 commit comments