2024-11-13 08:16:10 +01:00
|
|
|
/* Copyright (C) 2024 Manuel Bustillo*/
|
|
|
|
|
|
|
|
'use client';
|
|
|
|
|
|
|
|
import { Group } from '@/app/lib/definitions';
|
2024-11-17 16:10:01 +01:00
|
|
|
import TableOfContents from '../components/table-of-contents';
|
2024-12-08 12:50:33 +01:00
|
|
|
import { PencilIcon, TrashIcon } from '@heroicons/react/24/outline';
|
|
|
|
import { destroyGroup } from '@/app/api/groups';
|
2024-11-13 08:16:10 +01:00
|
|
|
|
2024-12-08 12:50:33 +01:00
|
|
|
export default function GroupsTable({ groups, onUpdate, onEdit }: {
|
|
|
|
groups: Group[],
|
|
|
|
onUpdate: () => void,
|
|
|
|
onEdit: (group: Group) => void,
|
|
|
|
}) {
|
2024-11-13 08:16:10 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TableOfContents
|
2024-12-08 12:50:33 +01:00
|
|
|
headers={['Name', 'Color', 'Confirmed', 'Tentative', 'Pending', 'Declined', 'Considered', 'Total', 'Actions']}
|
2024-11-13 08:16:10 +01:00
|
|
|
caption='Groups'
|
|
|
|
elements={groups}
|
|
|
|
rowRender={(group) => (
|
|
|
|
<tr key={group.id} className="bg-white border-b odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800">
|
|
|
|
<td scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
|
|
{group.name}
|
|
|
|
</td>
|
|
|
|
<td className="px-6">
|
|
|
|
<div className="w-8 h-8 rounded-full" style={{ backgroundColor: group.color }}></div>
|
|
|
|
</td>
|
2024-11-13 08:47:50 +01:00
|
|
|
<td className="px-6 text-lg">
|
2024-11-13 08:16:10 +01:00
|
|
|
{group.attendance?.confirmed}
|
|
|
|
</td>
|
2024-11-13 08:47:50 +01:00
|
|
|
<td className="px-6 text-sm">
|
2024-11-13 08:16:10 +01:00
|
|
|
{group.attendance?.tentative}
|
|
|
|
</td>
|
2024-11-13 08:47:50 +01:00
|
|
|
<td className="px-6 text-sm">
|
2024-11-13 08:16:10 +01:00
|
|
|
{group.attendance?.invited}
|
|
|
|
</td>
|
2024-11-13 08:47:50 +01:00
|
|
|
<td className="px-6 text-sm">
|
2024-11-13 08:16:10 +01:00
|
|
|
{group.attendance?.declined}
|
|
|
|
</td>
|
2024-11-13 08:47:50 +01:00
|
|
|
<td className="px-6 text-sm">
|
2024-11-13 08:16:10 +01:00
|
|
|
{group.attendance?.considered}
|
|
|
|
</td>
|
2024-11-13 08:47:50 +01:00
|
|
|
<td className="px-6 text-sm">
|
2024-11-13 08:16:10 +01:00
|
|
|
{group.attendance?.total}
|
|
|
|
</td>
|
2024-12-08 12:50:33 +01:00
|
|
|
<td>
|
|
|
|
<div className="flex flex-row items-center">
|
|
|
|
<TrashIcon className='size-6 cursor-pointer' onClick={() => { destroyGroup(group, () => onUpdate()) }} />
|
|
|
|
<PencilIcon className='size-6 cursor-pointer' onClick={() => onEdit(group)} />
|
|
|
|
</div>
|
|
|
|
</td>
|
2024-11-13 08:16:10 +01:00
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|