Seth commited on
Commit ·
323544d
1
Parent(s): 952e292
update
Browse files
frontend/src/components/prompts/PromptEditor.jsx
CHANGED
|
@@ -795,19 +795,17 @@ export default function PromptEditor({ selectedProducts, prompts, onPromptsChang
|
|
| 795 |
}, [selectedProducts, activeTab]);
|
| 796 |
|
| 797 |
useEffect(() => {
|
| 798 |
-
// Initialize prompts for selected products
|
|
|
|
| 799 |
const newPrompts = {};
|
| 800 |
selectedProducts.forEach(product => {
|
| 801 |
-
// Check if there's a saved prompt that's different from the default
|
| 802 |
const savedPrompt = prompts[product.name];
|
| 803 |
const defaultTemplate = DEFAULT_TEMPLATES[product.name];
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
// Only use saved prompt if there's no default template
|
| 807 |
-
if (defaultTemplate) {
|
| 808 |
-
newPrompts[product.name] = defaultTemplate;
|
| 809 |
-
} else if (savedPrompt) {
|
| 810 |
newPrompts[product.name] = savedPrompt;
|
|
|
|
|
|
|
| 811 |
} else {
|
| 812 |
newPrompts[product.name] = `Subject: {{first_name}}, let's talk about ${product.name}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${product.name} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest,\n{{sender_name}}`;
|
| 813 |
}
|
|
@@ -851,7 +849,7 @@ export default function PromptEditor({ selectedProducts, prompts, onPromptsChang
|
|
| 851 |
}
|
| 852 |
};
|
| 853 |
|
| 854 |
-
const
|
| 855 |
const defaultTemplate = DEFAULT_TEMPLATES[productName] ||
|
| 856 |
`Subject: {{first_name}}, let's talk about ${productName}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${productName} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest,\n{{sender_name}}`;
|
| 857 |
handlePromptChange(productName, defaultTemplate);
|
|
@@ -910,11 +908,11 @@ export default function PromptEditor({ selectedProducts, prompts, onPromptsChang
|
|
| 910 |
<Button
|
| 911 |
variant="ghost"
|
| 912 |
size="sm"
|
| 913 |
-
onClick={() =>
|
| 914 |
className="text-slate-500 hover:text-slate-700"
|
| 915 |
>
|
| 916 |
<RotateCcw className="h-4 w-4 mr-1" />
|
| 917 |
-
|
| 918 |
</Button>
|
| 919 |
<Button
|
| 920 |
size="sm"
|
|
|
|
| 795 |
}, [selectedProducts, activeTab]);
|
| 796 |
|
| 797 |
useEffect(() => {
|
| 798 |
+
// Initialize prompts for selected products.
|
| 799 |
+
// Priority: saved prompt > product default template > generic fallback.
|
| 800 |
const newPrompts = {};
|
| 801 |
selectedProducts.forEach(product => {
|
|
|
|
| 802 |
const savedPrompt = prompts[product.name];
|
| 803 |
const defaultTemplate = DEFAULT_TEMPLATES[product.name];
|
| 804 |
+
|
| 805 |
+
if (savedPrompt) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
newPrompts[product.name] = savedPrompt;
|
| 807 |
+
} else if (defaultTemplate) {
|
| 808 |
+
newPrompts[product.name] = defaultTemplate;
|
| 809 |
} else {
|
| 810 |
newPrompts[product.name] = `Subject: {{first_name}}, let's talk about ${product.name}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${product.name} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest,\n{{sender_name}}`;
|
| 811 |
}
|
|
|
|
| 849 |
}
|
| 850 |
};
|
| 851 |
|
| 852 |
+
const handleRestoreDefault = (productName) => {
|
| 853 |
const defaultTemplate = DEFAULT_TEMPLATES[productName] ||
|
| 854 |
`Subject: {{first_name}}, let's talk about ${productName}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${productName} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest,\n{{sender_name}}`;
|
| 855 |
handlePromptChange(productName, defaultTemplate);
|
|
|
|
| 908 |
<Button
|
| 909 |
variant="ghost"
|
| 910 |
size="sm"
|
| 911 |
+
onClick={() => handleRestoreDefault(product.name)}
|
| 912 |
className="text-slate-500 hover:text-slate-700"
|
| 913 |
>
|
| 914 |
<RotateCcw className="h-4 w-4 mr-1" />
|
| 915 |
+
Restore Default Prompt
|
| 916 |
</Button>
|
| 917 |
<Button
|
| 918 |
size="sm"
|