-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Business Info Page #30924
Business Info Page #30924
Changes from 19 commits
4f13317
d493d3a
82e383c
942d549
cfd4ace
36e10e6
ce24ca8
316040a
92b0ae2
de9b598
098e60c
427ab33
8152cd4
4a29bc9
e229faa
0a33668
72cc6f1
dff94a5
8d579c5
72546e5
8fa9a25
3b668bc
749e6a0
d4a6cc4
eafe68b
2b2f4a2
8197628
87f077c
1140b43
5fd108e
d6bd017
218c487
4fe37bb
75fae66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1390,6 +1390,37 @@ export default { | |
letsDoubleCheck: 'Revisemos que todo esté bien', | ||
byAddingThisBankAccount: 'Agregando esta cuenta bancaria, confirmas que as leído, entendido y aceptado', | ||
}, | ||
businessInfoStep: { | ||
businessInfo: 'Información de Negocio', | ||
enterTheNameOfYourBusiness: 'Introduzca el nombre de su negocio.', | ||
businessName: 'Nombre del Negocio', | ||
enterYourCompanysTaxIdNumber: 'Introduzca el número de identificación fiscal.', | ||
taxIDNumber: 'Número de identificación fiscal', | ||
taxIDNumberPlaceholder: '9 dígitos', | ||
enterYourCompanysWebsite: 'Introduzca el sitio web de su compañia.', | ||
companyWebsite: 'Sitio web de la compañia', | ||
enterYourCompanysPhoneNumber: 'Introduzca el número de teléfono de su compañia.', | ||
enterYourCompanysAddress: 'Introduzca el la dirección de su compañia.', | ||
selectYourCompanysType: 'Seleccione el tipo de compañia.', | ||
companyType: 'Tipo de compañia', | ||
incorporationType: { | ||
LLC: 'SRL', | ||
CORPORATION: 'Corporación', | ||
PARTNERSHIP: 'Asociación', | ||
COOPERATIVE: 'Cooperativa', | ||
SOLE_PROPRIETORSHIP: 'Empresa unipersonal', | ||
OTHER: 'Otros', | ||
}, | ||
selectYourCompanysIncorporationDate: 'Seleccione la fecha de constitución de su empresa.', | ||
incorporationDate: 'Fecha de constitución', | ||
incorporationDatePlaceholder: 'Fecha de inicio (yyyy-mm-dd)', | ||
incorporationState: 'Estado de constitución', | ||
pleaseSelectTheStateYourCompanyWasIncorporatedIn: 'Seleccione el estado en el que se constituyó su empresa.', | ||
letsDoubleCheck: 'Verifiquemos que todo esté correcto', | ||
companyAddress: 'Dirección de la empresa', | ||
listOfRestrictedBusinesses: 'lista de negocios restringidos', | ||
confirmCompanyIsNot: 'Confirmo que esta empresa no está en la', | ||
}, | ||
Comment on lines
+1391
to
+1420
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you confirm the verification of these in slack? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as with the other parts of this flow, given time constraints, it's been said that we will have a final check towards the end of the work on it, accepted as non blocking by Vit here |
||
validationStep: { | ||
headerTitle: 'Validar cuenta bancaria', | ||
buttonText: 'Finalizar configuración', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import React, {useCallback, useMemo} from 'react'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import lodashGet from 'lodash/get'; | ||
import _ from 'underscore'; | ||
import {parsePhoneNumber} from 'awesome-phonenumber'; | ||
import PropTypes from 'prop-types'; | ||
import useSubStep from '../../../hooks/useSubStep'; | ||
import ONYXKEYS from '../../../ONYXKEYS'; | ||
import {reimbursementAccountPropTypes} from '../reimbursementAccountPropTypes'; | ||
import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; | ||
import InteractiveStepSubHeader from '../../../components/InteractiveStepSubHeader'; | ||
import useLocalize from '../../../hooks/useLocalize'; | ||
import styles from '../../../styles/styles'; | ||
import CONST from '../../../CONST'; | ||
import * as BankAccounts from '../../../libs/actions/BankAccounts'; | ||
import Navigation from '../../../libs/Navigation/Navigation'; | ||
import ROUTES from '../../../ROUTES'; | ||
import ScreenWrapper from '../../../components/ScreenWrapper'; | ||
import getDefaultStateForField from '../utils/getDefaultStateForField'; | ||
import NameBusiness from './substeps/NameBusiness'; | ||
import TaxIdBusiness from './substeps/TaxIdBusiness'; | ||
import WebsiteBusiness from './substeps/WebsiteBusiness'; | ||
import PhoneNumberBusiness from './substeps/PhoneNumberBusiness'; | ||
import AddressBusiness from './substeps/AddressBusiness'; | ||
import TypeBusiness from './substeps/TypeBusiness'; | ||
import IncorporationDateBusiness from './substeps/IncorporationDateBusiness'; | ||
import IncorporationStateBusiness from './substeps/IncorporationStateBusiness'; | ||
import ConfirmationBusiness from './substeps/ConfirmationBusiness'; | ||
import getSubstepValues from '../utils/getSubstepValues'; | ||
import reimbursementAccountDraftPropTypes from '../ReimbursementAccountDraftPropTypes'; | ||
import * as ReimbursementAccountProps from '../reimbursementAccountPropTypes'; | ||
import getInitialSubstepForBusinessInfo from '../utils/getInitialSubstepForBusinessInfo'; | ||
|
||
const propTypes = { | ||
/** Reimbursement account from ONYX */ | ||
reimbursementAccount: reimbursementAccountPropTypes, | ||
|
||
/** The draft values of the bank account being setup */ | ||
reimbursementAccountDraft: reimbursementAccountDraftPropTypes, | ||
|
||
/* The workspace policyID */ | ||
policyID: PropTypes.string, | ||
}; | ||
|
||
const defaultProps = { | ||
reimbursementAccount: ReimbursementAccountProps.reimbursementAccountDefaultProps, | ||
reimbursementAccountDraft: {}, | ||
policyID: '', | ||
}; | ||
|
||
const STEPS_HEADER_HEIGHT = 40; | ||
// TODO Will most likely come from different place | ||
Swor71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const STEP_NAMES = ['1', '2', '3', '4', '5']; | ||
|
||
const bodyContent = [ | ||
NameBusiness, | ||
TaxIdBusiness, | ||
WebsiteBusiness, | ||
PhoneNumberBusiness, | ||
AddressBusiness, | ||
TypeBusiness, | ||
IncorporationDateBusiness, | ||
IncorporationStateBusiness, | ||
ConfirmationBusiness, | ||
]; | ||
|
||
const businessInfoStepKeys = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY; | ||
|
||
function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, policyID}) { | ||
const {translate} = useLocalize(); | ||
|
||
/** | ||
* @param {Array} fieldNames | ||
* | ||
* @returns {*} | ||
*/ | ||
const getBankAccountFields = useCallback( | ||
(fieldNames) => ({ | ||
..._.pick(lodashGet(reimbursementAccount, 'achData'), ...fieldNames), | ||
..._.pick(reimbursementAccountDraft, ...fieldNames), | ||
}), | ||
[reimbursementAccount, reimbursementAccountDraft], | ||
); | ||
|
||
const submit = useCallback(() => { | ||
const values = getSubstepValues(businessInfoStepKeys, reimbursementAccountDraft, reimbursementAccount); | ||
|
||
const payload = { | ||
bankAccountID: getDefaultStateForField({reimbursementAccount, fieldName: 'bankAccountID', defaultValue: 0}), | ||
...values, | ||
...getBankAccountFields(['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']), | ||
companyTaxID: values.companyTaxID.replace(CONST.REGEX.NON_NUMERIC, ''), | ||
companyPhone: parsePhoneNumber(values.companyPhone, {regionCode: CONST.COUNTRY.US}).number.significant, | ||
Comment on lines
+89
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. {BZ Checklist} this might have caused #50103, RC:
This was fixed in #50715 |
||
}; | ||
|
||
BankAccounts.updateCompanyInformationForBankAccount(payload, policyID); | ||
}, [getBankAccountFields, reimbursementAccount, reimbursementAccountDraft, policyID]); | ||
|
||
const startFrom = useMemo(() => getInitialSubstepForBusinessInfo(lodashGet(reimbursementAccount, ['achData'], {})), [reimbursementAccount]); | ||
Swor71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo} = useSubStep({bodyContent, startFrom, onFinished: submit}); | ||
|
||
const handleBackButtonPress = () => { | ||
if (screenIndex === 0) { | ||
Navigation.goBack(ROUTES.HOME); | ||
} else { | ||
prevScreen(); | ||
} | ||
}; | ||
|
||
return ( | ||
<ScreenWrapper | ||
testID={BusinessInfo.displayName} | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnablePickerAvoiding={false} | ||
shouldEnableMaxHeight | ||
> | ||
<HeaderWithBackButton | ||
title={translate('businessInfoStep.businessInfo')} | ||
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BANK_ACCOUNT} | ||
onBackButtonPress={handleBackButtonPress} | ||
/> | ||
<View style={[styles.ph5, styles.mv3, {height: STEPS_HEADER_HEIGHT}]}> | ||
<InteractiveStepSubHeader | ||
onStepSelected={() => {}} | ||
// TODO Will be replaced with proper values | ||
startStep={2} | ||
stepNames={STEP_NAMES} | ||
/> | ||
</View> | ||
<SubStep | ||
isEditing={isEditing} | ||
onNext={nextScreen} | ||
onMove={moveTo} | ||
/> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
BusinessInfo.propTypes = propTypes; | ||
BusinessInfo.defaultProps = defaultProps; | ||
BusinessInfo.displayName = 'BusinessInfo'; | ||
|
||
export default withOnyx({ | ||
reimbursementAccount: { | ||
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, | ||
}, | ||
reimbursementAccountDraft: { | ||
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, | ||
}, | ||
})(BusinessInfo); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {View} from 'react-native'; | ||
import useLocalize from '../../../../hooks/useLocalize'; | ||
import styles from '../../../../styles/styles'; | ||
import Text from '../../../../components/Text'; | ||
import CONST from '../../../../CONST'; | ||
import Form from '../../../../components/Form'; | ||
import ONYXKEYS from '../../../../ONYXKEYS'; | ||
import subStepPropTypes from '../../subStepPropTypes'; | ||
import * as ValidationUtils from '../../../../libs/ValidationUtils'; | ||
import {reimbursementAccountPropTypes} from '../../reimbursementAccountPropTypes'; | ||
import getDefaultStateForField from '../../utils/getDefaultStateForField'; | ||
import AddressForm from '../../AddressForm'; | ||
|
||
const propTypes = { | ||
/** Reimbursement account from ONYX */ | ||
reimbursementAccount: reimbursementAccountPropTypes.isRequired, | ||
Swor71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
...subStepPropTypes, | ||
}; | ||
|
||
const companyBusinessInfoKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY; | ||
|
||
const INPUT_KEYS = { | ||
street: companyBusinessInfoKey.STREET, | ||
city: companyBusinessInfoKey.CITY, | ||
state: companyBusinessInfoKey.STATE, | ||
zipCode: companyBusinessInfoKey.ZIP_CODE, | ||
}; | ||
|
||
const REQUIRED_FIELDS = [companyBusinessInfoKey.STREET, companyBusinessInfoKey.CITY, companyBusinessInfoKey.STATE, companyBusinessInfoKey.ZIP_CODE]; | ||
|
||
const validate = (values) => { | ||
const errors = ValidationUtils.getFieldRequiredErrors(values, REQUIRED_FIELDS); | ||
|
||
if (values.addressStreet && !ValidationUtils.isValidAddress(values.addressStreet)) { | ||
errors.addressStreet = 'bankAccount.error.addressStreet'; | ||
} | ||
|
||
if (values.addressZipCode && !ValidationUtils.isValidZipCode(values.addressZipCode)) { | ||
errors.addressZipCode = 'bankAccount.error.zipCode'; | ||
} | ||
|
||
return errors; | ||
}; | ||
|
||
function AddressBusiness({reimbursementAccount, onNext, isEditing}) { | ||
const {translate} = useLocalize(); | ||
|
||
const defaultValues = { | ||
street: getDefaultStateForField({reimbursementAccount, fieldName: companyBusinessInfoKey.STREET, defaultValue: ''}), | ||
city: getDefaultStateForField({reimbursementAccount, fieldName: companyBusinessInfoKey.CITY, defaultValue: ''}), | ||
state: getDefaultStateForField({reimbursementAccount, fieldName: companyBusinessInfoKey.STATE, defaultValue: ''}), | ||
zipCode: getDefaultStateForField({reimbursementAccount, fieldName: companyBusinessInfoKey.ZIP_CODE, defaultValue: ''}), | ||
}; | ||
|
||
return ( | ||
<Form | ||
formID={ONYXKEYS.REIMBURSEMENT_ACCOUNT} | ||
submitButtonText={isEditing ? translate('common.confirm') : translate('common.next')} | ||
validate={validate} | ||
onSubmit={onNext} | ||
submitButtonStyles={[styles.mb0, styles.pb5]} | ||
style={[styles.mh5, styles.flexGrow1]} | ||
> | ||
<View> | ||
<Text style={[styles.textHeadline]}>{translate('businessInfoStep.enterYourCompanysAddress')}</Text> | ||
<Text>{translate('common.noPO')}</Text> | ||
<AddressForm | ||
inputKeys={INPUT_KEYS} | ||
shouldSaveDraft | ||
translate={translate} | ||
defaultValues={defaultValues} | ||
streetTranslationKey="common.companyAddress" | ||
/> | ||
</View> | ||
</Form> | ||
); | ||
} | ||
|
||
AddressBusiness.propTypes = propTypes; | ||
AddressBusiness.displayName = 'AddressBusiness'; | ||
|
||
export default withOnyx({ | ||
reimbursementAccount: { | ||
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, | ||
}, | ||
})(AddressBusiness); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not companyWebsite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that has been used before, can we fix it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mountiny hm where did you find
companyWebsite
as the key? I've moved what was there in the CompanyStep component to the new components and their respective keys:https://github.com/Expensify/App/pull/30924/files#diff-40ada854d0b6039d4db7da6cede12f7be0cf7d113cc16c8cbc638af4bd0121d4L81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless you meant the translation, which is here https://github.com/Expensify/App/pull/30924/files#diff-2a9066512656fa29b1565e362127de5cc11ba95b28f143a9db26f76dc3750785R1379
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed we can do that later