@@ -3,7 +3,7 @@ import {connect} from 'react-redux'
3
3
import _ from 'lodash'
4
4
import FormsyForm from 'appirio-tech-react-components/components/Formsy'
5
5
const Formsy = FormsyForm . Formsy
6
- import { updateProject } from '../../../actions/project'
6
+ import { updateProject , loadProjectBillingAccount } from '../../../actions/project'
7
7
import NDAField from '../NDAField'
8
8
import GroupsField from '../GroupsField'
9
9
import BillingAccountField from '../BillingAccountField'
@@ -18,11 +18,13 @@ class EditProjectDefaultsForm extends React.Component {
18
18
19
19
this . state = {
20
20
enableButton : false ,
21
- isLoading : true
21
+ isLoading : true ,
22
+ isBillingAccountExpired : false ,
22
23
}
23
24
24
25
this . handleChange = this . handleChange . bind ( this )
25
26
this . handleSubmit = this . handleSubmit . bind ( this )
27
+ this . setBillingAccountExpired = this . setBillingAccountExpired . bind ( this )
26
28
}
27
29
28
30
componentDidMount ( ) {
@@ -35,6 +37,11 @@ class EditProjectDefaultsForm extends React.Component {
35
37
}
36
38
}
37
39
40
+ setBillingAccountExpired ( value ) {
41
+ this . setState ( {
42
+ isBillingAccountExpired : value
43
+ } )
44
+ }
38
45
handleChange ( changed ) {
39
46
const keys = _ . intersection ( Object . keys ( changed ) , Object . keys ( this . state . project ) )
40
47
const reqProjectState = keys . reduce ( ( acc , curr ) => {
@@ -52,7 +59,7 @@ class EditProjectDefaultsForm extends React.Component {
52
59
}
53
60
54
61
handleSubmit ( ) {
55
- const { updateProject} = this . props
62
+ const { updateProject, loadProjectBillingAccount } = this . props
56
63
const { id} = this . props . project
57
64
const updateProjectObj = Object . keys ( this . state . project )
58
65
. filter ( key => ! _ . isEqual ( this . props . project [ key ] , this . state . project [ key ] ) )
@@ -61,7 +68,7 @@ class EditProjectDefaultsForm extends React.Component {
61
68
return acc
62
69
} , { } )
63
70
updateProject ( id , updateProjectObj )
64
- . then ( ( ) => this . setState ( { enableButton : false } ) )
71
+ . then ( ( ) => this . setState ( { enableButton : false } ) ) . then ( ( ) => loadProjectBillingAccount ( id ) )
65
72
. catch ( console . error )
66
73
}
67
74
@@ -86,14 +93,16 @@ class EditProjectDefaultsForm extends React.Component {
86
93
< BillingAccountField
87
94
name = "billingAccountId"
88
95
projectId = { this . state . project . id }
96
+ isExpired = { this . props . isBillingAccountExpired }
89
97
value = { this . state . project . billingAccountId }
98
+ setBillingAccountExpired = { this . setBillingAccountExpired }
90
99
/>
91
100
</ div >
92
101
< div className = "section-footer section-footer-spec" >
93
102
< button
94
103
className = "tc-btn tc-btn-primary tc-btn-md"
95
104
type = "submit"
96
- disabled = { ! this . state . enableButton }
105
+ disabled = { this . state . isBillingAccountExpired || ! this . state . enableButton }
97
106
>
98
107
Save
99
108
</ button >
@@ -105,7 +114,8 @@ class EditProjectDefaultsForm extends React.Component {
105
114
}
106
115
107
116
const mapDispatchToProps = {
108
- updateProject
117
+ updateProject,
118
+ loadProjectBillingAccount
109
119
}
110
120
111
121
export default protectComponent (
0 commit comments