From da5a488c5835e64c6e9302ad7e6b5835d96f8204 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 10 Feb 2020 08:35:00 +1100 Subject: [PATCH] Contact form not submitting data. --- src/public/src/api/SendMail.tsx | 8 +++++--- src/public/src/components/forms/ContactForm.tsx | 13 ++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/public/src/api/SendMail.tsx b/src/public/src/api/SendMail.tsx index ff3d421..e2e38f8 100644 --- a/src/public/src/api/SendMail.tsx +++ b/src/public/src/api/SendMail.tsx @@ -1,5 +1,7 @@ import { APIRequest } from "./APIRequest"; -export const sendMail = (name:string, email:string, message:string) => APIRequest('mail/send', { - name, email, message -}).then(e => e.body); \ No newline at end of file +export interface SendMailParams { + name:string, email:string, message:string +}; + +export const sendMail = (data:SendMailParams) => APIRequest('mail/send', data).then(e => e.body); \ No newline at end of file diff --git a/src/public/src/components/forms/ContactForm.tsx b/src/public/src/components/forms/ContactForm.tsx index b117118..872bbec 100644 --- a/src/public/src/components/forms/ContactForm.tsx +++ b/src/public/src/components/forms/ContactForm.tsx @@ -5,7 +5,7 @@ import { Button, ButtonGroup } from '@objects/interactive/Button'; import * as yup from 'yup'; import { Panel } from '@objects/feedback/Panel'; import { Heading2 } from '@objects/typography/Heading'; -import { sendMail } from '@api/SendMail'; +import { sendMail, SendMailParams } from '@api/SendMail'; export interface ContactFormProps { @@ -25,16 +25,11 @@ export const ContactForm = (props:ContactFormProps) => { const [ pending, setPending ] = React.useState(false); const [ success, setSuccess ] = React.useState(false); - const onSubmit = async (data:any) => { + const onSubmit = async (data:SendMailParams) => { + console.log(data); setPending(true); - //await new Promise(resolve => setTimeout(resolve, 3000)); - - await sendMail( - '', - '', - '' - ); + await sendMail(data); setPending(false); setSuccess(true);