Seth commited on
Commit ·
7a74d14
1
Parent(s): acf4199
update
Browse files
frontend/src/pages/EmailSequenceGenerator.jsx
CHANGED
|
@@ -35,12 +35,9 @@ export default function EmailSequenceGenerator() {
|
|
| 35 |
return;
|
| 36 |
}
|
| 37 |
|
| 38 |
-
|
| 39 |
-
setIsGenerating(true);
|
| 40 |
-
|
| 41 |
-
// Save prompts to backend
|
| 42 |
try {
|
| 43 |
-
await fetch('/api/save-prompts', {
|
| 44 |
method: 'POST',
|
| 45 |
headers: { 'Content-Type': 'application/json' },
|
| 46 |
body: JSON.stringify({
|
|
@@ -49,9 +46,18 @@ export default function EmailSequenceGenerator() {
|
|
| 49 |
products: selectedProducts.map(p => p.name)
|
| 50 |
})
|
| 51 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
} catch (error) {
|
| 53 |
console.error('Error saving prompts:', error);
|
|
|
|
|
|
|
| 54 |
}
|
|
|
|
|
|
|
|
|
|
| 55 |
};
|
| 56 |
|
| 57 |
const handleGenerationComplete = () => {
|
|
|
|
| 35 |
return;
|
| 36 |
}
|
| 37 |
|
| 38 |
+
// Save prompts to backend first, then start generation (avoids "No prompts found" race)
|
|
|
|
|
|
|
|
|
|
| 39 |
try {
|
| 40 |
+
const res = await fetch('/api/save-prompts', {
|
| 41 |
method: 'POST',
|
| 42 |
headers: { 'Content-Type': 'application/json' },
|
| 43 |
body: JSON.stringify({
|
|
|
|
| 46 |
products: selectedProducts.map(p => p.name)
|
| 47 |
})
|
| 48 |
});
|
| 49 |
+
if (!res.ok) {
|
| 50 |
+
const err = await res.json().catch(() => ({}));
|
| 51 |
+
throw new Error(err.detail || res.statusText);
|
| 52 |
+
}
|
| 53 |
} catch (error) {
|
| 54 |
console.error('Error saving prompts:', error);
|
| 55 |
+
alert('Failed to save templates. Please try again.');
|
| 56 |
+
return;
|
| 57 |
}
|
| 58 |
+
|
| 59 |
+
setStep(3);
|
| 60 |
+
setIsGenerating(true);
|
| 61 |
};
|
| 62 |
|
| 63 |
const handleGenerationComplete = () => {
|