@@ -4,39 +4,35 @@ import Margin from 'common/components/spacing/Margin';
4
4
import Button from 'app/components/Button' ;
5
5
6
6
import AutosizeTextArea from 'common/components/AutosizeTextArea' ;
7
+ import Input from 'common/components/Input' ;
7
8
import pushToAirtable from 'app/store/utils/pushToAirtable' ;
8
9
9
10
import { EmojiButton } from './elements' ;
10
11
11
- function sendFeedback ( props ) {
12
- const { feedback, emoji, sandboxId, user } = props ;
13
- const { username, email } = user || { } ;
14
-
15
- return pushToAirtable ( { feedback, emoji, sandboxId, username, email } ) ;
16
- }
17
-
18
12
class Feedback extends React . Component {
19
13
state = {
20
14
feedback : '' ,
15
+ email : this . props . user ,
21
16
emoji : null ,
22
17
loading : false ,
23
18
} ;
24
19
25
20
onChange = e => {
26
- this . setState ( { feedback : e . target . value } ) ;
21
+ this . setState ( { [ e . target . name ] : e . target . value } ) ;
27
22
} ;
28
23
29
24
onSubmit = evt => {
30
25
const { id, user, signals } = this . props ;
31
- const { feedback, emoji } = this . state ;
26
+ const { feedback, emoji, email } = this . state ;
32
27
evt . preventDefault ( ) ;
33
28
34
29
this . setState ( { loading : true } , ( ) => {
35
- sendFeedback ( {
30
+ pushToAirtable ( {
36
31
sandboxId : id ,
37
32
feedback,
38
33
emoji,
39
- user,
34
+ username : ( user || { } ) . username ,
35
+ email,
40
36
} )
41
37
. then ( ( ) => {
42
38
this . setState (
@@ -76,18 +72,34 @@ class Feedback extends React.Component {
76
72
} ;
77
73
78
74
render ( ) {
79
- const { feedback, emoji } = this . state ;
75
+ const { feedback, emoji, email } = this . state ;
80
76
return (
81
77
< form onSubmit = { this . onSubmit } >
82
78
< AutosizeTextArea
83
79
css = { `
84
80
width: 100%;
85
81
` }
82
+ name = "feedback"
86
83
value = { feedback }
87
84
onChange = { this . onChange }
88
85
placeholder = "What are your thoughts?"
89
86
minRows = { 3 }
87
+ required
90
88
/>
89
+ { ! this . props . user && (
90
+ < Margin top = { 0.5 } >
91
+ < Input
92
+ css = { `
93
+ width: 100%;
94
+ ` }
95
+ type = "email"
96
+ name = "email"
97
+ value = { email }
98
+ onChange = { this . onChange }
99
+ placeholder = "Email if you wish to be contacted"
100
+ />
101
+ </ Margin >
102
+ ) }
91
103
92
104
< Margin
93
105
top = { 0.5 }
0 commit comments