-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathMobileVersion.tsx
More file actions
112 lines (104 loc) · 3.49 KB
/
MobileVersion.tsx
File metadata and controls
112 lines (104 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { useState } from 'react';
import Image from 'next/image';
import mailIcon from '../../../public/img/mail-icon.svg';
import messageIcon from '../../../public/img/message-icon.svg';
import { useForm, ValidationError } from '@formspree/react';
import ReCAPTCHA from 'react-google-recaptcha';
export default function MobileVersion() {
const [captchaComplete, setCaptchaComplete] = useState<boolean>(false);
const [state, handleSubmit] = useForm(process.env.NEXT_PUBLIC_FORMSPREE_ID!);
const handleRecaptchaResult = (result: string | null) => {
if (result) {
setCaptchaComplete(true);
}
};
if (state.succeeded) {
return (
<div className="flex justify-center items-center">
<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>
</div>
);
}
return (
<>
<h1 className="text-black font-roboto-mono text-4xl w-fit mx-auto py-4 font-bold">
Let's talk React
</h1>
<form className="w-4/5 mx-auto md:w-2/3 bg-[#0096c7]" onSubmit={handleSubmit}>
<label
htmlFor="name"
className="border border-black w-full rounded-md p-2 my-2 flex"
>
<input
id="name"
type="text"
name="name"
placeholder="Name"
className=" placeholder-black outline-hidden grow ml-8 font-roboto-mono text-base bg-[#0096c7]"
required
/>
</label>
<ValidationError prefix="Name" field="name" errors={state.errors} />
<label
htmlFor="email"
className="border border-black w-full rounded-md p-2 my-2 flex"
>
<Image
src={mailIcon}
alt=""
width={25}
height={25}
color="#000"
className="inline-block"
/>
<input
id="email"
type="email"
placeholder="Email"
name="email"
className="inline-block ml-2 outline-hidden grow placeholder-black font-roboto-mono text-base bg-[#0096c7]"
required
/>
</label>
<ValidationError prefix="Email" field="email" errors={state.errors} />
<label className="border border-black w-full rounded-md p-2 my-2 flex items-start">
<Image
src={messageIcon}
width={25}
height={25}
className="inline-block "
alt=""
/>
<textarea
placeholder="Message"
name="message"
className=" inline-block ml-2 h-[270px] resize-none outline-hidden grow placeholder-black font-roboto-mono text-base bg-[#0096c7]"
required
></textarea>
</label>
<ValidationError
prefix="Message"
field="message"
errors={state.errors}
/>
<ReCAPTCHA
sitekey={process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY!}
onChange={handleRecaptchaResult}
/>
{/* //TODO: replace this button with the app button component */}
<button
type="submit"
disabled={!captchaComplete || state.submitting}
className="border-2 border-[#12A04E] w-full rounded-md p-2 my-2 font-montserrat font-bold text-[#12A04E]"
>
Send Message
</button>
<ValidationError errors={state.errors} />
</form>
</>
);
}