1
1
import React from "react" ;
2
2
import AppContext from "./AppContext"
3
3
import { navigate } from "gatsby" ;
4
+ import { Message } from "semantic-ui-react" ;
5
+ import Alert from "../components/Alert" ;
6
+ import { StyledPrimaryButton } from "../components/Buttons" ;
4
7
5
8
import '../styles/contact.scss'
6
9
10
+
7
11
const encode = ( data ) => {
8
12
return Object . keys ( data )
9
13
. map ( key => encodeURIComponent ( key ) + "=" + encodeURIComponent ( data [ key ] ) )
@@ -18,10 +22,10 @@ var contactDict = {
18
22
contactLegend : "Contact Information" ,
19
23
email : "Email" ,
20
24
cell : "Cell" ,
21
- includeDetails : "Share information I enter about my tenancy " ,
25
+ includeDetails : "Share my tenancy information with Housing Now! " ,
22
26
subscribe : "Subscribe to newsletters from Housing Now!" ,
23
27
disclaimer : "Any information you share is kept confidential and is only used to assist you with your case." ,
24
- submitText : "Connect with us " ,
28
+ submitText : "Submit " ,
25
29
} ,
26
30
es : {
27
31
nameLegend : "Nombre" ,
@@ -30,10 +34,10 @@ var contactDict = {
30
34
contactLegend : "Información del contacto" ,
31
35
email : "Correo Electrónico" ,
32
36
cell : "Celular" ,
33
- includeDetails : "Compartir información que ingreso sobre mi arrendamiento " ,
34
- subscribe : "suscribirse a boletines de Housing Now!" ,
37
+ includeDetails : "¡Comparta mi información de arrendamiento con Housing Now! " ,
38
+ subscribe : "Suscribirse a boletines de Housing Now!" ,
35
39
disclaimer : "Cualquier información que comparta se mantiene confidencial y solo se utiliza para ayudarlo con su caso." ,
36
- submitText : "Conéctate con nosotros " ,
40
+ submitText : "Enviar " ,
37
41
}
38
42
} ;
39
43
@@ -52,6 +56,7 @@ class QuickContactForm extends React.Component {
52
56
subscribe : false ,
53
57
submitText : props . submitText ,
54
58
dict : contactDict ,
59
+ hasSubmitted : false ,
55
60
} ;
56
61
}
57
62
@@ -69,11 +74,13 @@ class QuickContactForm extends React.Component {
69
74
if ( this . state . submitDestination ) {
70
75
navigate ( this . state . submitDestination ) ;
71
76
}
77
+ this . setState ( {
78
+ hasSubmitted : true
79
+ } ) ;
72
80
} )
73
81
. catch ( error => console . log ( error ) ) ;
74
82
75
83
e . preventDefault ( ) ;
76
-
77
84
} ;
78
85
79
86
checkBoxes = { "includeDetails" : true , "subscribe" : true } ;
@@ -93,7 +100,7 @@ class QuickContactForm extends React.Component {
93
100
{ ( { appCtx, updateContext } ) => (
94
101
( ! appCtx . quickFormSubmit || ! autohide ) ?
95
102
< div >
96
- < form onSubmit = { ( e ) => { this . handleSubmit ( e , updateContext ) } } name = "quickContact" data-netlify = "true" data-netlify-honeypot = "bot-field" >
103
+ < form onSubmit = { ( e ) => { this . handleSubmit ( e , updateContext ) } } success = { this . state . hasSubmitted . toString ( ) } name = "quickContact" data-netlify = "true" data-netlify-honeypot = "bot-field" >
97
104
< input type = "hidden" name = "form-name" value = "quickContact" />
98
105
< fieldset >
99
106
< legend > { dict [ appCtx . lang ] . nameLegend } </ legend >
@@ -106,18 +113,17 @@ class QuickContactForm extends React.Component {
106
113
< input className = "form-control" type = "email" name = "email" value = { email } onChange = { this . handleChange } placeholder = { dict [ appCtx . lang ] . email } />
107
114
</ fieldset >
108
115
< fieldset >
109
- < label className = "form-control" > < input type = "checkbox" name = "includeDetails" checked = { includeDetails } onChange = { this . handleChange } /> { dict [ appCtx . lang ] . includeDetails } </ label >
110
- </ fieldset >
111
- < fieldset >
112
- < label className = "form-control" > < input type = "checkbox" name = "subscribe" checked = { subscribe } onChange = { this . handleChange } /> { dict [ appCtx . lang ] . subscribe } </ label >
116
+ < label className = "checkboxes" > < input type = "checkbox" name = "includeDetails" checked = { includeDetails } onChange = { this . handleChange } /> { dict [ appCtx . lang ] . includeDetails } </ label > < br />
117
+ < label className = "checkboxes" > < input type = "checkbox" name = "subscribe" checked = { subscribe } onChange = { this . handleChange } /> { dict [ appCtx . lang ] . subscribe } </ label >
113
118
</ fieldset >
114
119
< p className = "disclaimer" > { dict [ appCtx . lang ] . disclaimer } </ p >
115
-
116
- < button type = "submit" > { submitText ? submitText : dict [ appCtx . lang ] . submitText } </ button >
120
+ < center > < StyledPrimaryButton type = "submit" > { submitText ? submitText : dict [ appCtx . lang ] . submitText } </ StyledPrimaryButton > </ center >
117
121
</ form >
118
122
</ div >
119
123
:
120
- < div />
124
+ < div >
125
+ < Alert /> < br />
126
+ </ div >
121
127
) }
122
128
</ AppContext . Consumer >
123
129
) ;
@@ -277,7 +283,7 @@ class FullContactForm extends React.Component {
277
283
</ div >
278
284
}
279
285
< p >
280
- < button type = "submit" > { submitText ? submitText : dict [ appCtx . lang ] . submitText } </ button >
286
+ < button type = "submit" > { submitText ? submitText : dict [ appCtx . lang ] . submitText } </ button >
281
287
</ p >
282
288
</ form >
283
289
) }
0 commit comments