-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
888c7b4
commit f5ac443
Showing
3 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
document.getElementById('reservationForm').addEventListener('submit', async function(event) { | ||
event.preventDefault(); // Prevent form submission | ||
|
||
const formData = { | ||
name: document.getElementById('name').value, | ||
email: document.getElementById('email').value, | ||
date: document.getElementById('date').value, | ||
time: document.getElementById('time').value, | ||
service: document.getElementById('service').value, | ||
pax: document.getElementById('pax').value | ||
}; | ||
|
||
// Discord webhook URL | ||
const webhookURL = 'YOUR-DISCORD-WEBHOOK-URL'; | ||
|
||
// Prepare the message payload for Discord | ||
const messagePayload = { | ||
content: `New Reservation:\n\nName: ${formData.name}\nEmail: ${formData.email}\nDate: ${formData.date}\nTime: ${formData.time}\nService: ${formData.service}\nNumber of Pax: ${formData.pax}` | ||
}; | ||
|
||
try { | ||
const response = await fetch(webhookURL, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(messagePayload) | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Failed to send reservation to Discord'); | ||
} | ||
|
||
alert('Reservation sent successfully!'); | ||
document.getElementById('reservationForm').reset(); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
alert('Failed to send reservation. Please try again.'); | ||
} | ||
}); |