@@ -19,6 +19,7 @@ import * as analytics from "../../services/analytics";
1919import Footer from "../Layout/Footer" ;
2020import { useSiteContext } from "contexts/siteContext" ;
2121import SEO from "../SEO" ;
22+ import { useToasterContext } from "contexts/toasterContext" ;
2223
2324const validationSchema = Yup . object ( ) . shape ( {
2425 name : Yup . string ( ) . required ( "Please enter your name" ) ,
@@ -94,7 +95,7 @@ const Contact = () => {
9495
9596 const [ open , setOpen ] = useState ( false ) ;
9697 const [ submitted , setSubmitted ] = useState ( false ) ;
97- const [ submitError , setSubmitError ] = useState ( "" ) ;
98+ const { setToast } = useToasterContext ( )
9899 const handleOpen = ( ) => setOpen ( true ) ;
99100 const handleClose = ( ) => setOpen ( false ) ;
100101 const { isMobile } = useBreakpoints ( ) ;
@@ -176,12 +177,13 @@ const Contact = () => {
176177 sendContactForm ( values )
177178 . then ( ( ) => {
178179 setSubmitted ( true ) ;
179- setSubmitError ( "" ) ;
180180 handleOpen ( ) ;
181181 } )
182182 . catch ( ( ) => {
183- setSubmitError (
184- "There was an error with your submission. Please try again."
183+ setToast ( {
184+ message :"There was an error with your submission. Please try again." ,
185+ type :"error"
186+ }
185187 ) ;
186188 } ) ;
187189 } }
@@ -270,17 +272,6 @@ const Contact = () => {
270272 alignItems = "center"
271273 gap = { isMobile ? 1 : 2 }
272274 >
273- { submitError && (
274- < Typography
275- variant = "subtitle2"
276- color = "error"
277- sx = { {
278- marginTop : "-20px" ,
279- } }
280- >
281- { submitError }
282- </ Typography >
283- ) }
284275 < Button type = "submit" disabled = { ! dirty || ! isValid } >
285276 Submit
286277 </ Button >
0 commit comments