import { motion } from 'motion/react'; import { Check } from 'lucide-react'; import { useAppData } from '@/state/AppData'; import { unitColor, unitProgress } from '@/state/curriculum'; import { useNav } from '@/nav/Navigator'; import { SeyarMascot } from '@/mascots/SeyarMascot'; import { EmptyState, ErrorState, LoadingState, ProgressBar, Screen, ScreenHeader, Sep } from '@/components/ui'; import { ZigzagPath, zigzagPositions } from '@/components/ZigzagPath'; import { iconFor } from '@/components/NodeIcon'; import { toFa } from '@/lib/format'; /** نقشه‌ی فصل‌های پایه: هر خانه یک فصل است. */ export function MapScreen() { const { home, homeError, refreshHome, gradeTitle } = useAppData(); const nav = useNav(); const units = home?.units ?? []; const points = zigzagPositions(units.length, 150); const height = points.length ? points[points.length - 1].y + 200 : 400; const overall = Math.round(home?.stats.progressPercent ?? 0); return ( {gradeTitle && <>{gradeTitle}}{toFa(overall)}٪ از کلِ مسیر} color="#91ADC6" mascot={{ char: 'sigma', mood: overall > 0 ? 'happy' : 'idle' }} >
{!home ? ( homeError ? void refreshHome()} /> : ) : units.length === 0 ? ( ) : (
(units[i].nodes.some((n) => n.status !== 'locked') ? unitColor(i) : null)} /> {units.map((unit, i) => { const p = unitProgress(unit); const color = unitColor(i); const Icon = iconFor(unit.nodes[0]?.icon, i); const complete = p.total > 0 && p.done === p.total; return (
{unit.title}
{toFa(p.done)} از {toFa(p.total)} جزیره
); })}
= 100 ? 'excited' : 'happy'} size={72} bob />
{overall >= 100 ? 'همه رو تموم کردی! 🎉' : 'همین‌جا منتظرتم'}
)}
); }