diff --git a/src/components/contact/mailForm.js b/src/components/contact/mailForm.js index 16d2187..ee9280a 100644 --- a/src/components/contact/mailForm.js +++ b/src/components/contact/mailForm.js @@ -12,32 +12,27 @@ function MailForm() { const handleSubmit = async (e) => { e.preventDefault() + if (!firstName || !lastName || !email || !message) { + alert("Please fill out missing info") + return; + } try { - - const response = await fetch("https://twilight-wildflower-fcec.ubcagrobot.workers.dev/", { + await fetch("https://twilight-wildflower-fcec.ubcagrobot.workers.dev/", { method: "POST", headers: { "Content-Type": "application/json" }, - body: { + body: JSON.stringify({ "firstName": firstName, "lastName": lastName, "phoneNumber": phone, "email": email, "body": message - } + }) }) - if (!response.ok) { - throw Error() - } else { - setFirstName('') - setLastName('') - setPhone('') - setMessage('') - } } catch (error) { - alert('Error sending message 🙀, sending an email is a good alternative') } + window.location.reload(); } return (