@@ -2,9 +2,8 @@ import React, { Component } from 'react';
2
2
import * as WinesService from '../services/Wines' ;
3
3
4
4
export class CommentModal extends Component {
5
-
6
5
state = {
7
- comment : ''
6
+ comment : '' ,
8
7
} ;
9
8
10
9
componentDidMount ( ) {
@@ -28,36 +27,52 @@ export class CommentModal extends Component {
28
27
window . $ ( this . modalNode ) . closeModal ( ) ;
29
28
}
30
29
31
- onSubmit = ( e ) => {
30
+ onSubmit = e => {
32
31
e . preventDefault ( ) ;
33
32
const comment = this . state . comment ;
34
33
this . setState ( { comment : '' } ) ;
35
34
WinesService . commentWine ( this . props . wine . id , comment ) . then ( ( ) => {
36
35
this . props . closeCommentModal ( ) ;
37
36
} ) ;
38
- }
37
+ } ;
39
38
40
- onCommentChange = ( e ) => {
39
+ onCommentChange = e => {
41
40
this . setState ( { comment : e . target . value } ) ;
42
- }
43
-
41
+ } ;
42
+
44
43
render ( ) {
45
44
return (
46
- < div ref = { ref => this . modalNode = ref } className = "modal" >
45
+ < div ref = { ref => ( this . modalNode = ref ) } className = "modal" >
47
46
< div className = "modal-content" >
48
47
< h4 > Tell us something about this wine</ h4 >
49
48
< form className = "col s12" >
50
49
< div className = "row" >
51
50
< div className = "input-field col s12" >
52
- < input id = "inputComment" type = "text" className = "validate" value = { this . state . comment } onChange = { this . onCommentChange } />
51
+ < input
52
+ id = "inputComment"
53
+ type = "text"
54
+ className = "validate"
55
+ value = { this . state . comment }
56
+ onChange = { this . onCommentChange }
57
+ />
53
58
< label htmlFor = "inputComment" > Your comment</ label >
54
59
</ div >
55
60
</ div >
56
61
</ form >
57
62
</ div >
58
63
< div className = "modal-footer" >
59
- < a href = "#!" className = "modal-action waves-effect waves-green btn-flat " onClick = { this . onSubmit } > Submit</ a >
60
- < a href = "#!" className = "modal-action waves-effect waves-green btn-flat " onClick = { this . props . closeCommentModal } > Cancel</ a >
64
+ < a
65
+ href = "#!"
66
+ className = "modal-action waves-effect waves-green btn-flat "
67
+ onClick = { this . onSubmit } >
68
+ Submit
69
+ </ a >
70
+ < a
71
+ href = "#!"
72
+ className = "modal-action waves-effect waves-green btn-flat "
73
+ onClick = { this . props . closeCommentModal } >
74
+ Cancel
75
+ </ a >
61
76
</ div >
62
77
</ div >
63
78
) ;
0 commit comments