'use client' import { pageGridClass } from '@/components/layout/FeaturePage' import { LearningShell, LearningEmptyState, LearningErrorState, LearningSkeleton, } from '@/components/learning/LearningShell' import Link from 'next/link' import { useTranslation } from 'react-i18next' import { ArrowRight, Compass, Plus, Sparkles } from 'lucide-react' import type { MasteryTopic } from '@/lib/learning-api' import { MASTERY_OPENING_SCOPE, masteryOpeningMessage, masterySessionRoute, } from '@/lib/mastery-mode' import { setPendingPrompt } from '@/lib/pending-prompt' import { libraryItemKey } from '@/lib/learning-library' import { topicDisplayName } from './format' import { TopicMapCard } from './TopicMapCard' export function TopicAtlas({ topics, loading, error, onCreate, onRetry, }: { topics: MasteryTopic[] loading: boolean error: string | null onCreate: (trigger: HTMLButtonElement) => void onRetry: () => void }) { const { t } = useTranslation() const activeTopics = topics.filter(topic => topic.metadata.status === 'active') const dueCount = activeTopics.reduce( (count, topic) => count + topic.reviews.filter(review => review.due).length, 0 ) const dueTopics = activeTopics.filter(topic => topic.reviews.some(review => review.due)) const firstDueTopic = dueTopics[0] return ( onCreate(event.currentTarget)} className="inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-xl bg-[var(--primary)] px-5 text-sm font-medium text-[var(--primary-foreground)] transition hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2" > {t('New topic')} } > {dueCount > 0 && (
{t('{{beacons}} reviews are due across {{count}} topics', { beacons: dueCount, count: dueTopics.length, })}
{t('Open their maps for a short review without losing your main route.')}
{firstDueTopic && ( setPendingPrompt( masteryOpeningMessage('review', t, { dueTitles: firstDueTopic.reviews .filter(review => review.due) .slice(0, 5) .map(review => review.knowledge_point_name), }), MASTERY_OPENING_SCOPE ) } href={masterySessionRoute(firstDueTopic.path_id, 'review', firstDueTopic.content_workspace_id ?? '')} className="inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-xl bg-[var(--primary)] px-3.5 text-xs font-semibold text-white transition hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-2 " > {t('Start review')}: {topicDisplayName(firstDueTopic, t)} )}
)} {error && } {loading ? ( ) : activeTopics.length > 0 ? (
{activeTopics.map(topic => ( ))}
) : !error ? ( } title={t('Your atlas is still uncharted')} description={t( 'Tell DeepTutor what you want to learn, mix in your books, notes, and knowledge bases, and it will draft the first outline.' )} action={ } /> ) : null}
) }