From 8d12a2558d15630eec9edcc5bd43a5b863ddf3c6 Mon Sep 17 00:00:00 2001 From: fcarraUniSa Date: Tue, 23 Dec 2025 12:23:45 +0100 Subject: [PATCH] Update App.tsx --- App.tsx | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/App.tsx b/App.tsx index 0a7a96e..455a714 100644 --- a/App.tsx +++ b/App.tsx @@ -1,8 +1,9 @@ + import React, { useState, useEffect } from 'react'; import TemplateList from './components/TemplateList'; import TemplateEditor from './components/TemplateEditor'; import { ViewState, EmailTemplate, SQL_SCHEMA } from './types'; -import { getTemplates, deleteTemplate } from './services/storage'; +import { getTemplates, deleteTemplate, generateUUID } from './services/storage'; import { Database } from 'lucide-react'; const App: React.FC = () => { @@ -18,9 +19,14 @@ const App: React.FC = () => { const refreshTemplates = async () => { setIsLoading(true); - const data = await getTemplates(); - setTemplates(data); - setIsLoading(false); + try { + const data = await getTemplates(); + setTemplates(data); + } catch (err) { + console.error("Refresh Error:", err); + } finally { + setIsLoading(false); + } }; const handleCreate = () => { @@ -34,10 +40,9 @@ const App: React.FC = () => { }; const handleClone = (t: EmailTemplate) => { - // Create a copy of the template with a new ID and updated name const clonedTemplate: EmailTemplate = { ...t, - id: crypto.randomUUID(), // Generate new ID so it's treated as a new insert + id: generateUUID(), name: `${t.name} (Copia)`, updatedAt: new Date().toISOString() }; @@ -64,7 +69,7 @@ const App: React.FC = () => { <> {isLoading ? (
- Caricamento template... + Caricamento...
) : ( { /> )} - {/* Database Schema Modal (Global Help) */} {showSchema && (

- Configurazione Database per n8n + Configurazione DB

-

- Per far funzionare questa app con il tuo software interno, crea questa tabella nel tuo database MySQL o PostgreSQL. -

{SQL_SCHEMA}
@@ -113,7 +114,7 @@ const App: React.FC = () => {