File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
client/components/CreateProjectForm Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ class CreateProjectForm extends Component {
38
38
this . setState ( { projectName : event . target . value } )
39
39
}
40
40
41
- async createProject ( ) {
41
+ async createProject ( event ) {
42
+ event . preventDefault ( )
42
43
const response = await projectsApiClient . createProject (
43
44
this . state . projectName ,
44
45
this . state . causes ,
@@ -47,6 +48,8 @@ class CreateProjectForm extends Component {
47
48
)
48
49
if ( response . status === 500 ) {
49
50
this . setState ( { error : response . statusText } )
51
+ } else {
52
+ this . context . router . history . push ( '/profile' )
50
53
}
51
54
}
52
55
@@ -101,6 +104,11 @@ class CreateProjectForm extends Component {
101
104
Create Project
102
105
</ Button >
103
106
107
+ { this . state . error &&
108
+ < div className = { styles . errorContent } >
109
+ { this . state . error }
110
+ </ div >
111
+ }
104
112
</ form >
105
113
)
106
114
}
@@ -113,6 +121,10 @@ function mapStateToProps (state) {
113
121
}
114
122
}
115
123
124
+ CreateProjectForm . contextTypes = {
125
+ router : PropTypes . object
126
+ }
127
+
116
128
CreateProjectForm . propTypes = {
117
129
error : PropTypes . string ,
118
130
handleSubmit : PropTypes . func ,
Original file line number Diff line number Diff line change 28
28
grid-column : 1 / 1 ;
29
29
grid-row : 8 ;
30
30
}
31
+
32
+ .errorContent {
33
+ grid-row : 9 ;
34
+ grid-column : 1 / 1 ;
35
+ font-size : 1rem ;
36
+ color : $errorColor ;
37
+ }
You can’t perform that action at this time.
0 commit comments