import { apiRequest } from '@/shared/api/httpClient';

export interface GuardianStudentRow {
  readonly id: string;
  readonly guardianId: string;
  readonly studentId: string;
  readonly relationship?: string | null;
  readonly guardian?: { id: string; firstName?: string | null; lastName?: string | null } | null;
  readonly student?: { id: string; firstName?: string | null; lastName?: string | null } | null;
}

export function listGuardianStudents(
  studentId?: string,
): Promise<{ rows: GuardianStudentRow[] }> {
  const qs = studentId ? `?studentId=${encodeURIComponent(studentId)}` : '';
  return apiRequest<{ rows: GuardianStudentRow[] }>(`/guardian_students${qs}`);
}
