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

This commit is contained in:
Manuel Bustillo 2025-01-26 13:33:35 +01:00
parent bf7e871a1b
commit 157401bae5

View File

@ -7,20 +7,33 @@ import { TableSimulation, TableSimulationSerializer } from '@/app/lib/tableSimul
import Arrangement from '@/app/ui/arrangements/arrangement'; import Arrangement from '@/app/ui/arrangements/arrangement';
import ArrangementsTable from '@/app/ui/arrangements/arrangements-table'; import ArrangementsTable from '@/app/ui/arrangements/arrangements-table';
import { classNames } from '@/app/ui/components/button'; import { classNames } from '@/app/ui/components/button';
import { useState } from 'react'; import { Toast } from 'primereact/toast';
import React, { useRef, useState } from 'react';
export default function Page() { 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); const [currentArrangement, setCurrentArrangement] = useState<string | null>(null);
function createSimulation() { function createSimulation() {
const api = new AbstractApi<TableSimulation>(); const api = new AbstractApi<TableSimulation>();
const serializer = new TableSimulationSerializer(); const serializer = new TableSimulationSerializer();
api.create(serializer, new TableSimulation(), () => {}); api.create(serializer, new TableSimulation(), show);
} }
return ( return (
<> <>
<div className="flex flex-col w-full items-center justify-between"> <div className="flex flex-col w-full items-center justify-between">
<Toast ref={toast} />
<button onClick={createSimulation} className={classNames('primary')}>Add new</button> <button onClick={createSimulation} className={classNames('primary')}>Add new</button>
</div> </div>