diff --git a/src/components/GenerateCourse/AICourseContent.tsx b/src/components/GenerateCourse/AICourseContent.tsx index 462404049..ba484cd76 100644 --- a/src/components/GenerateCourse/AICourseContent.tsx +++ b/src/components/GenerateCourse/AICourseContent.tsx @@ -513,6 +513,10 @@ export function AICourseContent(props: AICourseContentProps) { setExpandedModules={setExpandedModules} onUpgradeClick={() => setShowUpgradeModal(true)} viewMode={viewMode} + isForkable={isForkable} + onForkCourse={() => { + setIsForkingCourse(true); + }} /> )} diff --git a/src/components/GenerateCourse/AICourseLesson.tsx b/src/components/GenerateCourse/AICourseLesson.tsx index dd4a443a2..9ef6e0a49 100644 --- a/src/components/GenerateCourse/AICourseLesson.tsx +++ b/src/components/GenerateCourse/AICourseLesson.tsx @@ -40,6 +40,7 @@ import { ResizablePanel, ResizablePanelGroup, } from './Resizeable'; +import { showLoginPopup } from '../../lib/popup'; function getQuestionsFromResult(result: string) { const matchedQuestions = result.match( @@ -301,13 +302,13 @@ export function AICourseLesson(props: AICourseLessonProps) { )} -
+
Lesson {activeLessonIndex + 1} of {totalLessons}
{!isGenerating && !isLoading && ( -
+
)} diff --git a/src/components/GenerateCourse/AICourseLessonChat.tsx b/src/components/GenerateCourse/AICourseLessonChat.tsx index 4e6fc081e..442fb553a 100644 --- a/src/components/GenerateCourse/AICourseLessonChat.tsx +++ b/src/components/GenerateCourse/AICourseLessonChat.tsx @@ -34,6 +34,7 @@ import { queryClient } from '../../stores/query-client'; import { billingDetailsOptions } from '../../queries/billing'; import { ResizablePanel } from './Resizeable'; import { Spinner } from '../ReactIcons/Spinner'; +import { showLoginPopup } from '../../lib/popup'; export type AllowedAIChatRole = 'user' | 'assistant'; export type AIChatHistoryType = { @@ -324,8 +325,8 @@ export function AICourseLessonChat(props: AICourseLessonChatProps) { className="relative flex items-start border-t border-gray-200 text-sm" onSubmit={handleChatSubmit} > - {isLimitExceeded && ( -
+ {isLimitExceeded && isLoggedIn() && ( +
)} + {!isLoggedIn() && ( +
+ +

Please login to continue

+ +
+ )} void; @@ -21,6 +22,10 @@ export function AICourseLimit(props: AICourseLimitProps) { const { data: userBillingDetails, isLoading: isBillingDetailsLoading } = useQuery(billingDetailsOptions(), queryClient); + if (!isLoggedIn()) { + return null; + } + if (isLoading || !limits || isBillingDetailsLoading || !userBillingDetails) { return (
diff --git a/src/components/GenerateCourse/AICourseOutlineHeader.tsx b/src/components/GenerateCourse/AICourseOutlineHeader.tsx index 386efc7cb..d099bfa83 100644 --- a/src/components/GenerateCourse/AICourseOutlineHeader.tsx +++ b/src/components/GenerateCourse/AICourseOutlineHeader.tsx @@ -69,11 +69,6 @@ export function AICourseOutlineHeader(props: AICourseOutlineHeaderProps) { +
+ )} + + {error && !isGenerating && !isLoggedIn() && (
-

+

{error || 'Something went wrong'}

diff --git a/src/components/GenerateCourse/GenerateAICourse.tsx b/src/components/GenerateCourse/GenerateAICourse.tsx index 8b901ad94..092cc0964 100644 --- a/src/components/GenerateCourse/GenerateAICourse.tsx +++ b/src/components/GenerateCourse/GenerateAICourse.tsx @@ -7,6 +7,7 @@ import { generateCourse } from '../../helper/generate-ai-course'; import { useQuery } from '@tanstack/react-query'; import { getAiCourseOptions } from '../../queries/ai-course'; import { queryClient } from '../../stores/query-client'; +import { useAuth } from '../../hooks/use-auth'; type GenerateAICourseProps = {}; @@ -20,6 +21,7 @@ export function GenerateAICourse(props: GenerateAICourseProps) { const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(''); + const currentUser = useAuth(); const [courseId, setCourseId] = useState(''); const [courseSlug, setCourseSlug] = useState(''); @@ -150,6 +152,7 @@ export function GenerateAICourse(props: GenerateAICourseProps) { return ( { - if (!isLoggedIn()) { - window.location.href = '/ai'; - } - }, [isLoggedIn]); - useEffect(() => { if (!aiCourse) { return; diff --git a/src/components/GenerateCourse/RegenerateLesson.tsx b/src/components/GenerateCourse/RegenerateLesson.tsx index 507d106b9..5bd468f51 100644 --- a/src/components/GenerateCourse/RegenerateLesson.tsx +++ b/src/components/GenerateCourse/RegenerateLesson.tsx @@ -4,6 +4,8 @@ import { useOutsideClick } from '../../hooks/use-outside-click'; import { cn } from '../../lib/classname'; import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal'; import { ModifyCoursePrompt } from './ModifyCoursePrompt'; +import { isLoggedIn } from '../../lib/jwt'; +import { showLoginPopup } from '../../lib/popup'; type RegenerateLessonProps = { onRegenerateLesson: (prompt?: string) => void; @@ -39,6 +41,11 @@ export function RegenerateLesson(props: RegenerateLessonProps) { onClose={() => setShowPromptModal(false)} onSubmit={(prompt) => { setShowPromptModal(false); + if (!isLoggedIn()) { + showLoginPopup(); + return; + } + if (isForkable) { onForkCourse(); return; @@ -49,7 +56,7 @@ export function RegenerateLesson(props: RegenerateLessonProps) { /> )} -
+