Render list of tables in an arrangement
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m40s
Add copyright notice / copyright_notice (pull_request) Successful in 2m1s
Playwright Tests / test (pull_request) Successful in 4m56s
Build Nginx-based docker image / build-static-assets (pull_request) Successful in 7m55s

This commit is contained in:
Manuel Bustillo 2024-11-02 11:24:48 +01:00
parent 094652d47e
commit 51d9a3d6e2
3 changed files with 63 additions and 0 deletions

View File

@ -1,10 +1,15 @@
/* Copyright (C) 2024 Manuel Bustillo*/ /* Copyright (C) 2024 Manuel Bustillo*/
import { Table } from '@/app/ui/components/table'; import { Table } from '@/app/ui/components/table';
import Arrangement from '@/app/ui/arrangements/arrangement';
import Summary from '@/app/ui/expenses/summary'; import Summary from '@/app/ui/expenses/summary';
import { lusitana } from '@/app/ui/fonts'; import { lusitana } from '@/app/ui/fonts';
export default function Page() { export default function Page() {
return(
<Arrangement id="4a54516b-1c6e-49eb-9781-c20b93f89c85"/>
)
return ( return (
<div className="w-full"> <div className="w-full">
<div className="w-full items-center justify-between"> <div className="w-full items-center justify-between">

View File

@ -26,6 +26,20 @@ export type Guest = {
status?: 'Considered' | 'Invited' | 'Confirmed' | 'Declined' | 'Tentative'; 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 = { export type Group = {
id: string; id: string;
name: string; name: string;

View File

@ -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<Array<Guest>>([]);
const [tables, setTables] = useState<Array<TableArrangement>>([]);
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 (
<div className="w-full">
<div className="w-full items-center justify-between">
<h1 className={`${lusitana.className} text-2xl`}>Table distributions</h1>
<div className="flex flex-row flex-wrap justify-around">
{tables.map((table) => (
<Table guests={table.guests} />
))}
</div>
</div>
</div>
)
}