File size: 723 Bytes
47203d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { apiFetch } from './client'
import type { InstructorStudent, StudentAttempt } from '../types'

export interface StudentDetail {
  id: string
  full_name: string
  email: string
  sessions: StudentAttempt[]
}

export async function getInstructorStudents(): Promise<InstructorStudent[]> {
  const res = await apiFetch('/api/instructor/students')
  if (!res.ok) {
    const err = await res.json()
    throw new Error(err.detail ?? 'Failed to load students')
  }
  return res.json()
}

export async function getStudentDetail(studentId: string): Promise<StudentDetail> {
  const res = await apiFetch(`/api/instructor/students/${studentId}`)
  if (!res.ok) throw new Error('Failed to load student')
  return res.json()
}