Spaces:
Runtime error
Runtime error
File size: 1,631 Bytes
2c6caad 4aadf35 2c6caad | 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 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<AdminSection[]> {
const { data } = await api.get<AdminSection[]>('/admin/sections');
return data;
},
async getRoster(sectionId: number, date?: string): Promise<AdminRosterItem[]> {
const { data } = await api.get<AdminRosterItem[]>(
`/admin/sections/${sectionId}/roster`,
{ params: date ? { date } : {} },
);
return data;
},
async swipe(
sectionId: number,
records: AdminAttendanceRecord[],
subjectId?: number,
): Promise<AdminSwipeResponse> {
const { data } = await api.post<AdminSwipeResponse>(
'/admin/attendance/swipe',
{ section_id: sectionId, subject_id: subjectId, records },
);
return data;
},
async batchToggle(
sectionId: number,
records: AdminAttendanceRecord[],
date?: string,
subjectId?: number,
): Promise<AdminSwipeResponse> {
const { data } = await api.post<AdminSwipeResponse>(
'/admin/attendance/batch-toggle',
{ section_id: sectionId, subject_id: subjectId, records },
{ params: date ? { date } : {} },
);
return data;
},
};
|