Manuel Bustillo
1b71bc9d79
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m21s
Add copyright notice / copyright_notice (pull_request) Successful in 1m53s
Playwright Tests / test (pull_request) Successful in 8m19s
Build Nginx-based docker image / build-static-assets (pull_request) Successful in 10m37s
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/* Copyright (C) 2024 Manuel Bustillo*/
|
|
|
|
'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 [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.number,
|
|
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 my-5`}>Table distributions</h1>
|
|
<div className="flex flex-row flex-wrap justify-around">
|
|
{tables.map((table) => (
|
|
<Table key={table.number} guests={table.guests || []} />
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
|
|
} |