Manuel Bustillo 82f5dd6c64
Some checks failed
Check usage of free licenses / build-static-assets (pull_request) Successful in 44s
Add copyright notice / copyright_notice (pull_request) Successful in 54s
Playwright Tests / test (pull_request) Failing after 8m28s
Update navigation to accept the slug as part of the URL
2024-12-01 18:02:25 +01:00

28 lines
786 B
TypeScript

/* Copyright (C) 2024 Manuel Bustillo*/
import { Group } from '@/app/lib/definitions';
import { getSlug } from '../lib/utils';
export function loadGroups(onLoad?: (groups: Group[]) => void) {
fetch(`/api/${getSlug()}/groups`)
.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 [];
});
}