11import {
2- FormControl ,
32 Container ,
43 TextField ,
54 Typography ,
65 Button ,
76 Box ,
7+ AlertColor ,
88} from "@mui/material" ;
99import { useState } from "react" ;
1010import { ErrorSnackbar } from "../common/ErrorSnackbar" ;
@@ -15,20 +15,28 @@ export const Contact = () => {
1515 const [ email , setEmail ] = useState ( "" ) ;
1616 const [ message , setMessage ] = useState ( "" ) ;
1717 const [ snackbarMessage , setSnackbarMessage ] = useState ( "" ) ;
18+ const [ snackbarSeverity , setSnackbarSeverity ] = useState < AlertColor > ( "error" ) ;
1819
1920 const handleSubmit = ( e : any ) => {
2021 if ( subject !== "" && email !== "" && message !== "" ) {
2122 e . preventDefault ( ) ;
2223 try {
23- window . location . assign (
24- `mailto:${ Email } ?subject=${ subject } &body=${ message } `
25- ) ;
26- setSnackbarMessage ( "Email sent successfully." ) ;
24+ // check email validity
25+ if ( e ?. currentTarget ?. form ?. reportValidity ( ) ) {
26+ window ?. location ?. assign (
27+ `mailto:${ Email } ?subject=${ subject } &body=${ message } `
28+ ) ;
29+ setSnackbarMessage ( "Email sent successfully." ) ;
30+ setSnackbarSeverity ( "success" ) ;
31+ } else {
32+ setSnackbarMessage ( "Invalid email." ) ;
33+ setSnackbarSeverity ( "warning" ) ;
34+ }
2735 } catch ( e ) {
2836 setSnackbarMessage ( "Email failed to send." ) ;
2937 console . log ( e ) ;
3038 }
31- } else setSnackbarMessage ( "Please fill out all fields." ) ;
39+ } else setSnackbarMessage ( "Please fill all fields." ) ;
3240 } ;
3341
3442 return (
@@ -40,35 +48,47 @@ export const Contact = () => {
4048 setSnackbarMessage ( "" ) ;
4149 } }
4250 titleMessage = { snackbarMessage }
43- bodyMessage = { snackbarMessage }
51+ severity = { snackbarSeverity }
4452 />
4553 ) }
4654
47- < Container >
55+ < Container maxWidth = { "md" } >
4856 < Typography
4957 variant = "h4"
5058 fontWeight = { "bold" }
51- color = { "black " }
52- sx = { { p : "1rem 0 3rem" } }
59+ p = { "2rem 0 1rem " }
60+ textAlign = { "center" }
5361 >
54- Contact Us
62+ We'd Love to Hear From You
63+ </ Typography >
64+
65+ < Typography variant = "body2" textAlign = { "center" } >
66+ Whether you're curious about features, have a question, or just want
67+ to say hi — we're ready to answer any and all questions.
5568 </ Typography >
5669
5770 < Box
5871 component = "form"
5972 autoComplete = { "true" }
6073 onSubmit = { handleSubmit }
74+ className = "contact-form"
75+ pt = { "4rem" }
6176 sx = { {
6277 display : "flex" ,
6378 flexDirection : "column" ,
6479 justifyContent : "center" ,
6580 bgcolor : "#44444" ,
81+ "& .MuiInputBase-root, .MuiButton-root" : {
82+ boxShadow : "0px 0px 10px 0px rgba(0.5,0,0,0.1)" ,
83+ borderRadius : "50px !important" ,
84+ } ,
6685 } }
6786 >
6887 < TextField
6988 id = "subject"
7089 label = "Subject"
7190 required
91+ autoFocus
7292 value = { subject }
7393 onChange = { ( e ) => setSubject ( e ?. target ?. value || "" ) }
7494 sx = { { pb : "1rem" } }
@@ -93,6 +113,7 @@ export const Contact = () => {
93113 />
94114 < Button
95115 variant = "contained"
116+ color = "success"
96117 type = "submit"
97118 fullWidth
98119 disabled = { subject === "" || email === "" || message === "" }
0 commit comments