-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathindex.js
More file actions
219 lines (215 loc) · 6.87 KB
/
index.js
File metadata and controls
219 lines (215 loc) · 6.87 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import React, { useState } from "react";
import Button from "../../reusecore/Button";
import { useWebhookSubmit } from "../../utils/hooks/useWebhookSubmit";
import { Field, Form, Formik } from "formik";
import logo from "../../assets/images/app/layer5.svg";
import ContactFormWrapper from "./contact-form.style";
const ContactForm = () => {
const [memberFormOne, setmemberFormOne] = useState({});
const [submit, setSubmit] = useState(false);
const { submitForm } = useWebhookSubmit();
if (submit) {
document.querySelector(".showForm").style.height = "20rem";
return (
<ContactFormWrapper>
<div className="form-submitted">
<h2 className="text-2xl">Thanks for contacting us!</h2>
<p className="text-md">We'll get back to you as soon as we can.</p>
</div>
</ContactFormWrapper>
);
}
return (
<ContactFormWrapper>
<div className="form-data">
<Formik
initialValues={{
subscribed: false,
firstname: "",
lastname: "",
email: "",
subject: "",
message: "",
scope: "",
form: "contact",
}}
onSubmit={async (values) => {
const { success } = await submitForm({ memberFormOne: values });
if (success) {
setmemberFormOne(values);
setSubmit(true);
window.scrollTo(0, 700);
} else {
alert("Submission failed. Please try again.");
}
}}
>
<Form className="form" method="post">
<div className="title">
<img className="layer5-logo" src={logo} alt="Layer5 Logo" />
</div>
<label htmlFor="firstname" className="form-name">
First Name <span className="required-sign">*</span>
</label>
<Field
type="text"
className="text-field"
id="firstname"
name="firstname"
maxLength="32"
pattern="[A-Za-z]{1,32}"
required
onInvalid={(e) =>
e.target.setCustomValidity("Please fill-in this field")
}
onInput={(e) => e.target.setCustomValidity("")}
/>
<label htmlFor="lastname" className="form-name">
Last Name <span className="required-sign">*</span>
</label>
<Field
type="text"
className="text-field"
id="lastname"
name="lastname"
maxLength="32"
pattern="[A-Za-z]{1,32}"
required
onInvalid={(e) =>
e.target.setCustomValidity("Please fill-in this field")
}
onInput={(e) => e.target.setCustomValidity("")}
/>
<label htmlFor="email" className="form-name">
Email Address <span className="required-sign">*</span>
</label>
<Field
type="text"
className="text-field"
id="email"
name="email"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
required
onInvalid={(e) =>
e.target.setCustomValidity("Please fill-in this field")
}
onInput={(e) => e.target.setCustomValidity("")}
/>
<label htmlFor="subject" className="form-name">
Subject <span className="required-sign">*</span>
</label>
<Field
type="text"
className="text-field"
id="subject"
name="subject"
required
onInvalid={(e) =>
e.target.setCustomValidity("Please fill-in this field")
}
onInput={(e) => e.target.setCustomValidity("")}
/>
<label htmlFor="message" className="form-name">
Message <span className="required-sign">*</span>
</label>
<Field
as="textarea"
rows="8"
type="text"
className="text-field"
id="message"
name="message"
required
onInvalid={(e) =>
e.target.setCustomValidity("Please fill-in this field")
}
onInput={(e) => e.target.setCustomValidity("")}
/>
<label htmlFor="scope" className="form-name">
Scope of Question <span className="required-sign">*</span>
</label>
<div aria-labelledby="my-radio-group">
<label>
<Field
className="radio-field"
type="radio"
name="scope"
value="Meshery"
/>
Meshery
</label>
<br></br>
<label>
<Field
className="radio-field"
type="radio"
name="scope"
value="SMP"
/>
SMP
</label>
<br></br>
<label>
<Field
className="radio-field"
type="radio"
name="scope"
value="SMI"
/>
SMI
</label>
<br></br>
<label>
<Field
className="radio-field"
type="radio"
name="scope"
value="GetNighthawk"
/>
GetNighthawk
</label>
<br></br>
<label>
<Field
className="radio-field"
type="radio"
name="scope"
value="Landscape"
/>
Landscape
</label>
<br></br>
<label>
<Field
className="radio-field"
type="radio"
name="scope"
value="Community"
/>
Community
</label>
<div className="newsletter">
<label>
<Field
type="checkbox"
name="subscribed"
className="form-check"
/>
<span>Subscribe to our newsletter</span>
</label>
</div>
<div className="form-submit">
<Button
$secondary type="submit"
className="btn-next"
title="Submit"
/>
</div>
</div>
</Form>
</Formik>
</div>
</ContactFormWrapper>
);
};
export default ContactForm;