import { useEffect, useMemo, useState } from 'react'; import { Link } from 'react-router-dom'; import { Loader, Rocket, ArrowLeft, ChevronRight, CheckCircle2, Circle, Sparkles, ListChecks, PartyPopper, } from 'lucide-react'; import Card from '../components/ui/Card'; import Button from '../components/ui/Button'; import Tag from '../components/ui/Tag'; import { useApp } from '../store/AppContext'; import { getOnboardingPlan, getCompletedThemes, getOrGenerateOnboardingOverview, markThemeCompleted, computeOnboardingProgress, } from '../lib/onboardingService'; function normalizeContent(raw) { if (!raw) return null; if (typeof raw === 'string') { try { return JSON.parse(raw); } catch { return null; } } return raw; } // ── Per-theme overview view ────────────────────────────────────────────────── function OnboardingThemeView({ theme, topics, done, onBack, onDone }) { const [record, setRecord] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [marked, setMarked] = useState(done); useEffect(() => { let cancelled = false; setLoading(true); setError(null); getOrGenerateOnboardingOverview(theme, topics) .then((rec) => { if (!cancelled) setRecord(rec); }) .catch((err) => { if (!cancelled) setError(err.message || 'Failed to load the overview.'); }) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, [theme]); // eslint-disable-line react-hooks/exhaustive-deps const content = normalizeContent(record?.content); const handleDone = async () => { if (marked) return; setMarked(true); await onDone(theme); }; return (
Preparing this theme…
This may take 10–30 seconds the first time — the result is cached.
Could not load this theme
{error}
{content.what_it_is}
{content.why_it_matters}
Loading your onboarding track…
Could not load the onboarding track
{error}
There are no themes to introduce yet. Once the knowledge base has content, your 5-day onboarding track will appear here.
A light, self-paced tour of every theme at Respellion, spread over about five days. It gives you the breadth you need to understand how we work day to day and week to week — you can go faster if you like.
{progress.allDone ? 'Onboarding complete' : `${progress.daysCompleted}/${progress.dayCount} days complete`}
{progress.themesDone} of {progress.themesTotal} themes done
You've been introduced to every theme. You're ready to pick up a first assignment — and you can revisit any theme below whenever you want a refresher.