Update TemplateList.tsx
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { EmailTemplate } from '../types';
|
import { EmailTemplate } from '../types';
|
||||||
import { Plus, Edit, Trash2, FileCode, Search, Database, ArrowRightCircle, Code, CopyPlus } from 'lucide-react';
|
import { Plus, Edit, Trash2, FileCode, Search, Database, ArrowRightCircle, Code, CopyPlus, Key } from 'lucide-react';
|
||||||
import { generateSelectSQL, generateN8nCode } from '../services/storage';
|
import { generateSelectSQL, generateN8nCode, generateTemplateKey } from '../services/storage';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
templates: EmailTemplate[];
|
templates: EmailTemplate[];
|
||||||
@@ -33,6 +33,13 @@ const TemplateList: React.FC<Props> = ({ templates, onCreate, onEdit, onClone, o
|
|||||||
alert('JS Code copied! Paste this into your n8n Code node.');
|
alert('JS Code copied! Paste this into your n8n Code node.');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const copyTemplateKey = (t: EmailTemplate, e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const key = generateTemplateKey(t.name);
|
||||||
|
navigator.clipboard.writeText(key);
|
||||||
|
alert(`Template Key '${key}' copied to clipboard!`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-8 max-w-7xl mx-auto h-screen flex flex-col">
|
<div className="p-8 max-w-7xl mx-auto h-screen flex flex-col">
|
||||||
<div className="flex justify-between items-center mb-8">
|
<div className="flex justify-between items-center mb-8">
|
||||||
@@ -130,6 +137,14 @@ const TemplateList: React.FC<Props> = ({ templates, onCreate, onEdit, onClone, o
|
|||||||
<Code size={14} />
|
<Code size={14} />
|
||||||
JS
|
JS
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={(e) => copyTemplateKey(t, e)}
|
||||||
|
className="flex items-center gap-1 text-xs font-medium text-slate-600 hover:text-orange-600 px-2 py-1 rounded hover:bg-white border border-transparent hover:border-slate-200 transition-all shadow-sm"
|
||||||
|
title="Copy Template Key"
|
||||||
|
>
|
||||||
|
<Key size={14} />
|
||||||
|
Key
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1">
|
<div className="flex gap-1">
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user