import api from './api'; export interface AdminSection { id: number; name: string } export interface AdminRosterItem { id: number; name: string; lastname: string; card_id: string | null; phone_number: string | null; sex: 'M' | 'F' | null; already_checked_in: boolean; entrance_logged: boolean; } export interface AdminAttendanceRecord { student_id: number; present: boolean } export interface AdminSwipeResponse { created: number; total: number; skipped: number[] } export const adminAttendanceService = { async listSections(): Promise { const { data } = await api.get('/admin/sections'); return data; }, async getRoster(sectionId: number, date?: string): Promise { const { data } = await api.get( `/admin/sections/${sectionId}/roster`, { params: date ? { date } : {} }, ); return data; }, async swipe( sectionId: number, records: AdminAttendanceRecord[], subjectId?: number, ): Promise { const { data } = await api.post( '/admin/attendance/swipe', { section_id: sectionId, subject_id: subjectId, records }, ); return data; }, async batchToggle( sectionId: number, records: AdminAttendanceRecord[], date?: string, subjectId?: number, ): Promise { const { data } = await api.post( '/admin/attendance/batch-toggle', { section_id: sectionId, subject_id: subjectId, records }, { params: date ? { date } : {} }, ); return data; }, };