fix: add a default subject

fix/default-subject
Arik Chakma 4 days ago
parent 6525b1bdee
commit 21046347da
  1. 30
      src/components/TopicDetail/TopicDetailAI.tsx

@ -7,6 +7,7 @@ import { queryClient } from '../../stores/query-client';
import { isLoggedIn, removeAuthToken } from '../../lib/jwt'; import { isLoggedIn, removeAuthToken } from '../../lib/jwt';
import { import {
BotIcon, BotIcon,
ChevronRightIcon,
Gift, Gift,
Loader2Icon, Loader2Icon,
LockIcon, LockIcon,
@ -220,9 +221,12 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
tokenUsage?.used || 0, tokenUsage?.used || 0,
tokenUsage?.limit || 0, tokenUsage?.limit || 0,
); );
const hasSubjects =
roadmapTreeMapping?.subjects && roadmapTreeMapping?.subjects?.length > 0;
const hasChatHistory = aiChatHistory.length > 1; const hasChatHistory = aiChatHistory.length > 1;
const nodeTextParts = roadmapTreeMapping?.text?.split('>') || [];
const hasSubjects =
(roadmapTreeMapping?.subjects &&
roadmapTreeMapping?.subjects?.length > 0) ||
nodeTextParts.length > 1;
return ( return (
<div className="relative mt-4 flex grow flex-col overflow-hidden rounded-lg border border-gray-200"> <div className="relative mt-4 flex grow flex-col overflow-hidden rounded-lg border border-gray-200">
@ -261,6 +265,26 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
</a> </a>
); );
})} })}
{roadmapTreeMapping?.subjects?.length === 0 && (
<a
target="_blank"
href={`/ai/search?term=${roadmapTreeMapping?.text}&difficulty=beginner&src=topic`}
className="flex items-center gap-1 rounded-md border border-gray-300 bg-gray-100 px-2 py-1 hover:bg-gray-200 hover:text-black"
>
{nodeTextParts.map((text, index) => (
<>
<span key={text} className="flex items-center">
{text}
</span>
{index !== nodeTextParts.length - 1 && (
<ChevronRightIcon className="h-3 w-3 text-gray-400" />
)}
</>
))}
</a>
)}
</div> </div>
</div> </div>
)} )}
@ -295,7 +319,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
<div className="flex gap-1.5"> <div className="flex gap-1.5">
{hasChatHistory && ( {hasChatHistory && (
<button <button
className="rounded-md bg-white py-2 px-2 text-xs font-medium text-black hover:bg-gray-200" className="rounded-md bg-white px-2 py-2 text-xs font-medium text-black hover:bg-gray-200"
onClick={() => { onClick={() => {
setAiChatHistory(defaultChatHistory); setAiChatHistory(defaultChatHistory);
}} }}

Loading…
Cancel
Save