1- import * as React from 'react' ;
2- import Avatar from '@mui/material/Avatar' ;
3- import Button from '@mui/material/Button' ;
4- import CssBaseline from '@mui/material/CssBaseline' ;
5- import TextField from '@mui/material/TextField' ;
6- import FormControlLabel from '@mui/material/FormControlLabel' ;
7- import Checkbox from '@mui/material/Checkbox' ;
8- import Link from '@mui/material/Link' ;
9- import Grid from '@mui/material/Grid' ;
10- import Box from '@mui/material/Box' ;
11- import LockOutlinedIcon from '@mui/icons-material/LockOutlined' ;
12- import Typography from '@mui/material/Typography' ;
13- import Container from '@mui/material/Container' ;
14- import { createTheme , ThemeProvider } from '@mui/material/styles' ;
1+ import React from "react" ;
2+ import { styled } from '@mui/material/styles' ;
3+ import Paper from '@mui/material/Paper' ;
4+ import { useForm , ValidationError } from "@formspree/react" ;
5+ import { Container , Grid } from '@mui/material' ;
6+ import ThanksBar from './ThanksBar' ;
157
16- function Copyright ( props ) {
17- return (
18- < Typography variant = "body2" color = "text.secondary" align = "center" { ...props } >
19- { 'Copyright © ' }
20- < Link color = "inherit" href = "https://mui.com/" >
21- Your Website
22- </ Link > { ' ' }
23- { new Date ( ) . getFullYear ( ) }
24- { '.' }
25- </ Typography >
26- ) ;
27- }
8+ function ContactForm ( ) {
9+ const [ state , handleSubmit ] = useForm ( "xaykzqea" ) ;
10+ if ( state . succeeded ) {
11+ return < p > Thanks for joining!</ p > ;
12+ }
2813
29- const theme = createTheme ( ) ;
30-
31- export default function FormPage ( ) {
32- const handleSubmit = ( event ) => {
33- event . preventDefault ( ) ;
34- const data = new FormData ( event . currentTarget ) ;
35- console . log ( {
36- email : data . get ( 'email' ) ,
37- password : data . get ( 'password' ) ,
38- } ) ;
39- } ;
14+ const Item = styled ( Paper ) ( ( { theme } ) => ( {
15+ backgroundColor : theme . palette . mode === 'dark' ? '#2d3334' : '#fff' ,
16+ ...theme . typography . body2 ,
17+ padding : theme . spacing ( 1 ) ,
18+ textAlign : 'center' ,
19+ color : theme . palette . text . secondary ,
20+ } ) ) ;
4021
4122 return (
42- < ThemeProvider theme = { theme } >
43- < Container component = "main" maxWidth = "xs" >
44- < CssBaseline />
45- < Box
46- sx = { {
47- marginTop : 8 ,
48- display : 'flex' ,
49- flexDirection : 'column' ,
50- alignItems : 'center' ,
51- } }
52- >
53- < Avatar sx = { { m : 1 , bgcolor : 'secondary.main' } } >
54- < LockOutlinedIcon />
55- </ Avatar >
56- < Typography component = "h1" variant = "h5" >
57- Sign up
58- </ Typography >
59- < Box component = "form" noValidate onSubmit = { handleSubmit } sx = { { mt : 3 } } >
23+ < >
24+ < ThanksBar />
25+ < form className = "mx-auto w-full pt-10 sm:w-3/4" onSubmit = { handleSubmit } >
26+ < div className = "flex flex-col md:flex-row" >
27+ < Container maxWidth = "sm" >
6028 < Grid container spacing = { 2 } >
61- < Grid item xs = { 12 } sm = { 6 } >
62- < TextField
63- autoComplete = "given-name"
64- name = "firstName"
65- required
66- fullWidth
67- id = "firstName"
68- label = "First Name"
69- autoFocus
70- />
71- </ Grid >
72- < Grid item xs = { 12 } sm = { 6 } >
73- < TextField
74- required
75- fullWidth
76- id = "lastName"
77- label = "Last Name"
78- name = "lastName"
79- autoComplete = "family-name"
80- />
29+ < Grid item xs = { 6 } md = { 8 } >
30+ < Item >
31+ < input
32+ data-aos = "fade-right"
33+ data-aos-duration = "1000"
34+ className = "mr-3 w-full rounded border px-4 py-3 font-body text-black md:w-1/2 lg:mr-5"
35+ placeholder = "Name"
36+ type = "text"
37+ id = "name"
38+ name = "name"
39+ />
40+ </ Item >
8141 </ Grid >
82- < Grid item xs = { 12 } >
83- < TextField
84- required
85- fullWidth
86- id = "email"
87- label = "Email Address"
88- name = "email"
89- autoComplete = "email"
90- />
42+ < Grid item xs = { 6 } md = { 4 } >
43+ < Item >
44+ < input
45+ data-aos = "fade-left"
46+ data-aos-duration = "1000"
47+ className = "mt-6 w-full rounded border px-4 py-3 font-body text-black md:mt-0 md:ml-3 md:w-1/2 lg:ml-5"
48+ placeholder = "Email"
49+ type = "email"
50+ id = "email"
51+ name = "email"
52+ />
53+ < ValidationError prefix = "Email" field = "email" errors = { state . errors } />
54+
55+ </ Item >
9156 </ Grid >
9257 < Grid item xs = { 12 } >
93- < TextField
94- required
95- fullWidth
96- name = "password"
97- label = "Password"
98- type = "password"
99- id = "password"
100- autoComplete = "new-password"
101- />
58+ < Item >
59+ < textarea
60+ data-aos = "fade-up"
61+ data-aos-duration = "1000"
62+ className = "mt-6 w-full rounded border px-4 py-3 font-body text-black md:mt-8"
63+ placeholder = "Message"
64+ id = "message"
65+ cols = "30"
66+ rows = "10"
67+ name = "message"
68+ > </ textarea >
69+ < ValidationError prefix = "Message" field = "message" errors = { state . errors } />
70+
71+ </ Item >
10272 </ Grid >
10373 < Grid item xs = { 12 } >
104- < FormControlLabel
105- control = { < Checkbox value = "allowExtraEmails" color = "primary" /> }
106- label = "I want to receive inspiration, marketing promotions and updates via email."
107- />
108- </ Grid >
109- </ Grid >
110- < Button
111- type = "submit"
112- fullWidth
113- variant = "contained"
114- sx = { { mt : 3 , mb : 2 } }
115- >
116- Sign Up
117- </ Button >
118- < Grid container justifyContent = "flex-end" >
119- < Grid item >
120- < Link href = "#" variant = "body2" >
121- Already have an account? Sign in
122- </ Link >
74+ < Item >
75+ < button
76+ data-aos = "fade-down"
77+ data-aos-duration = "1000"
78+ type = "submit"
79+ disabled = { state . submitting }
80+ className = "mt-6 flex items-center justify-center rounded bg-primary px-8 py-3 font-header text-lg font-bold uppercase text-white hover:bg-grey-20"
81+ >
82+ Send
83+ < i className = "bx bx-chevron-right relative -right-2 text-3xl" > </ i >
84+ </ button >
85+ </ Item >
12386 </ Grid >
12487 </ Grid >
125- </ Box >
126- </ Box >
127- < Copyright sx = { { mt : 5 } } />
128- </ Container >
129- </ ThemeProvider >
88+ </ Container >
89+ </ div >
90+ </ form >
91+ </ >
13092 ) ;
131- }
93+ }
94+
95+ export default ContactForm ;
0 commit comments