Spaces:
Runtime error

Greg Claude Sonnet 4.6 commited on
Commit
2c6caad
·
1 Parent(s): e07ae49

feat(ta-01): add adminAttendanceService client

Browse files

Covers listSections, getRoster (with optional date), swipe, and batchToggle
against /api/v1/admin/* endpoints. Uses the same default axios instance as
teacherService so bearer auth is injected automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

frontend/src/services/adminAttendanceService.ts ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import api from './api';
2
+
3
+ export interface AdminSection { id: number; name: string }
4
+ export interface AdminRosterItem {
5
+ id: number;
6
+ name: string;
7
+ lastname: string;
8
+ card_id: string | null;
9
+ phone_number: string | null;
10
+ already_checked_in: boolean;
11
+ entrance_logged: boolean;
12
+ }
13
+ export interface AdminAttendanceRecord { student_id: number; present: boolean }
14
+ export interface AdminSwipeResponse { created: number; total: number; skipped: number[] }
15
+
16
+ export const adminAttendanceService = {
17
+ async listSections(): Promise<AdminSection[]> {
18
+ const { data } = await api.get<AdminSection[]>('/admin/sections');
19
+ return data;
20
+ },
21
+ async getRoster(sectionId: number, date?: string): Promise<AdminRosterItem[]> {
22
+ const { data } = await api.get<AdminRosterItem[]>(
23
+ `/admin/sections/${sectionId}/roster`,
24
+ { params: date ? { date } : {} },
25
+ );
26
+ return data;
27
+ },
28
+ async swipe(
29
+ sectionId: number,
30
+ records: AdminAttendanceRecord[],
31
+ subjectId?: number,
32
+ ): Promise<AdminSwipeResponse> {
33
+ const { data } = await api.post<AdminSwipeResponse>(
34
+ '/admin/attendance/swipe',
35
+ { section_id: sectionId, subject_id: subjectId, records },
36
+ );
37
+ return data;
38
+ },
39
+ async batchToggle(
40
+ sectionId: number,
41
+ records: AdminAttendanceRecord[],
42
+ date?: string,
43
+ subjectId?: number,
44
+ ): Promise<AdminSwipeResponse> {
45
+ const { data } = await api.post<AdminSwipeResponse>(
46
+ '/admin/attendance/batch-toggle',
47
+ { section_id: sectionId, subject_id: subjectId, records },
48
+ { params: date ? { date } : {} },
49
+ );
50
+ return data;
51
+ },
52
+ };