@@ -3,7 +3,7 @@ import {connect} from 'react-redux'
33import _ from 'lodash'
44import FormsyForm from 'appirio-tech-react-components/components/Formsy'
55const Formsy = FormsyForm . Formsy
6- import { updateProject } from '../../../actions/project'
6+ import { updateProject , loadProjectBillingAccount } from '../../../actions/project'
77import NDAField from '../NDAField'
88import GroupsField from '../GroupsField'
99import BillingAccountField from '../BillingAccountField'
@@ -18,11 +18,13 @@ class EditProjectDefaultsForm extends React.Component {
1818
1919 this . state = {
2020 enableButton : false ,
21- isLoading : true
21+ isLoading : true ,
22+ isBillingAccountExpired : false ,
2223 }
2324
2425 this . handleChange = this . handleChange . bind ( this )
2526 this . handleSubmit = this . handleSubmit . bind ( this )
27+ this . setBillingAccountExpired = this . setBillingAccountExpired . bind ( this )
2628 }
2729
2830 componentDidMount ( ) {
@@ -35,6 +37,11 @@ class EditProjectDefaultsForm extends React.Component {
3537 }
3638 }
3739
40+ setBillingAccountExpired ( value ) {
41+ this . setState ( {
42+ isBillingAccountExpired : value
43+ } )
44+ }
3845 handleChange ( changed ) {
3946 const keys = _ . intersection ( Object . keys ( changed ) , Object . keys ( this . state . project ) )
4047 const reqProjectState = keys . reduce ( ( acc , curr ) => {
@@ -52,7 +59,7 @@ class EditProjectDefaultsForm extends React.Component {
5259 }
5360
5461 handleSubmit ( ) {
55- const { updateProject} = this . props
62+ const { updateProject, loadProjectBillingAccount } = this . props
5663 const { id} = this . props . project
5764 const updateProjectObj = Object . keys ( this . state . project )
5865 . filter ( key => ! _ . isEqual ( this . props . project [ key ] , this . state . project [ key ] ) )
@@ -61,7 +68,7 @@ class EditProjectDefaultsForm extends React.Component {
6168 return acc
6269 } , { } )
6370 updateProject ( id , updateProjectObj )
64- . then ( ( ) => this . setState ( { enableButton : false } ) )
71+ . then ( ( ) => this . setState ( { enableButton : false } ) ) . then ( ( ) => loadProjectBillingAccount ( id ) )
6572 . catch ( console . error )
6673 }
6774
@@ -86,14 +93,16 @@ class EditProjectDefaultsForm extends React.Component {
8693 < BillingAccountField
8794 name = "billingAccountId"
8895 projectId = { this . state . project . id }
96+ isExpired = { this . props . isBillingAccountExpired }
8997 value = { this . state . project . billingAccountId }
98+ setBillingAccountExpired = { this . setBillingAccountExpired }
9099 />
91100 </ div >
92101 < div className = "section-footer section-footer-spec" >
93102 < button
94103 className = "tc-btn tc-btn-primary tc-btn-md"
95104 type = "submit"
96- disabled = { ! this . state . enableButton }
105+ disabled = { this . state . isBillingAccountExpired || ! this . state . enableButton }
97106 >
98107 Save
99108 </ button >
@@ -105,7 +114,8 @@ class EditProjectDefaultsForm extends React.Component {
105114}
106115
107116const mapDispatchToProps = {
108- updateProject
117+ updateProject,
118+ loadProjectBillingAccount
109119}
110120
111121export default protectComponent (
0 commit comments