Update App.tsx
This commit is contained in:
16
App.tsx
16
App.tsx
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user