Integrated attendance system

This commit is contained in:
2025-11-25 13:11:08 -05:00
parent 0a718d36c2
commit ca4f6a811f
5 changed files with 75 additions and 25 deletions

View File

@@ -33,7 +33,7 @@ export async function getMonthCalendarEvents(viewedMonth: Date): Promise<Calenda
// Base range: first and last day of the month
const firstOfMonth = new Date(year, month, 1);
const lastOfMonth = new Date(year, month + 1, 0);
const lastOfMonth = new Date(year, month + 1, 0);
// --- Apply 10 day padding ---
const start = new Date(firstOfMonth);
@@ -44,7 +44,7 @@ export async function getMonthCalendarEvents(viewedMonth: Date): Promise<Calenda
end.setHours(23, 59, 59, 999);
const from = start.toISOString();
const to = end.toISOString();
const to = end.toISOString();
const url = `${addr}/calendar?from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}`;
@@ -60,7 +60,7 @@ export async function getMonthCalendarEvents(viewedMonth: Date): Promise<Calenda
export async function getCalendarEvent(id: number): Promise<CalendarEvent> {
let res = await fetch(`${addr}/calendar/${id}`);
if(res.ok) {
if (res.ok) {
return await res.json();
} else {
throw new Error(`Failed to fetch event: ${res.status} ${res.statusText}`);
@@ -84,5 +84,14 @@ export async function adminCancelCalendarEvent(eventID: number) {
}
export async function setCalendarEventAttendance(eventID: number, state: CalendarAttendance) {
let res = await fetch(`${addr}/calendar/ ${eventID}/attendance?state=${state}`, {
method: "POST",
credentials: "include",
});
if (res.ok) {
return;
} else {
throw new Error(`Failed to set attendance: ${res.status} ${res.statusText}`);
}
}