diff --git a/app/dashboard/tables/page.tsx b/app/dashboard/tables/page.tsx index f378fed..db4f10b 100644 --- a/app/dashboard/tables/page.tsx +++ b/app/dashboard/tables/page.tsx @@ -1,10 +1,15 @@ /* Copyright (C) 2024 Manuel Bustillo*/ import { Table } from '@/app/ui/components/table'; +import Arrangement from '@/app/ui/arrangements/arrangement'; import Summary from '@/app/ui/expenses/summary'; import { lusitana } from '@/app/ui/fonts'; export default function Page() { + + return( + + ) return (
diff --git a/app/lib/definitions.ts b/app/lib/definitions.ts index 4a9f09e..c182c95 100644 --- a/app/lib/definitions.ts +++ b/app/lib/definitions.ts @@ -26,6 +26,20 @@ export type Guest = { status?: 'Considered' | 'Invited' | 'Confirmed' | 'Declined' | 'Tentative'; } +export type Banana = { + id: string; + name: string; + email?: string; + group_name?: string; + status?: 'Considered' | 'Invited' | 'Confirmed' | 'Declined' | 'Tentative'; +} + +export type TableArrangement = { + number: number; + guests: Guest[]; + discomfort?: number +} + export type Group = { id: string; name: string; diff --git a/app/ui/arrangements/arrangement.tsx b/app/ui/arrangements/arrangement.tsx new file mode 100644 index 0000000..5da1c3f --- /dev/null +++ b/app/ui/arrangements/arrangement.tsx @@ -0,0 +1,44 @@ +'use client'; + +import React, { useState } from 'react'; +import { TableArrangement, Guest } from '@/app/lib/definitions'; +import { lusitana } from '@/app/ui/fonts'; +import { Table } from '@/app/ui/components/table'; + +export default function Arrangement({ id }: { id: string }) { + + const [guests, setGuests] = useState>([]); + const [tables, setTables] = useState>([]); + + + function loadTables() { + fetch(`/api/tables_arrangements/${id}`) + .then((response) => response.json()) + .then((data) => { + setTables(data.map((record: any) => { + return ({ + id: record.id, + guests: record.guests + }); + })); + }, (error) => { + return []; + }); + } + + tables.length === 0 && loadTables(); + + return ( +
+
+

Table distributions

+
+ {tables.map((table) => ( + + ))} + + + + ) + +} \ No newline at end of file