From 3679dceff7329d14efe5b86d08738da1bce6e986 Mon Sep 17 00:00:00 2001 From: fcarraUniSa Date: Thu, 11 Dec 2025 08:56:41 +0100 Subject: [PATCH] Update App.tsx --- App.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/App.tsx b/App.tsx index d4ad3e1..995a649 100644 --- a/App.tsx +++ b/App.tsx @@ -33,6 +33,19 @@ const App: React.FC = () => { setView('editor'); }; + 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 + name: `${t.name} (Copy)`, + updatedAt: new Date().toISOString() + }; + + setSelectedTemplate(clonedTemplate); + setView('editor'); + }; + const handleDelete = async (id: string) => { if (window.confirm("Are you sure you want to delete this template?")) { await deleteTemplate(id); @@ -58,6 +71,7 @@ const App: React.FC = () => { templates={templates} onCreate={handleCreate} onEdit={handleEdit} + onClone={handleClone} onDelete={handleDelete} /> )} @@ -119,4 +133,4 @@ const App: React.FC = () => { ); }; -export default App; \ No newline at end of file +export default App;