/* Copyright (C) 2024 Manuel Bustillo*/ 'use client'; import TableOfContents from '../components/table-of-contents'; import React, { useState } from 'react'; import { Group } from '@/app/lib/definitions'; export default function GroupsTable() { const [groups, setGroups] = useState>([]); const [groupsLoaded, setGroupsLoaded] = useState(false); function loadGroups() { fetch("/api/groups") .then((response) => response.json()) .then((data) => { setGroups(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, } }); })); setGroupsLoaded(true); }, (error) => { return []; }); } !groupsLoaded && loadGroups(); return ( ( {group.name}
{group.attendance?.confirmed} {group.attendance?.tentative} {group.attendance?.invited} {group.attendance?.declined} {group.attendance?.considered} {group.attendance?.total} )} /> ) }