-
+
}>
-
+ setGroupBeingEdited(group)}
+ />
TabPanel>
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)} />
+
+ |
)}
/>