diff --git a/src/shared-components/contact-us/contact-us.js b/src/shared-components/contact-us/contact-us.js index 84c30e2..af222af 100644 --- a/src/shared-components/contact-us/contact-us.js +++ b/src/shared-components/contact-us/contact-us.js @@ -166,27 +166,27 @@ class ContactUs extends Component { this.form.validateFields(); if (!this.form.isValid()) { - console.log('form is invalid: do not submit'); + return; } else { - console.log('form is valid: submit'); + axios({ + method: "POST", + url: "http://localhost:3002/send", + data: this.state + }).then((response) => { + if (response.data.status === 'success') { + alert("Message Sent."); + this.resetForm(); + } else if (response.data.status === 'fail') { + alert("Message failed to send."); + } + }) } - axios({ - method: "POST", - url: "http://localhost:3002/send", - data: this.state - }).then((response) => { - if (response.data.status === 'success') { - alert("Message Sent."); - this.resetForm() - } else if (response.data.status === 'fail') { - alert("Message failed to send.") - } - }) + } resetForm() { - this.setState({ firstname: '', lastname: '', email: '', message: '' }) + this.setState({ firstname: '', lastname: '', email: '', message: '', agent: '', house: '' }) } } diff --git a/src/shared-components/contact-us/index.js b/src/shared-components/contact-us/index.js index 9147321..f0e73e9 100644 --- a/src/shared-components/contact-us/index.js +++ b/src/shared-components/contact-us/index.js @@ -27,10 +27,10 @@ router.post('/send', (req, res, next) => { var firstname = req.body.firstname var lastname = req.body.lastname var email = req.body.email - var message = req.body.message var agent = req.body.agent var house = req.body.house - var content = `firstname: ${firstname} \n lastname: ${lastname} \n email: ${email} \n message: ${message} \n agent: ${agent} \n house: ${house}` + var message = req.body.message + var content = `First Name: ${firstname} \n Last Name: ${lastname} \n E-mail: ${email} \n Agent: ${agent} \n House: ${house} \n Message: ${message} ` var mail = { from: email,