fix: Clear newsletter form fields after successful test send
Improves UX by resetting form after test email is successfully sent, allowing admin to start fresh for the next newsletter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
18181be000
commit
4cf65d07fa
1 changed files with 16 additions and 10 deletions
|
|
@ -309,7 +309,6 @@ function getCsrfToken() {
|
||||||
function validateNewsletterForm() {
|
function validateNewsletterForm() {
|
||||||
const tier = document.getElementById('newsletter-tier').value;
|
const tier = document.getElementById('newsletter-tier').value;
|
||||||
const subject = document.getElementById('newsletter-subject').value;
|
const subject = document.getElementById('newsletter-subject').value;
|
||||||
const contentRaw = document.getElementById('newsletter-content').value;
|
|
||||||
|
|
||||||
if (!tier) {
|
if (!tier) {
|
||||||
showStatus('error', 'Please select a newsletter tier');
|
showStatus('error', 'Please select a newsletter tier');
|
||||||
|
|
@ -321,16 +320,21 @@ function validateNewsletterForm() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!contentRaw) {
|
// Collect content from individual form fields
|
||||||
showStatus('error', 'Please enter content variables (JSON)');
|
const variables = {
|
||||||
return null;
|
highlight_1_title: document.getElementById('highlight_1_title').value,
|
||||||
}
|
highlight_1_summary: document.getElementById('highlight_1_summary').value,
|
||||||
|
highlight_1_link: document.getElementById('highlight_1_link').value,
|
||||||
|
finding_1: document.getElementById('finding_1').value,
|
||||||
|
question_1: document.getElementById('question_1').value,
|
||||||
|
feedback_link: document.getElementById('feedback_link').value,
|
||||||
|
blog_link: document.getElementById('blog_link').value
|
||||||
|
};
|
||||||
|
|
||||||
let variables;
|
// Basic validation - at least one content field should be filled
|
||||||
try {
|
const hasContent = Object.values(variables).some(val => val && val.trim());
|
||||||
variables = JSON.parse(contentRaw);
|
if (!hasContent) {
|
||||||
} catch (error) {
|
showStatus('error', 'Please fill in at least one content field');
|
||||||
showStatus('error', 'Invalid JSON in content field');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,6 +446,8 @@ async function handleTestNewsletter(e) {
|
||||||
|
|
||||||
if (response.ok && result.success) {
|
if (response.ok && result.success) {
|
||||||
showStatus('success', `Test email sent to ${testEmail}`);
|
showStatus('success', `Test email sent to ${testEmail}`);
|
||||||
|
// Clear form on successful test send
|
||||||
|
document.getElementById('send-newsletter-form').reset();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(result.error || 'Test send failed');
|
throw new Error(result.error || 'Test send failed');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue