diff --git a/src/components/GenerateCourse/AICourseContent.tsx b/src/components/GenerateCourse/AICourseContent.tsx index 3234c0322..ce9b6085d 100644 --- a/src/components/GenerateCourse/AICourseContent.tsx +++ b/src/components/GenerateCourse/AICourseContent.tsx @@ -6,8 +6,11 @@ import { Menu, X, Map, + MessageCircle, + MessageCircleOffIcon, + MessageCircleIcon, } from 'lucide-react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { type AiCourse } from '../../lib/ai'; import { cn } from '../../lib/classname'; import { useIsPaidUser } from '../../queries/billing'; @@ -208,6 +211,12 @@ export function AICourseContent(props: AICourseContentProps) { const isViewingLesson = viewMode === 'module'; + useEffect(() => { + if (window && window?.innerWidth < 1024 && isAIChatsOpen) { + setIsAIChatsOpen(false); + } + }, []); + return (
{modals} @@ -236,6 +245,19 @@ export function AICourseContent(props: AICourseContentProps) { /> + {viewMode === 'module' && ( + + )} + + { generateAiCourseContent(true, prompt); @@ -283,17 +294,6 @@ export function AICourseLesson(props: AICourseLessonProps) { )} - - )} @@ -419,16 +419,16 @@ export function AICourseLesson(props: AICourseLessonProps) { - {isAIChatsOpen && ( - setIsAIChatsOpen(false)} - /> - )} + setIsAIChatsOpen(false)} + isAIChatsOpen={isAIChatsOpen} + setIsAIChatsOpen={setIsAIChatsOpen} + /> ); } diff --git a/src/components/GenerateCourse/AICourseLessonChat.tsx b/src/components/GenerateCourse/AICourseLessonChat.tsx index 3a3100bdc..64aa4d3a5 100644 --- a/src/components/GenerateCourse/AICourseLessonChat.tsx +++ b/src/components/GenerateCourse/AICourseLessonChat.tsx @@ -47,6 +47,9 @@ type AICourseLessonChatProps = { isDisabled?: boolean; onClose: () => void; + + isAIChatsOpen: boolean; + setIsAIChatsOpen: (isAIChatsOpen: boolean) => void; }; export function AICourseLessonChat(props: AICourseLessonChatProps) { @@ -57,10 +60,12 @@ export function AICourseLessonChat(props: AICourseLessonChatProps) { onUpgradeClick, isDisabled, onClose, + + isAIChatsOpen, + setIsAIChatsOpen, } = props; const toast = useToast(); - const containerRef = useRef(null); const scrollareaRef = useRef(null); const [courseAIChatHistory, setCourseAIChatHistory] = useState< @@ -203,124 +208,127 @@ export function AICourseLessonChat(props: AICourseLessonChatProps) { scrollToBottom(); }, []); - useOutsideClick(containerRef, () => { - onClose(); - }); - return ( -
-
+ <> + {isAIChatsOpen && ( +
+ )}
- +
+ -
-

Course AI

-
+
+

Course AI

+
-
-
-
-
- {courseAIChatHistory.map((chat, index) => { - return ( - <> - - - {chat.isDefault && ( -
-
- {capabilities.map((capability, index) => ( - - ))} +
+
+
+
+ {courseAIChatHistory.map((chat, index) => { + return ( + <> + + + {chat.isDefault && ( +
+
+ {capabilities.map((capability, index) => ( + + ))} +
-
- )} - - ); - })} - - {isStreamingMessage && !streamedMessage && ( - - )} - - {streamedMessage && ( - - )} + )} + + ); + })} + + {isStreamingMessage && !streamedMessage && ( + + )} + + {streamedMessage && ( + + )} +
-
-
- {isLimitExceeded && ( -
- -

- Limit reached for today - {isPaidUser ? '. Please wait until tomorrow.' : ''} -

- {!isPaidUser && ( - - )} -
- )} - setMessage(e.target.value)} - autoFocus={true} - onKeyDown={(e) => { - if (e.key === 'Enter' && !e.shiftKey) { - handleChatSubmit(e as unknown as FormEvent); - } - }} - /> - - + {isLimitExceeded && ( +
+ +

+ Limit reached for today + {isPaidUser ? '. Please wait until tomorrow.' : ''} +

+ {!isPaidUser && ( + + )} +
+ )} + setMessage(e.target.value)} + autoFocus={true} + onKeyDown={(e) => { + if (e.key === 'Enter' && !e.shiftKey) { + handleChatSubmit(e as unknown as FormEvent); + } + }} + /> + + +
-
+ ); }