Compare commits

...

9 Commits

Author SHA1 Message Date
Renovate Bot
c0fd48b89d Update dependency tailwindcss to v4
Some checks failed
Playwright Tests / test (pull_request) Has been skipped
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m7s
Add copyright notice / copyright_notice (pull_request) Successful in 2m13s
Build Nginx-based docker image / build-static-assets (push) Failing after 8m34s
2025-01-27 03:06:19 +00:00
9a2ce5b654 Merge pull request 'Simulations life cycle improvements' (#191) from mark-expired-simulations into main
All checks were successful
Playwright Tests / test (push) Has been skipped
Check usage of free licenses / build-static-assets (push) Successful in 19s
Build Nginx-based docker image / build-static-assets (push) Successful in 3m47s
Reviewed-on: #191
2025-01-26 13:07:58 +00:00
0d1c46a349 Fix redundant class definitions
All checks were successful
Playwright Tests / test (pull_request) Has been skipped
Add copyright notice / copyright_notice (pull_request) Successful in 1m27s
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m53s
Build Nginx-based docker image / build-static-assets (push) Successful in 6m0s
2025-01-26 13:47:17 +01:00
157401bae5 Display a toast message after successfully creating a simulation
All checks were successful
Build Nginx-based docker image / build-static-assets (push) Successful in 2m52s
Playwright Tests / test (pull_request) Has been skipped
Add copyright notice / copyright_notice (pull_request) Successful in 25s
Check usage of free licenses / build-static-assets (pull_request) Successful in 49s
2025-01-26 13:33:35 +01:00
bf7e871a1b Display a button to create new simulations 2025-01-26 13:21:23 +01:00
e597b4fc00 Mark expired rows with red background 2025-01-26 13:09:31 +01:00
53a2752964 Remove references to unsupported dark theme 2025-01-26 13:06:29 +01:00
1184a529cf Display an icon indicating whether a simulation is still valid 2025-01-26 13:05:32 +01:00
Renovate Bot
58962e2f48 Update dependency next to v15.1.6
Some checks failed
Add copyright notice / copyright_notice (pull_request) Successful in 5m33s
Playwright Tests / test (pull_request) Has been skipped
Check usage of free licenses / build-static-assets (pull_request) Successful in 6m4s
Playwright Tests / test (push) Has been skipped
Check usage of free licenses / build-static-assets (push) Successful in 2m5s
Build Nginx-based docker image / build-static-assets (push) Failing after 2m56s
2025-01-25 03:10:32 +00:00
7 changed files with 140 additions and 815 deletions

View File

@ -2,15 +2,41 @@
'use client';
import { AbstractApi } from '@/app/api/abstract-api';
import { TableSimulation, TableSimulationSerializer } from '@/app/lib/tableSimulation';
import Arrangement from '@/app/ui/arrangements/arrangement';
import React, { useState } from 'react';
import ArrangementsTable from '@/app/ui/arrangements/arrangements-table';
import { classNames } from '@/app/ui/components/button';
import { Toast } from 'primereact/toast';
import React, { useRef, useState } from 'react';
export default function Page() {
const toast = useRef<Toast>(null);
const show = () => {
toast.current?.show({
severity: 'success',
summary: 'Simulation created',
detail: 'Table distributions will be calculated shortly, please come back in some minutes'
});
};
const [currentArrangement, setCurrentArrangement] = useState<string | null>(null);
function createSimulation() {
const api = new AbstractApi<TableSimulation>();
const serializer = new TableSimulationSerializer();
api.create(serializer, new TableSimulation(), show);
}
return (
<>
<div className="flex flex-col w-full items-center justify-between">
<Toast ref={toast} />
<button onClick={createSimulation} className={classNames('primary')}>Add new</button>
</div>
<ArrangementsTable onArrangementSelected={setCurrentArrangement} />
{currentArrangement && <Arrangement key={currentArrangement} id={currentArrangement} />}
</>

View File

@ -12,6 +12,7 @@ export function loadTableSimulations(onLoad?: (tableSimulations: TableArrangemen
id: record.id,
name: record.name,
discomfort: record.discomfort,
valid: record.valid,
});
}));
}, (error) => {

View File

@ -12,7 +12,8 @@ export type TableArrangement = {
number: number;
name: string;
guests?: Guest[];
discomfort?: number
discomfort?: number;
valid?: boolean;
}
export type User = {

View File

@ -19,12 +19,12 @@ export type Table = {
}
export class TableSimulation implements Entity {
id: string;
id?: string;
tables: Table[];
constructor(id: string, tables: Table[]) {
constructor(id?: string, tables?: Table[]) {
this.id = id;
this.tables = tables;
this.tables = tables || [];
}
}

View File

@ -7,42 +7,57 @@ import { TableArrangement } from '@/app/lib/definitions';
import { classNames } from "../components/button";
import TableOfContents from "../components/table-of-contents";
import { loadTableSimulations } from "@/app/api/tableSimulations";
import { ArchiveBoxXMarkIcon, CheckBadgeIcon } from "@heroicons/react/24/outline";
import { Tooltip } from "primereact/tooltip";
import clsx from "clsx";
export default function ArrangementsTable ({onArrangementSelected}: {onArrangementSelected: (arrangementId: string) => void}) {
const [arrangements, setArrangements] = useState<Array<TableArrangement>>([]);
const [arrangementsLoaded, setArrangementsLoaded] = useState(false);
export default function ArrangementsTable({ onArrangementSelected }: { onArrangementSelected: (arrangementId: string) => void }) {
const [arrangements, setArrangements] = useState<Array<TableArrangement>>([]);
const [arrangementsLoaded, setArrangementsLoaded] = useState(false);
function refreshSimulations() {
loadTableSimulations((arrangements) => {
setArrangements(arrangements);
setArrangementsLoaded(true);
});
}
function refreshSimulations() {
loadTableSimulations((arrangements) => {
setArrangements(arrangements);
setArrangementsLoaded(true);
});
}
function arrangementClicked(e: React.MouseEvent<HTMLElement>) {
onArrangementSelected(e.currentTarget.getAttribute('data-arrangement-id') || '');
}
!arrangementsLoaded && refreshSimulations();
function arrangementClicked(e: React.MouseEvent<HTMLElement>) {
onArrangementSelected(e.currentTarget.getAttribute('data-arrangement-id') || '');
}
return(
<TableOfContents
headers={['Name', 'Discomfort', 'Actions']}
caption='Simulations'
elements={arrangements}
rowRender={(arrangement) => (
<tr key={arrangement.id} className="bg-white border-b odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800">
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{arrangement.name}
</th>
<td className="px-6 py-4">
{arrangement.discomfort}
</td>
<td>
<button data-arrangement-id={arrangement.id} onClick={arrangementClicked} className={classNames('primary')}>Load</button>
</td>
</tr>
)}
/>
);
!arrangementsLoaded && refreshSimulations();
return (
<TableOfContents
headers={['Name', 'Discomfort', 'Actions', 'Status']}
caption='Simulations'
elements={arrangements}
rowRender={(arrangement) => (
<tr key={arrangement.id} className={clsx("border-b", {
"bg-white odd:bg-white even:bg-gray-50": arrangement.valid,
"bg-red-50 odd:bg-red-50 even:bg-red-100": !arrangement.valid
})}>
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
{arrangement.name}
</th>
<td className="px-6 py-4">
{arrangement.discomfort}
</td>
<td>
<button data-arrangement-id={arrangement.id} onClick={arrangementClicked} className={classNames('primary')}>Load</button>
</td>
<td>
<Tooltip target=".tooltip-status" />
{
arrangement.valid ?
<CheckBadgeIcon className='size-6 tooltip-status' data-pr-position="right" data-pr-tooltip="Simulation is valid" /> :
<ArchiveBoxXMarkIcon className='size-6 tooltip-status' data-pr-position="right" data-pr-tooltip="Simulation is expired due to attendance or affinity changes" />
}
</td>
</tr>
)}
/>
);
}

View File

@ -11,14 +11,14 @@
"autoprefixer": "10.4.20",
"bcrypt": "^5.1.1",
"clsx": "^2.1.1",
"next": "15.1.4",
"next": "15.1.6",
"next-auth": "5.0.0-beta.25",
"postcss": "8.5.1",
"primeicons": "^7.0.0",
"primereact": "^10.8.2",
"react": "19.0.0-rc-f38c22b244-20240704",
"react-dom": "19.0.0-rc-f38c22b244-20240704",
"tailwindcss": "3.4.17",
"tailwindcss": "4.0.0",
"typescript": "5.7.3",
"use-debounce": "^10.0.1",
"uuid": "11.0.5",

830
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff