DocDoeAI / src /lib /api /dashboard.ts
asnannp's picture
deploy: sync backend to Space root (learn-lesson HF cache fix)
65d68f5
Raw History Blame Contribute Delete
1.41 kB
import { apiGet } from "@/lib/api/client";
export type DashboardMaterials = {
total: number;
ready: number;
processing: number;
needs_review: number;
};
export type DashboardSource = {
id: string;
title: string;
subject: string;
status: "ready";
material_type?: string | null;
source_type?: string | null;
};
export type DashboardResult = {
id: string;
label: string;
source_title: string;
created_at: string | null;
};
export type DashboardStudyFocus = {
exam: string | null;
subject: string | null;
time_left: string | null;
goal: string | null;
weak_areas: string[];
};
export type DashboardVideoLessons = {
total: number;
ready: number;
in_progress: number;
};
export type DashboardRecommendedAction = {
kind: "upload" | "wait" | "revise" | "generate" | "practice";
label: string;
};
export type StudentDashboard = {
materials: DashboardMaterials;
recent_source: DashboardSource | null;
recent_results: DashboardResult[];
study_focus: DashboardStudyFocus;
video_lessons: DashboardVideoLessons;
recommended_action: DashboardRecommendedAction;
};
/** Fetch the aggregated student dashboard snapshot. User-scoped. */
export async function getStudentDashboard(options?: {
signal?: AbortSignal;
}): Promise<StudentDashboard> {
return apiGet<StudentDashboard>("/dashboard/student", {
signal: options?.signal,
timeoutMs: 15000,
});
}