@@ -68,43 +68,26 @@ export class AppContact {
6868 switch ( e . name ) {
6969 case 'name' :
7070 this . formValues . nameValid = e . checkValidity ( ) ;
71- this . nameError = this . formValues . nameValid
72- ? ''
73- : ( this . nameError = e . validationMessage ) ;
71+ this . nameError = this . formValues . nameValid ? '' : ( this . nameError = e . validationMessage ) ;
7472 break ;
7573
7674 case 'email' :
7775 this . formValues . emailValid = e . checkValidity ( ) ;
78- this . emailError = this . formValues . emailValid
79- ? ''
80- : ( this . emailError = e . validationMessage ) ;
76+ this . emailError = this . formValues . emailValid ? '' : ( this . emailError = e . validationMessage ) ;
8177 break ;
8278
8379 case 'phone' :
84- this . formValues . phoneValid = e . value . match (
85- / ^ [ \+ ] ? [ ( ] ? \d { 1 , 3 } [ ) ] ? ( [ - \s \. ] ? \d { 3 } ) { 1 , 2 } [ - \s \. ] ? \d { 4 , 6 } $ /
86- ) ;
87- this . phoneError = this . formValues . phoneValid
88- ? ''
89- : ( this . phoneError =
90- e . validationMessage ||
91- 'Phone number invalid. Please try a valid format.' ) ;
80+ this . formValues . phoneValid = e . value . match ( / ^ [ \+ ] ? [ ( ] ? \d { 1 , 3 } [ ) ] ? ( [ - \s \. ] ? \d { 3 } ) { 1 , 2 } [ - \s \. ] ? \d { 4 , 6 } $ / ) ;
81+ this . phoneError = this . formValues . phoneValid ? '' : ( this . phoneError = e . validationMessage || 'Phone number invalid. Please try a valid format.' ) ;
9282 break ;
9383
9484 case 'message' :
9585 this . formValues . messageValid = e . checkValidity ( ) ;
96- this . messageError = this . formValues . messageValid
97- ? ''
98- : ( this . messageError = e . validationMessage ) ;
86+ this . messageError = this . formValues . messageValid ? '' : ( this . messageError = e . validationMessage ) ;
9987 break ;
10088 }
10189
102- this . formValues . nameValid &&
103- this . formValues . emailValid &&
104- this . formValues . phoneValid &&
105- this . formValues . messageValid
106- ? ( this . isDisabled = false )
107- : ( this . isDisabled = true ) ;
90+ this . formValues . nameValid && this . formValues . emailValid && this . formValues . phoneValid && this . formValues . messageValid ? ( this . isDisabled = false ) : ( this . isDisabled = true ) ;
10891 }
10992
11093 async handleSubmit ( event ) {
@@ -114,17 +97,14 @@ export class AppContact {
11497 this . formSubmitting = true ;
11598 this . isDisabled = true ;
11699
117- await fetch (
118- 'https://5fq97p31pc.execute-api.us-east-1.amazonaws.com/prod/openforgeContactUs' ,
119- {
120- method : 'post' ,
121- mode : 'no-cors' ,
122- headers : {
123- 'Content-type' : 'application/x-www-form-urlencoded; charset=UTF-8' ,
124- } ,
125- body : JSON . stringify ( this . formValues ) ,
126- }
127- ) ;
100+ await fetch ( 'https://5fq97p31pc.execute-api.us-east-1.amazonaws.com/prod/openforgeContactUs' , {
101+ method : 'post' ,
102+ mode : 'no-cors' ,
103+ headers : {
104+ 'Content-type' : 'application/x-www-form-urlencoded; charset=UTF-8' ,
105+ } ,
106+ body : JSON . stringify ( this . formValues ) ,
107+ } ) ;
128108
129109 // isServer is false when running in the browser
130110 // and true when being prerendered
@@ -152,8 +132,7 @@ export class AppContact {
152132 form . scrollIntoView ( { block : 'start' , behavior : 'smooth' } ) ;
153133 }
154134
155- private className =
156- localStorage . getItem ( 'isSafari' ) === 'false' ? 'webp' : 'hero' ;
135+ private className = localStorage . getItem ( 'allowWebp' ) === 'false' ? 'webp' : 'hero' ;
157136
158137 render ( ) {
159138 return (
@@ -169,10 +148,7 @@ export class AppContact {
169148 < p >
170149 < app-translate key = "contact.hero.request" />
171150 </ p >
172- < button
173- onClick = { this . scrollToForm . bind ( this ) }
174- class = "btn btn-primary"
175- >
151+ < button onClick = { this . scrollToForm . bind ( this ) } class = "btn btn-primary" >
176152 < app-translate key = "contact.hero.requestNow" />
177153 </ button >
178154 </ div >
@@ -190,100 +166,40 @@ export class AppContact {
190166 < p class = "lead" >
191167 < app-translate key = "contact.form.text" />
192168 </ p >
193- < form
194- id = "contact-form"
195- onSubmit = { this . handleSubmit . bind ( this ) }
196- novalidate = { true }
197- >
198- < app-input
199- name = "name"
200- label = { translate ( 'contact.form.fullName' ) }
201- type = "text"
202- id = "name"
203- placeholder = ""
204- required = { true }
205- />
169+ < form id = "contact-form" onSubmit = { this . handleSubmit . bind ( this ) } novalidate = { true } >
170+ < app-input name = "name" label = { translate ( 'contact.form.fullName' ) } type = "text" id = "name" placeholder = "" required = { true } />
206171 < p class = "error" >
207- < span
208- style = {
209- ! this . nameError
210- ? { display : 'none' }
211- : this . errorIconStyles
212- }
213- >
172+ < span style = { ! this . nameError ? { display : 'none' } : this . errorIconStyles } >
214173 < i class = "fa fa-exclamation-circle" aria-hidden = "true" />
215174 </ span >
216175 { this . nameError }
217176 </ p >
218177
219- < app-input
220- name = "email"
221- label = { translate ( 'contact.form.email' ) }
222- type = "email"
223- id = "email"
224- placeholder = ""
225- required = { true }
226- />
178+ < app-input name = "email" label = { translate ( 'contact.form.email' ) } type = "email" id = "email" placeholder = "" required = { true } />
227179 < p class = "error" >
228- < span
229- style = {
230- ! this . emailError
231- ? { display : 'none' }
232- : this . errorIconStyles
233- }
234- >
180+ < span style = { ! this . emailError ? { display : 'none' } : this . errorIconStyles } >
235181 < i class = "fa fa-exclamation-circle" aria-hidden = "true" />
236182 </ span >
237183 { this . emailError }
238184 </ p >
239185
240- < app-input
241- name = "phone"
242- label = { translate ( 'contact.form.phone' ) }
243- id = "phone"
244- type = "tel"
245- placeholder = ""
246- required = { true }
247- />
186+ < app-input name = "phone" label = { translate ( 'contact.form.phone' ) } id = "phone" type = "tel" placeholder = "" required = { true } />
248187 < p class = "error" >
249- < span
250- style = {
251- ! this . phoneError
252- ? { display : 'none' }
253- : this . errorIconStyles
254- }
255- >
188+ < span style = { ! this . phoneError ? { display : 'none' } : this . errorIconStyles } >
256189 < i class = "fa fa-exclamation-circle" aria-hidden = "true" />
257190 </ span >
258191 { this . phoneError }
259192 </ p >
260193
261- < app-input
262- name = "message"
263- label = { translate ( 'contact.form.whereDidYouHear' ) }
264- type = "text"
265- placeholder = ""
266- required = { true }
267- />
194+ < app-input name = "message" label = { translate ( 'contact.form.whereDidYouHear' ) } type = "text" placeholder = "" required = { true } />
268195 < p class = "error" >
269- < span
270- style = {
271- ! this . messageError
272- ? { display : 'none' }
273- : this . errorIconStyles
274- }
275- >
196+ < span style = { ! this . messageError ? { display : 'none' } : this . errorIconStyles } >
276197 < i class = "fa fa-exclamation-circle" aria-hidden = "true" />
277198 </ span >
278199 { this . messageError }
279200 </ p >
280201
281- < button
282- name = "submit"
283- type = "submit"
284- class = "btn btn-primary"
285- disabled = { this . isDisabled }
286- >
202+ < button name = "submit" type = "submit" class = "btn btn-primary" disabled = { this . isDisabled } >
287203 < app-translate key = "contact.form.button.send" />
288204 </ button >
289205 </ form >
0 commit comments