1
1
import _ from 'underscore' ;
2
+ import lodashGet from 'lodash/get' ;
2
3
import React from 'react' ;
3
4
import { View } from 'react-native' ;
4
5
import Str from 'expensify-common/lib/str' ;
@@ -22,7 +23,7 @@ import TextLink from '../../components/TextLink';
22
23
import StatePicker from '../../components/StatePicker' ;
23
24
import withLocalize , { withLocalizePropTypes } from '../../components/withLocalize' ;
24
25
import {
25
- isValidAddress , isValidDate , isValidZipCode , isRequiredFulfilled ,
26
+ isValidAddress , isValidDate , isValidZipCode , isRequiredFulfilled , isValidURL ,
26
27
} from '../../libs/ValidationUtils' ;
27
28
import compose from '../../libs/compose' ;
28
29
import ONYXKEYS from '../../ONYXKEYS' ;
@@ -45,14 +46,18 @@ class CompanyStep extends React.Component {
45
46
46
47
this . submit = this . submit . bind ( this ) ;
47
48
49
+ this . defaultWebsite = lodashGet ( props , 'user.isFromPublicDomain' , false )
50
+ ? 'https://'
51
+ : `https://www.${ Str . extractEmailDomain ( props . session . email , '' ) } ` ;
52
+
48
53
this . state = {
49
54
companyName : ReimbursementAccountUtils . getDefaultStateForField ( props , 'companyName' ) ,
50
55
addressStreet : ReimbursementAccountUtils . getDefaultStateForField ( props , 'addressStreet' ) ,
51
56
addressCity : ReimbursementAccountUtils . getDefaultStateForField ( props , 'addressCity' ) ,
52
57
addressState : ReimbursementAccountUtils . getDefaultStateForField ( props , 'addressState' ) ,
53
58
addressZipCode : ReimbursementAccountUtils . getDefaultStateForField ( props , 'addressZipCode' ) ,
54
59
companyPhone : ReimbursementAccountUtils . getDefaultStateForField ( props , 'companyPhone' ) ,
55
- website : ReimbursementAccountUtils . getDefaultStateForField ( props , 'website' , 'https://' ) ,
60
+ website : ReimbursementAccountUtils . getDefaultStateForField ( props , 'website' , this . defaultWebsite ) ,
56
61
companyTaxID : ReimbursementAccountUtils . getDefaultStateForField ( props , 'companyTaxID' ) ,
57
62
incorporationType : ReimbursementAccountUtils . getDefaultStateForField ( props , 'incorporationType' ) ,
58
63
incorporationDate : ReimbursementAccountUtils . getDefaultStateForField ( props , 'incorporationDate' ) ,
@@ -130,7 +135,7 @@ class CompanyStep extends React.Component {
130
135
errors . addressZipCode = true ;
131
136
}
132
137
133
- if ( ! Str . isValidURL ( this . state . website ) ) {
138
+ if ( ! isValidURL ( this . state . website ) ) {
134
139
errors . website = true ;
135
140
}
136
141
@@ -334,5 +339,11 @@ export default compose(
334
339
reimbursementAccountDraft : {
335
340
key : ONYXKEYS . REIMBURSEMENT_ACCOUNT_DRAFT ,
336
341
} ,
342
+ session : {
343
+ key : ONYXKEYS . SESSION ,
344
+ } ,
345
+ user : {
346
+ key : ONYXKEYS . USER ,
347
+ } ,
337
348
} ) ,
338
349
) ( CompanyStep ) ;
0 commit comments