Skip to content

Commit 69d740a

Browse files
authored
Merge pull request #4272 from Expensify/jasper-disableSubmitButtonCompanyStep
Disable the submit button if required form fields are not filled out
2 parents 782ce71 + 79f9648 commit 69d740a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/pages/ReimbursementAccount/CompanyStep.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ class CompanyStep extends React.Component {
4545
hasNoConnectionToCannabis: lodashGet(props, ['achData', 'hasNoConnectionToCannabis'], false),
4646
password: '',
4747
};
48+
49+
// These fields need to be filled out in order to submit the form
50+
this.requiredFields = [
51+
'companyName',
52+
'addressStreet',
53+
'addressCity',
54+
'addressState',
55+
'addressZipCode',
56+
'website',
57+
'companyTaxID',
58+
'incorporationDate',
59+
'industryCode',
60+
'password',
61+
];
4862
}
4963

5064
/**
@@ -111,6 +125,8 @@ class CompanyStep extends React.Component {
111125
render() {
112126
const shouldDisableCompanyName = Boolean(this.props.achData.bankAccountID && this.props.achData.companyName);
113127
const shouldDisableCompanyTaxID = Boolean(this.props.achData.bankAccountID && this.props.achData.companyTaxID);
128+
const shouldDisableSubmitButton = this.requiredFields
129+
.reduce((acc, curr) => acc || !this.state[curr].trim(), false);
114130
return (
115131
<>
116132
<HeaderWithCloseButton
@@ -253,6 +269,7 @@ class CompanyStep extends React.Component {
253269
onPress={this.submit}
254270
style={[styles.w100]}
255271
text={this.props.translate('common.saveAndContinue')}
272+
isDisabled={shouldDisableSubmitButton}
256273
/>
257274
</FixedFooter>
258275
</>

0 commit comments

Comments
 (0)