diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 8d0c59ab8d60..34143251d768 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -119,6 +119,18 @@ function getVBBADataForOnyx(currentStep?: BankAccountStep): OnyxData { }; } +function addBusinessWebsiteForDraft(website: string) { + Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, {website}); +} + +function addBusinessAddressForDraft(businessAddress: {addressStreet?: string; addressCity?: string; addressState?: string; addressZipCode?: string}) { + Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, businessAddress); +} + +function addPersonalAddressForDraft(personalAddress: {requestorAddressStreet?: string; requestorAddressCity?: string; requestorAddressState?: string; requestorAddressZipCode?: string}) { + Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, personalAddress); +} + /** * Submit Bank Account step with Plaid data so php can perform some checks. */ @@ -433,6 +445,9 @@ function setReimbursementAccountLoading(isLoading: boolean) { } export { + addBusinessWebsiteForDraft, + addBusinessAddressForDraft, + addPersonalAddressForDraft, addPersonalBankAccount, clearOnfidoToken, clearPersonalBankAccount, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js b/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js index 271916c0cbc5..11f271a3043e 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js @@ -125,7 +125,7 @@ function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, policyID {}} // TODO Will be replaced with proper values - startStep={2} + startStep={1} stepNames={STEP_NAMES} /> diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js index c94505b1b46e..70e17e97e973 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js @@ -1,6 +1,6 @@ import React from 'react'; import {withOnyx} from 'react-native-onyx'; -import Form from '@components/Form'; +import FormProvider from '@components/Form/FormProvider'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import * as ValidationUtils from '@libs/ValidationUtils'; @@ -9,6 +9,7 @@ import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@ import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import styles from '@styles/styles'; +import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -58,12 +59,17 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}) { zipCode: getDefaultValueForReimbursementAccountField(reimbursementAccount, companyBusinessInfoKey.ZIP_CODE, ''), }; + const handleSubmit = (values) => { + BankAccounts.addBusinessAddressForDraft(values); + onNext(); + }; + return ( -
@@ -76,7 +82,7 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}) { defaultValues={defaultValues} streetTranslationKey="common.companyAddress" /> -
+ ); } diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js index d6d98e5ef360..37be528310ba 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js @@ -3,7 +3,7 @@ import {ScrollView, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import CheckboxWithLabel from '@components/CheckboxWithLabel'; import DotIndicatorMessage from '@components/DotIndicatorMessage'; -import Form from '@components/Form'; +import FormProvider from '@components/Form/FormProvider'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; @@ -129,7 +129,7 @@ function ConfirmationBusiness({reimbursementAccount, reimbursementAccountDraft, onMove(7); }} /> -
( @@ -156,7 +156,7 @@ function ConfirmationBusiness({reimbursementAccount, reimbursementAccountDraft, shouldSaveDraft onInputChange={() => {}} /> - + {error.length > 0 && ( { + BankAccounts.addBusinessWebsiteForDraft(defaultCompanyWebsite); + }, [defaultCompanyWebsite]); + return (
{ const {translate} = useLocalize(); const values = useMemo(() => getSubstepValues(personalInfoStepKeys, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); @@ -63,7 +65,7 @@ function PersonalInfo({reimbursementAccount, reimbursementAccountDraft}) { const handleBackButtonPress = () => { if (screenIndex === 0) { - Navigation.goBack(ROUTES.HOME); + onBackButtonPress(); } else { prevScreen(); } @@ -71,6 +73,7 @@ function PersonalInfo({reimbursementAccount, reimbursementAccountDraft}) { return ( {}} // TODO Will be replaced with proper values - startStep={1} + startStep={2} stepNames={STEP_NAMES} /> @@ -95,7 +98,7 @@ function PersonalInfo({reimbursementAccount, reimbursementAccountDraft}) { /> ); -} +}); PersonalInfo.propTypes = propTypes; PersonalInfo.defaultProps = defaultProps; diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.js b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.js index 6ac9d4913d6f..8cc8797e3bcf 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.js +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.js @@ -1,7 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; -import Form from '@components/Form'; +import FormProvider from '@components/Form/FormProvider'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import * as ValidationUtils from '@libs/ValidationUtils'; @@ -12,6 +12,7 @@ import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimburs import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import styles from '@styles/styles'; +import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -61,12 +62,17 @@ function Address({reimbursementAccount, onNext, isEditing}) { zipCode: getDefaultValueForReimbursementAccountField(reimbursementAccount, personalInfoStepKey.ZIP_CODE, ''), }; + const handleSubmit = (values) => { + BankAccounts.addPersonalAddressForDraft(values); + onNext(); + }; + return ( - @@ -85,7 +91,7 @@ function Address({reimbursementAccount, onNext, isEditing}) { containerStyles={[styles.mt5]} /> -
+ ); } diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.js b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.js index 04e38d36e330..3ca6146f4275 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.js +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.js @@ -1,3 +1,4 @@ +import lodashGet from 'lodash/get'; import React, {useMemo} from 'react'; import {ScrollView, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -38,6 +39,7 @@ const personalInfoStepKeys = CONST.BANK_ACCOUNT.PERSONAL_INFO_STEP.INPUT_KEY; function Confirmation({reimbursementAccount, reimbursementAccountDraft, onNext, onMove}) { const {translate} = useLocalize(); + const isLoading = lodashGet(reimbursementAccount, 'isLoading', false); const values = useMemo(() => getSubstepValues(personalInfoStepKeys, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const error = ErrorUtils.getLatestErrorMessage(reimbursementAccount); @@ -117,6 +119,7 @@ function Confirmation({reimbursementAccount, reimbursementAccountDraft, onNext, )}