diff --git a/app/[slug]/dashboard/guests/page.tsx b/app/[slug]/dashboard/guests/page.tsx index 20cc211..0b7a88d 100644 --- a/app/[slug]/dashboard/guests/page.tsx +++ b/app/[slug]/dashboard/guests/page.tsx @@ -56,14 +56,18 @@ export default function Page() { onHide={() => { setGuestBeingEdited(undefined) }} /> }> - setGuestBeingEdited(guest)} /> + setGuestBeingEdited(guest)} + />
- + }> - + setGroupBeingEdited(group)} + />
diff --git a/app/api/groups.tsx b/app/api/groups.tsx index 1ffc0b5..8c8081e 100644 --- a/app/api/groups.tsx +++ b/app/api/groups.tsx @@ -64,4 +64,18 @@ export function createGroup(group: Group, onCreate?: () => void) { onCreate && onCreate(); }) .catch((error) => console.error(error)); +} + +export function destroyGroup(group: Group, onDestroy?: () => void) { + fetch(`/api/${getSlug()}/groups/${group.id}`, { + method: 'DELETE', + headers: { + 'X-CSRF-TOKEN': getCsrfToken(), + } + }) + .then((response) => response.json()) + .then((data) => { + onDestroy && onDestroy(); + }) + .catch((error) => console.error(error)); } \ No newline at end of file diff --git a/app/ui/groups/table.tsx b/app/ui/groups/table.tsx index 354c229..ca1240e 100644 --- a/app/ui/groups/table.tsx +++ b/app/ui/groups/table.tsx @@ -4,12 +4,18 @@ import { Group } from '@/app/lib/definitions'; import TableOfContents from '../components/table-of-contents'; +import { PencilIcon, TrashIcon } from '@heroicons/react/24/outline'; +import { destroyGroup } from '@/app/api/groups'; -export default function GroupsTable({ groups }: { groups: Group[] }) { +export default function GroupsTable({ groups, onUpdate, onEdit }: { + groups: Group[], + onUpdate: () => void, + onEdit: (group: Group) => void, +}) { return ( ( @@ -38,6 +44,12 @@ export default function GroupsTable({ groups }: { groups: Group[] }) { {group.attendance?.total} + +
+ { destroyGroup(group, () => onUpdate()) }} /> + onEdit(group)} /> +
+ )} />