import { useState, type ComponentType } from "react"; import { Link } from "react-router-dom"; import { Activity, AlertTriangle, Brain, Gauge, Users } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Badge } from "@/components/ui/badge"; import { useAdaptiveDashboard, useAdaptiveStudents } from "@/hooks/queries/useAdaptiveEngine"; import type { AdaptiveDashboardMetrics, AdaptiveEngineStudentRow } from "@/types"; import { LineChart, Line, ResponsiveContainer } from "recharts"; export default function AdaptiveDashboard() { const [page, setPage] = useState(1); const limit = 10; const { data: metrics } = useAdaptiveDashboard(); const { data: studentsPage, isLoading } = useAdaptiveStudents({ page, limit }); const m: AdaptiveDashboardMetrics = metrics ?? { active_students: 0, engine_phase: "—", decisions_today: 0, average_improvement: 0, alerts_count: 0, }; const rows: AdaptiveEngineStudentRow[] = studentsPage?.data ?? []; const total = studentsPage?.pagination?.total ?? rows.length; const pages = Math.max(1, Math.ceil(total / limit)); return (

Adaptive engine

Live decisions and learner risk

Students Signals, pacing, and trajectory {isLoading ? (

Loading…

) : ( <>
Name Subject Current level Target Days active Last decision Progress Alert {rows.map((r) => ( {r.name} {r.subject} {r.current_level} {r.target} {r.days_active} {new Date(r.last_decision_at).toLocaleString()} {r.alert ? ( {r.alert} ) : ( "—" )} ))}
Page {page} of {pages}
)}
); } function MetricCard({ icon: Icon, label, value, }: { icon: ComponentType<{ className?: string }>; label: string; value: string; }) { return ( {label}
{value}
); } function Spark({ vals }: { vals: number[] }) { const data = (vals?.length ? vals : [0, 0, 0, 0, 0]).map((v, i) => ({ i, v })); return (
); }