11/* eslint-disable @typescript-eslint/no-non-null-assertion */
22import { useState } from 'react' ;
33
4- import { useForm , ValidationError } from '@formspree/react' ;
4+ import { useForm , ValidationError } from '@formspree/react' ;
55
6- import ReCAPTCHA from " react-google-recaptcha" ;
6+ import ReCAPTCHA from ' react-google-recaptcha' ;
77
88export default function DesktopVersion ( ) {
9+ const [ captchaComplete , setCaptchaComplete ] = useState < boolean > ( false ) ;
910
10- const [ captchaComplete , setCaptchaComplete ] = useState < boolean > ( false ) ;
11+ const [ state , handleSubmit ] = useForm ( process . env . NEXT_PUBLIC_FORMSPREE_ID ! ) ;
1112
12- const [ state , handleSubmit ] = useForm ( process . env . NEXT_PUBLIC_FORMSPREE_ID ! ) ;
13-
14- const handleRecaptchaResult = ( result : string | null ) => {
15- if ( result ) {
16- setCaptchaComplete ( true ) ;
17- }
13+ const handleRecaptchaResult = ( result : string | null ) => {
14+ if ( result ) {
15+ setCaptchaComplete ( true ) ;
1816 }
17+ } ;
1918
20- if ( state . succeeded ) {
21- return (
22- < div className = "flex justify-center items-center" >
23- < p className = 'text-xl font-medium text-green-800' > Thank you for your submission. We will get back to you as soon as possible</ p >
24- </ div >
25- )
26- }
19+ if ( state . succeeded ) {
20+ return (
21+ < div className = "flex justify-center items-center" >
22+ < p className = "text-xl font-medium text-green-800" >
23+ Thank you for your submission. We will get back to you as soon as
24+ possible
25+ </ p >
26+ </ div >
27+ ) ;
28+ }
2729
2830 return (
2931 < >
@@ -40,8 +42,8 @@ export default function DesktopVersion() {
4042 </ label >
4143 < input
4244 id = "name"
43- type = ' text'
44- name = ' name'
45+ type = " text"
46+ name = " name"
4547 placeholder = { 'Jane Doe' }
4648 className = "border border-[#CEEDF4] w-full rounded-lg px-4 py-3 mb-5 placeholder-[#7E7979] outline-none font-montserrat text-base"
4749 required
@@ -55,8 +57,8 @@ export default function DesktopVersion() {
5557 </ label >
5658 < input
5759 id = "email"
58- type = ' email'
59- name = ' email'
60+ type = " email"
61+ name = " email"
6062 placeholder = { 'you@example.com' }
6163 className = "border border-[#CEEDF4] w-full rounded-lg px-4 py-3 mb-5 outline-none placeholder-[#7E7979] font-montserrat text-base"
6264 required
@@ -70,35 +72,41 @@ export default function DesktopVersion() {
7072 </ label >
7173 < textarea
7274 id = "message"
73- name = ' message'
75+ name = " message"
7476 placeholder = "Hello, I'm getting in touch ..."
7577 className = "border border-[#CEEDF4] w-full rounded-lg px-4 py-[22px] mb-9 h-[178px] resize-none outline-none placeholder-[#7E7979] font-montserrat text-base"
7678 required
7779 />
78- < ValidationError prefix = "Message" field = "message" errors = { state . errors } />
80+ < ValidationError
81+ prefix = "Message"
82+ field = "message"
83+ errors = { state . errors }
84+ />
7985 { /*//TODO: replace this button with the app button component */ }
8086
8187 < ReCAPTCHA
82- sitekey = { process . env . NEXT_PUBLIC_RECAPTCHA_SITE_KEY ! }
83- onChange = { handleRecaptchaResult }
84- />
88+ sitekey = { process . env . NEXT_PUBLIC_RECAPTCHA_SITE_KEY ! }
89+ onChange = { handleRecaptchaResult }
90+ />
8591
86- { captchaComplete ?
87- < button
88- type = "submit"
89- disabled = { state . submitting }
90- className = "block rounded-md p-2 my-2 w-[247px] h-14 mx-auto bg-[#EC0505] text-white font-bold font-montserrat"
91- >
92- Send Message
93- </ button > :
94- < button
95- type = "submit"
96- disabled
97- className = "block rounded-md p-2 my-2 w-[247px] h-14 mx-auto bg-[#EC0505] text-white font-bold font-montserrat"
98- >
99- Send Message
100- </ button > }
101- < ValidationError errors = { state . errors } />
92+ { captchaComplete ? (
93+ < button
94+ type = "submit"
95+ disabled = { state . submitting }
96+ className = "block rounded-md p-2 my-2 w-[247px] h-14 mx-auto bg-[#EC0505] text-white font-bold font-montserrat"
97+ >
98+ Send Message
99+ </ button >
100+ ) : (
101+ < button
102+ type = "submit"
103+ disabled
104+ className = "block rounded-md p-2 my-2 w-[247px] h-14 mx-auto bg-[#EC0505] text-white font-bold font-montserrat"
105+ >
106+ Send Message
107+ </ button >
108+ ) }
109+ < ValidationError errors = { state . errors } />
102110 </ form >
103111 </ div >
104112 </ >
0 commit comments