From 6372ef9c8d90ccd8e937cf3c47b421841a4a2170 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Mon, 14 Sep 2026 07:50:54 +0200 Subject: [PATCH] Aggiunge la conferma di modifica in Gestione eventi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prima di salvare l'aggiornamento di un evento esistente, mostra un drawer di conferma coerente con quello giĆ  usato per l'eliminazione. Co-Authored-By: Claude Sonnet 5 --- src/routes/eventi.tsx | 50 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/routes/eventi.tsx b/src/routes/eventi.tsx index c3b9477..34b99ea 100644 --- a/src/routes/eventi.tsx +++ b/src/routes/eventi.tsx @@ -66,6 +66,7 @@ function GestioneEventi() { const elimina = useEliminaEvento(); const [bozza, setBozza] = useState(null); const [daEliminare, setDaEliminare] = useState(null); + const [confermaModifica, setConfermaModifica] = useState(false); const rosa = squadra.filter((g) => g.attivo); if (!io || !admin) { @@ -85,18 +86,31 @@ function GestioneEventi() { setBozza((b) => (b ? { ...b, ...patch } : b)); } - async function conferma() { + const modificaEsistente = bozza ? eventi.some((e) => e.id === bozza.id) : false; + + function chiediConferma() { if (!bozza) return; if (!bozza.titolo.trim()) { toast.error("Serve un titolo per l'evento"); return; } + if (modificaEsistente) { + setConfermaModifica(true); + return; + } + conferma(); + } + + async function conferma() { + if (!bozza) return; try { await salva.mutateAsync({ ...bozza, titolo: bozza.titolo.trim() }); toast.success("Evento salvato"); setBozza(null); } catch { toast.error("Non sono riuscito a salvare l'evento"); + } finally { + setConfermaModifica(false); } } @@ -272,7 +286,7 @@ function GestioneEventi() { + + + + + + + !aperto && setDaEliminare(null)}>