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
				
			
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /* Copyright (C) 2024-2025 LibreWeddingPlanner contributors*/
 | |
| 
 | |
| 'use client';
 | |
| 
 | |
| import { AbstractApi } from '@/app/api/abstract-api';
 | |
| import { TableSimulation, TableSimulationSerializer } from '@/app/lib/tableSimulation';
 | |
| import Arrangement from '@/app/ui/arrangements/arrangement';
 | |
| 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} />}
 | |
|     </>
 | |
|   )
 | |
| } |