- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2.5 KiB
JavaScript
78 lines
2.5 KiB
JavaScript
/**
|
|
* Case Submission Form Handler
|
|
*/
|
|
|
|
const form = document.getElementById('case-submission-form');
|
|
const submitButton = document.getElementById('submit-button');
|
|
const successMessage = document.getElementById('success-message');
|
|
const errorMessage = document.getElementById('error-message');
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
// Hide previous messages
|
|
successMessage.style.display = 'none';
|
|
errorMessage.style.display = 'none';
|
|
|
|
// Disable submit button
|
|
submitButton.disabled = true;
|
|
submitButton.textContent = 'Submitting...';
|
|
|
|
// Collect form data
|
|
const evidenceText = document.getElementById('case-evidence').value;
|
|
const evidence = evidenceText
|
|
? evidenceText.split('\n').filter(line => line.trim())
|
|
: [];
|
|
|
|
const formData = {
|
|
submitter: {
|
|
name: document.getElementById('submitter-name').value,
|
|
email: document.getElementById('submitter-email').value,
|
|
organization: document.getElementById('submitter-organization').value || null,
|
|
public: document.getElementById('submitter-public').checked
|
|
},
|
|
case_study: {
|
|
title: document.getElementById('case-title').value,
|
|
description: document.getElementById('case-description').value,
|
|
failure_mode: document.getElementById('case-failure-mode').value,
|
|
tractatus_applicability: document.getElementById('case-tractatus').value,
|
|
evidence: evidence,
|
|
attachments: []
|
|
}
|
|
};
|
|
|
|
try {
|
|
const response = await fetch('/api/cases/submit', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(formData)
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
// Success
|
|
successMessage.textContent = data.message || 'Thank you for your submission. We will review it shortly.';
|
|
successMessage.style.display = 'block';
|
|
form.reset();
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
} else {
|
|
// Error
|
|
errorMessage.textContent = data.message || 'An error occurred. Please try again.';
|
|
errorMessage.style.display = 'block';
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Submit error:', error);
|
|
errorMessage.textContent = 'Network error. Please check your connection and try again.';
|
|
errorMessage.style.display = 'block';
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
} finally {
|
|
// Re-enable submit button
|
|
submitButton.disabled = false;
|
|
submitButton.textContent = 'Submit Case Study';
|
|
}
|
|
});
|