27 lines
738 B
TypeScript
Raw Normal View History

2024-11-17 16:00:30 +00:00
/* Copyright (C) 2024 Manuel Bustillo*/
2024-11-17 16:34:58 +01:00
import { Group } from '@/app/lib/definitions';
export function loadGroups(onLoad?: (groups: Group[]) => void) {
fetch("/api/groups.json")
.then((response) => response.json())
.then((data) => {
onLoad && onLoad(data.map((record: any) => {
return ({
id: record.id,
name: record.name,
color: record.color,
attendance: {
considered: record.considered,
invited: record.invited,
confirmed: record.confirmed,
tentative: record.tentative,
declined: record.declined,
total: record.total,
}
});
}));
}, (error) => {
return [];
});
}