diff --git a/src/components/GenerateCourse/AICourseContent.tsx b/src/components/GenerateCourse/AICourseContent.tsx index a5254ef2f..3234c0322 100644 --- a/src/components/GenerateCourse/AICourseContent.tsx +++ b/src/components/GenerateCourse/AICourseContent.tsx @@ -19,6 +19,7 @@ import { AICourseSidebarModuleList } from './AICourseSidebarModuleList'; import { AILimitsPopup } from './AILimitsPopup'; import { AICourseOutlineView } from './AICourseOutlineView'; import { AICourseRoadmapView } from './AICourseRoadmapView'; +import { AICourseFooter } from './AICourseFooter'; type AICourseContentProps = { courseSlug?: string; @@ -35,6 +36,7 @@ export function AICourseContent(props: AICourseContentProps) { const [showUpgradeModal, setShowUpgradeModal] = useState(false); const [showAILimitsPopup, setShowAILimitsPopup] = useState(false); + const [isAIChatsOpen, setIsAIChatsOpen] = useState(true); const [activeModuleIndex, setActiveModuleIndex] = useState(0); const [activeLessonIndex, setActiveLessonIndex] = useState(0); @@ -412,6 +414,8 @@ export function AICourseContent(props: AICourseContentProps) { onGoToNextLesson={goToNextLesson} key={`${courseSlug}-${activeModuleIndex}-${activeLessonIndex}`} onUpgrade={() => setShowUpgradeModal(true)} + isAIChatsOpen={isAIChatsOpen} + setIsAIChatsOpen={setIsAIChatsOpen} /> )} @@ -445,14 +449,7 @@ export function AICourseContent(props: AICourseContentProps) { /> )} -
- AI can make mistakes, check important info. -
+ diff --git a/src/components/GenerateCourse/AICourseFooter.tsx b/src/components/GenerateCourse/AICourseFooter.tsx new file mode 100644 index 000000000..26a5b9d47 --- /dev/null +++ b/src/components/GenerateCourse/AICourseFooter.tsx @@ -0,0 +1,19 @@ +import { cn } from '../../lib/classname'; + +type AICourseFooterProps = { + className?: string; +}; +export function AICourseFooter(props: AICourseFooterProps) { + const { className } = props; + + return ( +
+ AI can make mistakes, check important info. +
+ ); +} diff --git a/src/components/GenerateCourse/AICourseLesson.tsx b/src/components/GenerateCourse/AICourseLesson.tsx index 971b35463..899f8af12 100644 --- a/src/components/GenerateCourse/AICourseLesson.tsx +++ b/src/components/GenerateCourse/AICourseLesson.tsx @@ -5,6 +5,8 @@ import { ChevronRight, Loader2Icon, LockIcon, + MessageCircleIcon, + MessageCircleOffIcon, XIcon, } from 'lucide-react'; import { useEffect, useMemo, useState } from 'react'; @@ -28,6 +30,7 @@ import './AICourseLessonChat.css'; import { RegenerateLesson } from './RegenerateLesson'; import { TestMyKnowledgeAction } from './TestMyKnowledgeAction'; import { AICourseLessonChat } from './AICourseLessonChat'; +import { AICourseFooter } from './AICourseFooter'; type AICourseLessonProps = { courseSlug: string; @@ -44,6 +47,9 @@ type AICourseLessonProps = { onGoToNextLesson: () => void; onUpgrade: () => void; + + isAIChatsOpen: boolean; + setIsAIChatsOpen: (isAIChatsOpen: boolean) => void; }; export function AICourseLesson(props: AICourseLessonProps) { @@ -62,6 +68,9 @@ export function AICourseLesson(props: AICourseLessonProps) { onGoToNextLesson, onUpgrade, + + isAIChatsOpen, + setIsAIChatsOpen, } = props; const [isLoading, setIsLoading] = useState(true); @@ -210,7 +219,12 @@ export function AICourseLesson(props: AICourseLessonProps) { return (
-
+
{(isGenerating || isLoading) && (
@@ -269,6 +283,17 @@ export function AICourseLesson(props: AICourseLessonProps) { )} + +
)}
@@ -390,19 +415,20 @@ export function AICourseLesson(props: AICourseLessonProps) {
-
- AI can make mistakes, check important info. -
+
- + {isAIChatsOpen && ( + setIsAIChatsOpen(false)} + /> + )} ); } diff --git a/src/components/GenerateCourse/AICourseLessonChat.tsx b/src/components/GenerateCourse/AICourseLessonChat.tsx index 3b5be326a..3a3100bdc 100644 --- a/src/components/GenerateCourse/AICourseLessonChat.tsx +++ b/src/components/GenerateCourse/AICourseLessonChat.tsx @@ -6,6 +6,7 @@ import { HelpCircle, LockIcon, Send, + XIcon, } from 'lucide-react'; import { useCallback, @@ -44,13 +45,22 @@ type AICourseLessonChatProps = { lessonTitle: string; onUpgradeClick: () => void; isDisabled?: boolean; + + onClose: () => void; }; export function AICourseLessonChat(props: AICourseLessonChatProps) { - const { courseSlug, moduleTitle, lessonTitle, onUpgradeClick, isDisabled } = - props; + const { + courseSlug, + moduleTitle, + lessonTitle, + onUpgradeClick, + isDisabled, + onClose, + } = props; const toast = useToast(); + const containerRef = useRef(null); const scrollareaRef = useRef(null); const [courseAIChatHistory, setCourseAIChatHistory] = useState< @@ -193,9 +203,24 @@ export function AICourseLessonChat(props: AICourseLessonChatProps) { scrollToBottom(); }, []); + useOutsideClick(containerRef, () => { + onClose(); + }); + return ( -
-
+
+
+
+ +

Course AI