Merge pull request #9 from YourWishes/gatsby

Contact form not submitting data.
This commit is contained in:
2020-02-10 08:52:46 +11:00
committed by GitHub
2 changed files with 9 additions and 12 deletions

View File

@ -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);
export interface SendMailParams {
name:string, email:string, message:string
};
export const sendMail = (data:SendMailParams) => APIRequest('mail/send', data).then(e => e.body);

View File

@ -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);