/* 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 []; }); }