Contact form not submitting data.
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
import { APIRequest } from "./APIRequest";
|
import { APIRequest } from "./APIRequest";
|
||||||
|
|
||||||
export const sendMail = (name:string, email:string, message:string) => APIRequest('mail/send', {
|
export interface SendMailParams {
|
||||||
name, email, message
|
name:string, email:string, message:string
|
||||||
}).then(e => e.body);
|
};
|
||||||
|
|
||||||
|
export const sendMail = (data:SendMailParams) => APIRequest('mail/send', data).then(e => e.body);
|
@ -5,7 +5,7 @@ import { Button, ButtonGroup } from '@objects/interactive/Button';
|
|||||||
import * as yup from 'yup';
|
import * as yup from 'yup';
|
||||||
import { Panel } from '@objects/feedback/Panel';
|
import { Panel } from '@objects/feedback/Panel';
|
||||||
import { Heading2 } from '@objects/typography/Heading';
|
import { Heading2 } from '@objects/typography/Heading';
|
||||||
import { sendMail } from '@api/SendMail';
|
import { sendMail, SendMailParams } from '@api/SendMail';
|
||||||
|
|
||||||
export interface ContactFormProps {
|
export interface ContactFormProps {
|
||||||
|
|
||||||
@ -25,16 +25,11 @@ export const ContactForm = (props:ContactFormProps) => {
|
|||||||
const [ pending, setPending ] = React.useState(false);
|
const [ pending, setPending ] = React.useState(false);
|
||||||
const [ success, setSuccess ] = React.useState(false);
|
const [ success, setSuccess ] = React.useState(false);
|
||||||
|
|
||||||
const onSubmit = async (data:any) => {
|
const onSubmit = async (data:SendMailParams) => {
|
||||||
|
console.log(data);
|
||||||
setPending(true);
|
setPending(true);
|
||||||
|
|
||||||
//await new Promise(resolve => setTimeout(resolve, 3000));
|
await sendMail(data);
|
||||||
|
|
||||||
await sendMail(
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
''
|
|
||||||
);
|
|
||||||
|
|
||||||
setPending(false);
|
setPending(false);
|
||||||
setSuccess(true);
|
setSuccess(true);
|
||||||
|
Reference in New Issue
Block a user