Merge pull request #6 from mildz79-code/claude/gallant-wright-DgJoQ
Configure Formspree endpoint and refactor form submission
This commit is contained in:
+4
-6
@@ -250,7 +250,7 @@ html[lang="ko"] em { font-style: normal; color: var(--gold); font-weight: 500; }
|
||||
// 3. Replace the empty string below with that URL.
|
||||
// Until this is set, the form submits to a friendly "not configured" message.
|
||||
// ────────────────────────────────────────────────────────────────
|
||||
const FORM_ENDPOINT = '';
|
||||
const FORM_ENDPOINT = 'https://formspree.io/f/xojbbdzv';
|
||||
|
||||
(function() {
|
||||
const form = document.getElementById('orderForm');
|
||||
@@ -286,17 +286,15 @@ const FORM_ENDPOINT = '';
|
||||
}
|
||||
|
||||
const data = new FormData(form);
|
||||
const payload = {};
|
||||
data.forEach((v, k) => { payload[k] = v; });
|
||||
payload._subject = 'New order — ' + (payload.name || 'unknown') + ' · ' + (payload.fulfillment || '');
|
||||
data.append('_subject', 'New order — ' + (data.get('name') || 'unknown') + ' · ' + (data.get('fulfillment') || ''));
|
||||
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.textContent = 'Sending…';
|
||||
|
||||
fetch(FORM_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
headers: { 'Accept': 'application/json' },
|
||||
body: data
|
||||
}).then(function(r) {
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
return r.json().catch(() => ({}));
|
||||
|
||||
Reference in New Issue
Block a user