diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx
index 2b65f56..2ce7335 100644
--- a/app/dashboard/guests/page.tsx
+++ b/app/dashboard/guests/page.tsx
@@ -1,24 +1,34 @@
/* Copyright (C) 2024 Manuel Bustillo*/
-import { lusitana } from '@/app/ui/fonts';
import AffinityGroupsTree from '@/app/ui/guests/affinity-groups-tree';
import GuestsTable from '@/app/ui/guests/table';
import React, { Suspense } from 'react';
import SkeletonTable from '@/app/ui/guests/skeleton-row';
-
-
+import { TabView, TabPanel } from 'primereact/tabview';
+import GroupsTable from '@/app/ui/groups/table';
export default function Page() {
return (
-
Guests
-
- }>
-
-
-
+
+
+
+ }>
+
+
+
+ TabPanel>
+
+
+ }>
+
+
+
+ TabPanel>
+ TabView>
+
);
}
\ No newline at end of file
diff --git a/app/dashboard/layout.tsx b/app/dashboard/layout.tsx
index d179387..69055f9 100644
--- a/app/dashboard/layout.tsx
+++ b/app/dashboard/layout.tsx
@@ -8,7 +8,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
- {children}
+ {children}
);
}
\ No newline at end of file
diff --git a/app/lib/definitions.ts b/app/lib/definitions.ts
index 07eef8b..572914b 100644
--- a/app/lib/definitions.ts
+++ b/app/lib/definitions.ts
@@ -47,8 +47,19 @@ export type Group = {
guest_count: number;
icon: string;
children: Group[];
+ color?: string;
+ attendance?: AttendanceSummary
};
+export type AttendanceSummary = {
+ considered: number;
+ invited: number;
+ confirmed: number;
+ declined: number;
+ tentative: number;
+ total: number;
+}
+
export type Invoice = {
id: string;
customer_id: string;
diff --git a/app/ui/groups/table.tsx b/app/ui/groups/table.tsx
new file mode 100644
index 0000000..9b4e76b
--- /dev/null
+++ b/app/ui/groups/table.tsx
@@ -0,0 +1,75 @@
+/* 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}
+ |
+
+ )}
+ />
+ )
+}
diff --git a/tests/guests.spec.ts b/tests/guests.spec.ts
index 05e7215..02a8bc7 100644
--- a/tests/guests.spec.ts
+++ b/tests/guests.spec.ts
@@ -1,7 +1,8 @@
import { test, expect } from '@playwright/test'
-
+
test('should navigate to the guests page', async ({ page }) => {
await page.goto('/dashboard/guests')
- await expect(page.getByRole('heading', { name: 'Guests' })).toContainText('Guests')
+ await expect(page.getByRole('tab', { name: 'Groups' })).toContainText('Groups')
+ await expect(page.getByRole('tab', { name: 'Guests' })).toContainText('Guests')
})
\ No newline at end of file