Update App.tsx

This commit is contained in:
fcarraUniSa
2025-12-11 08:56:41 +01:00
committed by GitHub
parent b9f2943a22
commit 3679dceff7

16
App.tsx
View File

@@ -33,6 +33,19 @@ const App: React.FC = () => {
setView('editor'); 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) => { const handleDelete = async (id: string) => {
if (window.confirm("Are you sure you want to delete this template?")) { if (window.confirm("Are you sure you want to delete this template?")) {
await deleteTemplate(id); await deleteTemplate(id);
@@ -58,6 +71,7 @@ const App: React.FC = () => {
templates={templates} templates={templates}
onCreate={handleCreate} onCreate={handleCreate}
onEdit={handleEdit} onEdit={handleEdit}
onClone={handleClone}
onDelete={handleDelete} onDelete={handleDelete}
/> />
)} )}
@@ -119,4 +133,4 @@ const App: React.FC = () => {
); );
}; };
export default App; export default App;