From 29dc2afc7f3e684b2033c896f461328b83d23ca7 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 2 May 2025 05:24:32 +0100 Subject: [PATCH] Improve topic popup --- .astro/types.d.ts | 1 - src/components/TopicDetail/TopicDetail.tsx | 6 +- src/components/TopicDetail/TopicDetailAI.tsx | 56 +++++++++++++------ .../TopicDetail/TopicDetailsTabs.tsx | 6 +- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/.astro/types.d.ts b/.astro/types.d.ts index 03d7cc43f..f964fe0cf 100644 --- a/.astro/types.d.ts +++ b/.astro/types.d.ts @@ -1,2 +1 @@ /// -/// \ No newline at end of file diff --git a/src/components/TopicDetail/TopicDetail.tsx b/src/components/TopicDetail/TopicDetail.tsx index dd48af0c2..ccfad8c43 100644 --- a/src/components/TopicDetail/TopicDetail.tsx +++ b/src/components/TopicDetail/TopicDetail.tsx @@ -375,7 +375,7 @@ export function TopicDetail(props: TopicDetailProps) { )} {isLoading && ( -
+
-
+
{shouldShowAiTab && ( Help us Improve this Content diff --git a/src/components/TopicDetail/TopicDetailAI.tsx b/src/components/TopicDetail/TopicDetailAI.tsx index 36b488eaa..32380fd7c 100644 --- a/src/components/TopicDetail/TopicDetailAI.tsx +++ b/src/components/TopicDetail/TopicDetailAI.tsx @@ -14,10 +14,11 @@ import { queryClient } from '../../stores/query-client'; import { isLoggedIn, removeAuthToken } from '../../lib/jwt'; import { BotIcon, + Gift, Loader2Icon, LockIcon, - RotateCcwIcon, SendIcon, + Trash2 } from 'lucide-react'; import { showLoginPopup } from '../../lib/popup'; import { cn } from '../../lib/classname'; @@ -34,6 +35,7 @@ import type { ResourceType } from '../../lib/resource-progress'; import { getPercentage } from '../../lib/number'; import { roadmapTreeMappingOptions } from '../../queries/roadmap-tree'; import { defaultChatHistory } from './TopicDetail'; +import { AILimitsPopup } from '../GenerateCourse/AILimitsPopup'; type TopicDetailAIProps = { resourceId: string; @@ -67,7 +69,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) { const [message, setMessage] = useState(''); const [isStreamingMessage, setIsStreamingMessage] = useState(false); const [streamedMessage, setStreamedMessage] = useState(''); - + const [showAILimitsPopup, setShowAILimitsPopup] = useState(false); const { data: tokenUsage, isLoading } = useQuery( getAiCourseLimitOptions(), queryClient, @@ -234,10 +236,20 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
)} + {showAILimitsPopup && ( + setShowAILimitsPopup(false)} + onUpgrade={() => { + setShowAILimitsPopup(false); + onUpgrade(); + }} + /> + )} + {hasSubjects && ( -
-

- Complete the following courses on AI Tutor +
+

+ Complete the following AI Tutor courses

@@ -247,7 +259,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) { key={subject} target="_blank" href={`/ai/search?term=${subject}&difficulty=beginner&src=topic`} - className="rounded-md border px-1.5" + className="flex items-center bg-gray-100 gap-1 gap-2 rounded-md border border-gray-300 px-2 py-1 hover:bg-gray-200 hover:text-black" > {subject} @@ -259,13 +271,16 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
{hasSubjects && ( - - or start chatting with AI + + + Chat with AI )} @@ -280,29 +295,36 @@ export function TopicDetailAI(props: TopicDetailAIProps) { )} {!isDataLoading && ( -
+
{hasChatHistory && ( )} {!isPaidUser && ( <> + -

- {usagePercentage}% used -

)}
diff --git a/src/components/TopicDetail/TopicDetailsTabs.tsx b/src/components/TopicDetail/TopicDetailsTabs.tsx index 3080337fd..6368a7753 100644 --- a/src/components/TopicDetail/TopicDetailsTabs.tsx +++ b/src/components/TopicDetail/TopicDetailsTabs.tsx @@ -42,16 +42,16 @@ function TopicDetailsTab(props: TopicDetailsTabProps) { return (