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) {
|
2024-11-30 20:21:19 +01:00
|
|
|
fetch("/api/default/groups")
|
2024-11-17 16:34:58 +01:00
|
|
|
.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 [];
|
|
|
|
});
|
|
|
|
}
|