Update email_templates.html

This commit is contained in:
2025-06-02 13:15:35 +02:00
parent 220d892fa0
commit 694c8df364

View File

@@ -267,19 +267,28 @@ document.addEventListener('DOMContentLoaded', function() {
saveButton.disabled = true; saveButton.disabled = true;
saveButton.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>Saving...'; saveButton.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>Saving...';
// Get CSRF token from meta tag
const csrfToken = document.querySelector('meta[name="csrf-token"]').content;
// Send AJAX request // Send AJAX request
fetch(`/settings/email-templates/${templateId}`, { fetch(`/settings/email-templates/${templateId}`, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content 'X-CSRF-Token': csrfToken,
'X-Requested-With': 'XMLHttpRequest'
}, },
body: JSON.stringify({ body: JSON.stringify({
subject: subject, subject: subject,
body: body body: body
}) })
}) })
.then(response => response.json()) .then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => { .then(data => {
if (data.error) { if (data.error) {
throw new Error(data.error); throw new Error(data.error);