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.
|
// 3. Replace the empty string below with that URL.
|
||||||
// Until this is set, the form submits to a friendly "not configured" message.
|
// 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() {
|
(function() {
|
||||||
const form = document.getElementById('orderForm');
|
const form = document.getElementById('orderForm');
|
||||||
@@ -286,17 +286,15 @@ const FORM_ENDPOINT = '';
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
const payload = {};
|
data.append('_subject', 'New order — ' + (data.get('name') || 'unknown') + ' · ' + (data.get('fulfillment') || ''));
|
||||||
data.forEach((v, k) => { payload[k] = v; });
|
|
||||||
payload._subject = 'New order — ' + (payload.name || 'unknown') + ' · ' + (payload.fulfillment || '');
|
|
||||||
|
|
||||||
submitBtn.disabled = true;
|
submitBtn.disabled = true;
|
||||||
submitBtn.textContent = 'Sending…';
|
submitBtn.textContent = 'Sending…';
|
||||||
|
|
||||||
fetch(FORM_ENDPOINT, {
|
fetch(FORM_ENDPOINT, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
|
headers: { 'Accept': 'application/json' },
|
||||||
body: JSON.stringify(payload)
|
body: data
|
||||||
}).then(function(r) {
|
}).then(function(r) {
|
||||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||||
return r.json().catch(() => ({}));
|
return r.json().catch(() => ({}));
|
||||||
|
|||||||
Reference in New Issue
Block a user