From 81e594c7bb1c92b05ce77593155589ad02846242 Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 25 Nov 2024 10:15:41 +0100 Subject: [PATCH 001/138] step 3 implementation applied --- src/CONST.ts | 1 + src/languages/en.ts | 5 ++ src/languages/es.ts | 5 ++ .../GetCorpayOnboardingFieldsParams.ts | 7 ++ ...aveCorpayOnboardingCompanyDetailsParams.ts | 31 +++++++ src/libs/API/parameters/index.ts | 2 + src/libs/API/types.ts | 2 + src/libs/ValidationUtils.ts | 87 +++++++++++++++++++ src/libs/actions/BankAccounts.ts | 15 ++++ .../NonUSD/BusinessInfo/BusinessInfo.tsx | 81 ++++++++++++++++- .../BusinessInfo/substeps/Confirmation.tsx | 17 +++- .../substeps/RegistrationNumber.tsx | 22 +++-- .../BusinessInfo/substeps/TaxIDEINNumber.tsx | 57 ++++++++++++ .../NonUSD/SignerInfo/HangTight.tsx | 2 +- .../NonUSD/SignerInfo/index.tsx | 1 + 15 files changed, 321 insertions(+), 14 deletions(-) create mode 100644 src/libs/API/parameters/GetCorpayOnboardingFieldsParams.ts create mode 100644 src/libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams.ts create mode 100644 src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/TaxIDEINNumber.tsx diff --git a/src/CONST.ts b/src/CONST.ts index c28914541113..de77a0881d8c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -614,6 +614,7 @@ const CONST = { ALLOWED_FILE_TYPES: ['pdf', 'jpg', 'jpeg', 'png'], FILE_LIMIT: 10, TOTAL_FILES_SIZE_LIMIT: 5242880, + PURPOSE_OF_TRANSACTION_ID: 8, STEP: { COUNTRY: 'CountryStep', BANK_INFO: 'BankInfoStep', diff --git a/src/languages/en.ts b/src/languages/en.ts index d79695ed8b48..ccfeacc3cd49 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2206,11 +2206,13 @@ const translations = { whatsTheBusinessAddress: "What's the business address?", whatsTheBusinessContactInformation: "What's the business contact information?", whatsTheBusinessRegistrationNumber: "What's the business registration number?", + whatsTheBusinessTaxIDEIN: "What's the business tax ID/EIN/VAT/GST Registration number?", whatsThisNumber: "What's this number?", whereWasTheBusinessIncorporated: 'Where was the business incorporated?', whatTypeOfBusinessIsIt: 'What type of business is it?', whatsTheBusinessAnnualPayment: "What's the business's annual payment volume?", registrationNumber: 'Registration number', + taxIDEIN: 'Tax ID/EIN number', businessAddress: 'Business address', businessType: 'Business type', incorporation: 'Incorporation', @@ -2228,6 +2230,9 @@ const translations = { findBusinessCategory: 'Find business category', findAnnualPaymentVolume: 'Find annual payment volume', findIncorporationState: 'Find incorporation state', + error: { + registrationNumber: 'Please provide a valid registration number.', + } }, beneficialOwnerInfoStep: { doYouOwn25percent: 'Do you own 25% or more of', diff --git a/src/languages/es.ts b/src/languages/es.ts index 5ce47db18d35..b16d29d597ff 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2230,11 +2230,13 @@ const translations = { whatsTheBusinessAddress: '¿Cuál es la dirección de la empresa?', whatsTheBusinessContactInformation: '¿Cuál es la información de contacto de la empresa?', whatsTheBusinessRegistrationNumber: '¿Cuál es el número de registro de la empresa?', + whatsTheBusinessTaxIDEIN: '¿Cuál es el número de identificación fiscal/EIN/IVA/GST de la empresa?', whatsThisNumber: '¿Qué es este número?', whereWasTheBusinessIncorporated: '¿Dónde se constituyó la empresa?', whatTypeOfBusinessIsIt: '¿Qué tipo de empresa es?', whatsTheBusinessAnnualPayment: '¿Cuál es el volumen anual de pagos de la empresa?', registrationNumber: 'Número de registro', + taxIDEIN: 'Número de identificación fiscal/EIN', businessAddress: 'Dirección de la empresa', businessType: 'Tipo de empresa', incorporation: 'Constitución', @@ -2252,6 +2254,9 @@ const translations = { findBusinessCategory: 'Buscar categoría de la empresa', findAnnualPaymentVolume: 'Buscar volumen anual de pagos', findIncorporationState: 'Buscar estado de constitución', + error: { + registrationNumber: 'Por favor, proporcione un número de registro válido.', + }, }, beneficialOwnerInfoStep: { doYouOwn25percent: '¿Posees el 25% o más de', diff --git a/src/libs/API/parameters/GetCorpayOnboardingFieldsParams.ts b/src/libs/API/parameters/GetCorpayOnboardingFieldsParams.ts new file mode 100644 index 000000000000..8b217e253282 --- /dev/null +++ b/src/libs/API/parameters/GetCorpayOnboardingFieldsParams.ts @@ -0,0 +1,7 @@ +import type {Country} from '@src/CONST'; + +type GetCorpayOnboardingFieldsParams = { + countryISO: Country | ''; +}; + +export default GetCorpayOnboardingFieldsParams; diff --git a/src/libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams.ts b/src/libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams.ts new file mode 100644 index 000000000000..d48d1efcfaa9 --- /dev/null +++ b/src/libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams.ts @@ -0,0 +1,31 @@ +import type CONST from '@src/CONST'; + +type SaveCorpayOnboardingCompanyDetails = { + annualVolume: string; + applicantTypeId: string; + companyName: string; + companyStreetAddress: string; + companyCity: string; + companyState?: string; + companyPostalCode: string; + companyCountryCode: string; + currencyNeeded: string; + businessContactNumber: string; + businessConfirmationEmail: string; + businessRegistrationIncorporationNumber: string; + formationIncorporationCountryCode: string; + formationIncorporationState?: string; + fundDestinationCountries: string; + fundSourceCountries: string; + natureOfBusiness: string; + purposeOfTransactionId: typeof CONST.NON_USD_BANK_ACCOUNT.PURPOSE_OF_TRANSACTION_ID; + tradeVolume: string; + taxIDEINNumber: string; +}; + +type SaveCorpayOnboardingCompanyDetailsParams = { + inputs: string; + bankAccountID: number; +}; + +export type {SaveCorpayOnboardingCompanyDetails, SaveCorpayOnboardingCompanyDetailsParams}; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 6a510d074f98..f42653dc1e6a 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -352,3 +352,5 @@ export type {default as OpenPolicyPerDiemRatesPageParams} from './OpenPolicyPerD export type {default as TogglePlatformMuteParams} from './TogglePlatformMuteParams'; export type {default as ImportPerDiemRatesParams} from './ImportPerDiemRatesParams'; export type {default as ExportPerDiemCSVParams} from './ExportPerDiemCSVParams'; +export type {default as GetCorpayOnboardingFieldsParams} from './GetCorpayOnboardingFieldsParams'; +export type {SaveCorpayOnboardingCompanyDetailsParams} from './SaveCorpayOnboardingCompanyDetailsParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 892bad17928e..1d99c626a9f0 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -438,6 +438,7 @@ const WRITE_COMMANDS = { SELF_TOUR_VIEWED: 'SelfTourViewed', UPDATE_INVOICE_COMPANY_NAME: 'UpdateInvoiceCompanyName', UPDATE_INVOICE_COMPANY_WEBSITE: 'UpdateInvoiceCompanyWebsite', + SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS: 'SaveCorpayOnboardingCompanyDetails', } as const; type WriteCommand = ValueOf; @@ -762,6 +763,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY]: Parameters.UpdateSubscriptionAddNewUsersAutomaticallyParams; [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_SIZE]: Parameters.UpdateSubscriptionSizeParams; [WRITE_COMMANDS.REQUEST_TAX_EXEMPTION]: null; + [WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS]: Parameters.SaveCorpayOnboardingCompanyDetailsParams; [WRITE_COMMANDS.DELETE_MONEY_REQUEST_ON_SEARCH]: Parameters.DeleteMoneyRequestOnSearchParams; [WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH]: Parameters.HoldMoneyRequestOnSearchParams; diff --git a/src/libs/ValidationUtils.ts b/src/libs/ValidationUtils.ts index fac02bd2b4ca..1308e5beef5b 100644 --- a/src/libs/ValidationUtils.ts +++ b/src/libs/ValidationUtils.ts @@ -5,6 +5,7 @@ import isObject from 'lodash/isObject'; import type {OnyxCollection} from 'react-native-onyx'; import type {FormInputErrors, FormOnyxKeys, FormOnyxValues, FormValue} from '@components/Form/types'; import CONST from '@src/CONST'; +import type {Country} from '@src/CONST'; import type {OnyxFormKey} from '@src/ONYXKEYS'; import type {Report, TaxRates} from '@src/types/onyx'; import * as CardUtils from './CardUtils'; @@ -554,6 +555,91 @@ function isValidOwnershipPercentage(value: string, totalOwnedPercentage: Record< return isValidNumber && isTotalSumValid; } +/** + * Validates the given value if it is correct ABN number + * @param registrationNumber - number to validate. + */ +function isValidABN(registrationNumber: string): boolean { + const cleanedAbn: string = registrationNumber.replaceAll(/[ _]/g, ''); + if (cleanedAbn.length !== 11) { + return false; + } + + const weights: number[] = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; + const checksum: number = [...cleanedAbn].reduce((total: number, char: string, index: number) => { + let digit = Number(char); + if (index === 0) { + digit--; + } // First digit special rule + return total + digit * (weights.at(index) ?? 0); // Using optional chaining for safety + }, 0); + + return checksum % 89 === 0; +} + +/** + * Validates the given value if it is correct ACN number + * @param registrationNumber - number to validate. + */ +function isValidACN(registrationNumber: string): boolean { + const cleanedAcn: string = registrationNumber.replaceAll(/\s|-/g, ''); + if (cleanedAcn.length !== 9 || Number.isNaN(Number(cleanedAcn))) { + return false; + } + + const weights: number[] = [8, 7, 6, 5, 4, 3, 2, 1]; + const tally: number = weights.reduce((total: number, weight: number, index: number) => { + return total + Number(cleanedAcn[index]) * weight; + }, 0); + + const checkDigit: number = 10 - (tally % 10); + return checkDigit === Number(cleanedAcn[8]) || (checkDigit === 10 && Number(cleanedAcn[8]) === 0); +} + +/** + * Validates the given value if it is correct australian registration number. + * @param registrationNumber + */ +function isValidAURegistrationNumber(registrationNumber: string): boolean { + return isValidABN(registrationNumber) || isValidACN(registrationNumber); +} + +/** + * Validates the given value if it is correct british registration number. + * @param registrationNumber + */ +function isValidGBRegistrationNumber(registrationNumber: string): boolean { + return /^(?:\d{8}|[A-Z]{2}\d{6})$/.test(registrationNumber); +} + +/** + * Validates the given value if it is correct canadian registration number. + * @param registrationNumber + */ +function isValidCARegistrationNumber(registrationNumber: string): boolean { + return /^\d{9}(?:[A-Z]{2}\d{4})?$/.test(registrationNumber); +} + +/** + * Validates the given value if it is correct registration number for the given country. + * @param registrationNumber + * @param country + */ +function isValidRegistrationNumber(registrationNumber: string, country: Country | '') { + switch (country) { + case CONST.COUNTRY.AU: + return isValidAURegistrationNumber(registrationNumber); + case CONST.COUNTRY.GB: + return isValidGBRegistrationNumber(registrationNumber); + case CONST.COUNTRY.CA: + return isValidCARegistrationNumber(registrationNumber); + case CONST.COUNTRY.US: + return isValidTaxID(registrationNumber); + default: + return true; + } +} + export { meetsMinimumAgeRequirement, meetsMaximumAgeRequirement, @@ -602,4 +688,5 @@ export { isValidPhoneInternational, isValidZipCodeInternational, isValidOwnershipPercentage, + isValidRegistrationNumber, }; diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 19245ba715f1..1adaa8eaeedd 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -11,10 +11,12 @@ import type { ValidateBankAccountWithTransactionsParams, VerifyIdentityForBankAccountParams, } from '@libs/API/parameters'; +import type {SaveCorpayOnboardingCompanyDetails} from '@libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as Localize from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; +import type {Country} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -500,6 +502,17 @@ function getCorpayBankAccountFields(country: string, currency: string) { }; } +function getCorpayOnboardingFields(country: Country | '') { + return API.read(READ_COMMANDS.GET_CORPAY_ONBOARDING_FIELDS, {countryISO: country}); +} + +function saveCorpayOnboardingCompanyDetails(parameters: SaveCorpayOnboardingCompanyDetails, bankAccountID: number) { + return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS, { + inputs: JSON.stringify(parameters), + bankAccountID, + }); +} + function clearReimbursementAccount() { Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null); } @@ -730,6 +743,8 @@ export { clearPersonalBankAccountSetupType, validatePlaidSelection, getCorpayBankAccountFields, + getCorpayOnboardingFields, + saveCorpayOnboardingCompanyDetails, }; export type {BusinessAddress, PersonalAddress}; diff --git a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/BusinessInfo.tsx b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/BusinessInfo.tsx index 61b42789daea..4f4cbf205b67 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/BusinessInfo.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/BusinessInfo.tsx @@ -1,10 +1,15 @@ import type {ComponentType} from 'react'; -import React from 'react'; +import React, {useCallback, useEffect, useMemo} from 'react'; +import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; +import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; +import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import Address from './substeps/Address'; import BusinessType from './substeps/BusinessType'; import Confirmation from './substeps/Confirmation'; @@ -13,6 +18,7 @@ import IncorporationLocation from './substeps/IncorporationLocation'; import Name from './substeps/Name'; import PaymentVolume from './substeps/PaymentVolume'; import RegistrationNumber from './substeps/RegistrationNumber'; +import TaxIDEINNumber from './substeps/TaxIDEINNumber'; type BusinessInfoProps = { /** Handles back button press */ @@ -22,14 +28,81 @@ type BusinessInfoProps = { onSubmit: () => void; }; -const bodyContent: Array> = [Name, Address, ContactInformation, RegistrationNumber, IncorporationLocation, BusinessType, PaymentVolume, Confirmation]; +const bodyContent: Array> = [ + Name, + Address, + ContactInformation, + RegistrationNumber, + TaxIDEINNumber, + IncorporationLocation, + BusinessType, + PaymentVolume, + Confirmation, +]; + +const INPUT_KEYS = { + NAME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.COMPANY_NAME, + STREET: INPUT_IDS.ADDITIONAL_DATA.CORPAY.COMPANY_STREET, + CITY: INPUT_IDS.ADDITIONAL_DATA.CORPAY.COMPANY_CITY, + STATE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.COMPANY_STATE, + ZIP_CODE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.COMPANY_ZIP_CODE, + COUNTRY: INPUT_IDS.ADDITIONAL_DATA.CORPAY.COMPANY_COUNTRY, + CONTACT_NUMBER: INPUT_IDS.ADDITIONAL_DATA.CORPAY.BUSINESS_CONTACT_NUMBER, + CONFIRMATION_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.BUSINESS_CONFIRMATION_EMAIL, + INCORPORATION_STATE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.FORMATION_INCORPORATION_STATE, + INCORPORATION_COUNTRY: INPUT_IDS.ADDITIONAL_DATA.CORPAY.FORMATION_INCORPORATION_COUNTRY_CODE, + BUSINESS_REGISTRATION_INCORPORATION_NUMBER: INPUT_IDS.ADDITIONAL_DATA.CORPAY.BUSINESS_REGISTRATION_INCORPORATION_NUMBER, + BUSINESS_CATEGORY: INPUT_IDS.ADDITIONAL_DATA.CORPAY.BUSINESS_CATEGORY, + APPLICANT_TYPE_ID: INPUT_IDS.ADDITIONAL_DATA.CORPAY.APPLICANT_TYPE_ID, + ANNUAL_VOLUME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.ANNUAL_VOLUME, + TAX_ID_EIN_NUMBER: INPUT_IDS.ADDITIONAL_DATA.CORPAY.TAX_ID_EIN_NUMBER, +}; function BusinessInfo({onBackButtonPress, onSubmit}: BusinessInfoProps) { const {translate} = useLocalize(); - const submit = () => { + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const policyID = reimbursementAccount?.achData?.policyID ?? '-1'; + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const currency = policy?.outputCurrency ?? ''; + const onyxValues = useMemo(() => getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); + const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; + + const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + + useEffect(() => { + BankAccounts.getCorpayOnboardingFields(country); + }, [country]); + + const submit = useCallback(() => { + BankAccounts.saveCorpayOnboardingCompanyDetails( + { + annualVolume: onyxValues[INPUT_KEYS.ANNUAL_VOLUME], + applicantTypeId: onyxValues[INPUT_KEYS.APPLICANT_TYPE_ID], + companyName: onyxValues[INPUT_KEYS.NAME], + companyStreetAddress: onyxValues[INPUT_KEYS.STREET], + companyCity: onyxValues[INPUT_KEYS.CITY], + companyState: onyxValues[INPUT_KEYS.STATE], + companyPostalCode: onyxValues[INPUT_KEYS.ZIP_CODE], + companyCountryCode: onyxValues[INPUT_KEYS.COUNTRY], + currencyNeeded: currency, + businessContactNumber: onyxValues[INPUT_KEYS.CONTACT_NUMBER], + businessConfirmationEmail: onyxValues[INPUT_KEYS.CONFIRMATION_EMAIL], + businessRegistrationIncorporationNumber: onyxValues[INPUT_KEYS.BUSINESS_REGISTRATION_INCORPORATION_NUMBER], + formationIncorporationState: onyxValues[INPUT_KEYS.INCORPORATION_STATE], + formationIncorporationCountryCode: onyxValues[INPUT_KEYS.INCORPORATION_COUNTRY], + fundSourceCountries: onyxValues[INPUT_KEYS.COUNTRY], + fundDestinationCountries: onyxValues[INPUT_KEYS.STATE], + natureOfBusiness: onyxValues[INPUT_KEYS.BUSINESS_CATEGORY], + purposeOfTransactionId: CONST.NON_USD_BANK_ACCOUNT.PURPOSE_OF_TRANSACTION_ID, + tradeVolume: onyxValues[INPUT_KEYS.ANNUAL_VOLUME], + taxIDEINNumber: onyxValues[INPUT_KEYS.TAX_ID_EIN_NUMBER], + }, + bankAccountID, + ); onSubmit(); - }; + }, [bankAccountID, currency, onSubmit, onyxValues]); const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo, goToTheLastStep} = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); diff --git a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/Confirmation.tsx index d0f26feccf0f..156967d63239 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/Confirmation.tsx @@ -19,6 +19,7 @@ const BUSINESS_INFO_STEP_KEYS = INPUT_IDS.ADDITIONAL_DATA.CORPAY; const { COMPANY_NAME, BUSINESS_REGISTRATION_INCORPORATION_NUMBER, + TAX_ID_EIN_NUMBER, COMPANY_COUNTRY, COMPANY_STREET, COMPANY_CITY, @@ -77,6 +78,14 @@ function Confirmation({onNext, onMove}: SubStepProps) { onMove(3); }} /> + { + onMove(4); + }} + /> { - onMove(5); + onMove(6); }} /> { - onMove(4); + onMove(5); }} /> { - onMove(5); + onMove(6); }} /> { - onMove(6); + onMove(7); }} /> diff --git a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/RegistrationNumber.tsx b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/RegistrationNumber.tsx index c2e02688a23f..8ec195d5c0c1 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/RegistrationNumber.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/RegistrationNumber.tsx @@ -21,7 +21,7 @@ import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; type RegistrationNumberProps = SubStepProps; -const {BUSINESS_REGISTRATION_INCORPORATION_NUMBER} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {BUSINESS_REGISTRATION_INCORPORATION_NUMBER, COMPANY_COUNTRY} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; const STEP_FIELDS = [BUSINESS_REGISTRATION_INCORPORATION_NUMBER]; function RegistrationNumber({onNext, isEditing}: RegistrationNumberProps) { @@ -33,11 +33,23 @@ function RegistrationNumber({onNext, isEditing}: RegistrationNumberProps) { const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const defaultValue = reimbursementAccount?.achData?.additionalData?.corpay?.[BUSINESS_REGISTRATION_INCORPORATION_NUMBER] ?? reimbursementAccountDraft?.[BUSINESS_REGISTRATION_INCORPORATION_NUMBER] ?? ''; + const businessStepCountryDraftValue = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_COUNTRY] ?? reimbursementAccountDraft?.[COMPANY_COUNTRY] ?? ''; - // TODO Validation for registration number depending on the country will be added in https://github.com/Expensify/App/issues/50905 - const validate = useCallback((values: FormOnyxValues): FormInputErrors => { - return ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); - }, []); + const validate = useCallback( + (values: FormOnyxValues): FormInputErrors => { + const errors = ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); + + if ( + values[BUSINESS_REGISTRATION_INCORPORATION_NUMBER] && + !ValidationUtils.isValidRegistrationNumber(values[BUSINESS_REGISTRATION_INCORPORATION_NUMBER], businessStepCountryDraftValue) + ) { + errors[BUSINESS_REGISTRATION_INCORPORATION_NUMBER] = translate('businessInfoStep.error.registrationNumber'); + } + + return errors; + }, + [businessStepCountryDraftValue, translate], + ); const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, diff --git a/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/TaxIDEINNumber.tsx b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/TaxIDEINNumber.tsx new file mode 100644 index 000000000000..2ceba8d7f386 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/BusinessInfo/substeps/TaxIDEINNumber.tsx @@ -0,0 +1,57 @@ +import React, {useCallback} from 'react'; +import {useOnyx} from 'react-native-onyx'; +import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; +import SingleFieldStep from '@components/SubStepForms/SingleFieldStep'; +import useLocalize from '@hooks/useLocalize'; +import useReimbursementAccountStepFormSubmit from '@hooks/useReimbursementAccountStepFormSubmit'; +import type {SubStepProps} from '@hooks/useSubStep/types'; +import * as ValidationUtils from '@libs/ValidationUtils'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; + +type TaxIDEINNumberProps = SubStepProps; + +const {TAX_ID_EIN_NUMBER} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const STEP_FIELDS = [TAX_ID_EIN_NUMBER]; + +function TaxIDEINNumber({onNext, onMove, isEditing}: TaxIDEINNumberProps) { + const {translate} = useLocalize(); + + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const defaultValue = reimbursementAccount?.achData?.additionalData?.corpay?.[TAX_ID_EIN_NUMBER] ?? reimbursementAccountDraft?.[TAX_ID_EIN_NUMBER] ?? ''; + + const validate = useCallback((values: FormOnyxValues): FormInputErrors => { + const errors = ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); + + return errors; + }, []); + + const handleSubmit = useReimbursementAccountStepFormSubmit({ + fieldIds: STEP_FIELDS, + onNext, + shouldSaveDraft: isEditing, + }); + + return ( + + isEditing={isEditing} + onNext={onNext} + onMove={onMove} + formID={ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM} + formTitle={translate('businessInfoStep.whatsTheBusinessTaxIDEIN')} + validate={validate} + onSubmit={handleSubmit} + inputId={TAX_ID_EIN_NUMBER} + inputLabel={translate('businessInfoStep.taxIDEIN')} + inputMode={CONST.INPUT_MODE.NUMERIC} + defaultValue={defaultValue} + shouldShowHelpLinks={false} + /> + ); +} + +TaxIDEINNumber.displayName = 'TaxIDEINNumber'; + +export default TaxIDEINNumber; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/HangTight.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/HangTight.tsx index 15fea5e46691..638137e82ff1 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/HangTight.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/HangTight.tsx @@ -15,7 +15,7 @@ function HangTight({tempSubmit}: {tempSubmit: () => void}) { const styles = useThemeStyles(); const handleSendReminder = () => { - // TODO remove that + // TODO this should send a message to the email provided in the previous step tempSubmit(); }; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 1ba513c07807..2c44659c845c 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -107,6 +107,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }; const handleEmailSubmit = () => { + // TODO: the message to the email provided in the previous step should be sent setCurrentSubStep(SUBSTEP.HANG_TIGHT); }; From 5f213c75e11131cb956df4e876fd9acd2d07eada Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 25 Nov 2024 14:51:58 +0100 Subject: [PATCH 002/138] getting corpay onboarding fields call added to signer info page --- src/libs/API/types.ts | 2 ++ .../ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 1d99c626a9f0..404498378002 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -949,6 +949,7 @@ const READ_COMMANDS = { OPEN_DRAFT_DISTANCE_EXPENSE: 'OpenDraftDistanceExpense', START_ISSUE_NEW_CARD_FLOW: 'StartIssueNewCardFlow', OPEN_CARD_DETAILS_PAGE: 'OpenCardDetailsPage', + GET_CORPAY_ONBOARDING_FIELDS: 'GetCorpayOnboardingFields', } as const; type ReadCommand = ValueOf; @@ -1011,6 +1012,7 @@ type ReadCommandParameters = { [READ_COMMANDS.OPEN_DRAFT_DISTANCE_EXPENSE]: null; [READ_COMMANDS.START_ISSUE_NEW_CARD_FLOW]: Parameters.StartIssueNewCardFlowParams; [READ_COMMANDS.OPEN_CARD_DETAILS_PAGE]: Parameters.OpenCardDetailsPageParams; + [READ_COMMANDS.GET_CORPAY_ONBOARDING_FIELDS]: Parameters.GetCorpayOnboardingFieldsParams; }; const SIDE_EFFECT_REQUEST_COMMANDS = { diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 2c44659c845c..30023cdd968a 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,5 +1,5 @@ import type {ComponentType} from 'react'; -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import YesNoStep from '@components/SubStepForms/YesNoStep'; @@ -7,6 +7,7 @@ import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; import Navigation from '@navigation/Navigation'; +import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; @@ -51,6 +52,12 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const [currentSubStep, setCurrentSubStep] = useState(SUBSTEP.IS_DIRECTOR); const [isUserDirector, setIsUserDirector] = useState(false); + const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + + useEffect(() => { + BankAccounts.getCorpayOnboardingFields(country); + }, [country]); + const submit = () => { if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); From aadaf97f746d9b9da9c852aa0a3e65092b03fdcb Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 26 Nov 2024 13:30:35 +0100 Subject: [PATCH 003/138] unnecessary api call prevented --- src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 30023cdd968a..1880507b215d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -55,6 +55,10 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; useEffect(() => { + if (!country) { + return; + } + BankAccounts.getCorpayOnboardingFields(country); }, [country]); From 8aaecc40d345ec657dac3647097501d434102064 Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 27 Nov 2024 14:24:28 +0100 Subject: [PATCH 004/138] save corpay onboarding director information endpoint handling --- ...rpayOnboardingDirectorInformationParams.ts | 24 ++++++++++++++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 ++ src/libs/actions/BankAccounts.ts | 9 ++++++ .../NonUSD/SignerInfo/index.tsx | 31 ++++++++++++++++++- 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts diff --git a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts new file mode 100644 index 000000000000..0b216df03de8 --- /dev/null +++ b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts @@ -0,0 +1,24 @@ +type SaveCorpayOnboardingDirectorInformation = { + signerFullName: string; + signerDateOfBirth: string; + signerJobTitle: string; + signerEmail: string; + signerCompleteResidentialAddress: string; + secondSignerFullName?: string; + secondSignerDateOfBirth?: string; + secondSignerJobTitle?: string; + secondSignerEmail?: string; + secondSignerCompleteResidentialAddress?: string; +}; + +type SaveCorpayOnboardingDirectorInformationParams = { + inputs: string; + bankAccountID: number; + proofOfDirectors?: File; + copyOfID?: File; + addressProof?: File; + codiceProof?: File; + pdsAndFSG?: File; +}; + +export type {SaveCorpayOnboardingDirectorInformation, SaveCorpayOnboardingDirectorInformationParams}; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index f42653dc1e6a..55e34ff2622e 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -354,3 +354,4 @@ export type {default as ImportPerDiemRatesParams} from './ImportPerDiemRatesPara export type {default as ExportPerDiemCSVParams} from './ExportPerDiemCSVParams'; export type {default as GetCorpayOnboardingFieldsParams} from './GetCorpayOnboardingFieldsParams'; export type {SaveCorpayOnboardingCompanyDetailsParams} from './SaveCorpayOnboardingCompanyDetailsParams'; +export type {SaveCorpayOnboardingDirectorInformationParams} from './SaveCorpayOnboardingDirectorInformationParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 404498378002..13e89ffe850d 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -439,6 +439,7 @@ const WRITE_COMMANDS = { UPDATE_INVOICE_COMPANY_NAME: 'UpdateInvoiceCompanyName', UPDATE_INVOICE_COMPANY_WEBSITE: 'UpdateInvoiceCompanyWebsite', SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS: 'SaveCorpayOnboardingCompanyDetails', + SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION: 'SaveCorpayOnboardingDirectorInformation', } as const; type WriteCommand = ValueOf; @@ -764,6 +765,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_SIZE]: Parameters.UpdateSubscriptionSizeParams; [WRITE_COMMANDS.REQUEST_TAX_EXEMPTION]: null; [WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS]: Parameters.SaveCorpayOnboardingCompanyDetailsParams; + [WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION]: Parameters.SaveCorpayOnboardingDirectorInformationParams; [WRITE_COMMANDS.DELETE_MONEY_REQUEST_ON_SEARCH]: Parameters.DeleteMoneyRequestOnSearchParams; [WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH]: Parameters.HoldMoneyRequestOnSearchParams; diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 1adaa8eaeedd..1613f1608139 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -12,6 +12,7 @@ import type { VerifyIdentityForBankAccountParams, } from '@libs/API/parameters'; import type {SaveCorpayOnboardingCompanyDetails} from '@libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams'; +import type {SaveCorpayOnboardingDirectorInformation} from '@libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as Localize from '@libs/Localize'; @@ -513,6 +514,13 @@ function saveCorpayOnboardingCompanyDetails(parameters: SaveCorpayOnboardingComp }); } +function saveCorpayOnboardingDirectorInformation(parameters: SaveCorpayOnboardingDirectorInformation, bankAccountID: number) { + return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION, { + inputs: JSON.stringify(parameters), + bankAccountID, + }); +} + function clearReimbursementAccount() { Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null); } @@ -745,6 +753,7 @@ export { getCorpayBankAccountFields, getCorpayOnboardingFields, saveCorpayOnboardingCompanyDetails, + saveCorpayOnboardingDirectorInformation, }; export type {BusinessAddress, PersonalAddress}; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 1880507b215d..fe07bc13b1c7 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,4 +1,4 @@ -import type {ComponentType} from 'react'; +import { ComponentType, useMemo } from "react"; import React, {useEffect, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; @@ -18,6 +18,7 @@ import DateOfBirth from './substeps/DateOfBirth'; import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import UploadDocuments from './substeps/UploadDocuments'; +import getSubstepValues from "@pages/ReimbursementAccount/utils/getSubstepValues"; type SignerInfoProps = { /** Handles back button press */ @@ -36,6 +37,19 @@ const {OWNS_MORE_THAN_25_PERCENT, COMPANY_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORP const bodyContent: Array> = [Name, JobTitle, DateOfBirth, UploadDocuments, Confirmation]; const userIsOwnerBodyContent: Array> = [JobTitle, UploadDocuments, Confirmation]; +const INPUT_KEYS = { + SIGNER_FULL_NAME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_FULL_NAME, + SIGNER_DATE_OF_BIRTH: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_DATE_OF_BIRTH, + SIGNER_JOB_TITLE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_JOB_TITLE, + SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_EMAIL, + SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, + SECOND_SIGNER_FULL_NAME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_FULL_NAME, + SECOND_SIGNER_DATE_OF_BIRTH: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_DATE_OF_BIRTH, + SECOND_SIGNER_JOB_TITLE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_JOB_TITLE, + SECOND_SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL, + SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, +}; + function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const {translate} = useLocalize(); @@ -44,6 +58,9 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const policyID = reimbursementAccount?.achData?.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const currency = policy?.outputCurrency ?? ''; + const onyxValues = useMemo(() => getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); + const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; + // TODO set this based on param from redirect or BE response const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; @@ -66,6 +83,18 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); } else { + BankAccounts.saveCorpayOnboardingDirectorInformation({ + signerFullName: onyxValues[INPUT_KEYS.SIGNER_FULL_NAME], + signerDateOfBirth: onyxValues[INPUT_KEYS.SIGNER_DATE_OF_BIRTH], + signerJobTitle: onyxValues[INPUT_KEYS.SIGNER_JOB_TITLE], + signerEmail: onyxValues[INPUT_KEYS.SIGNER_EMAIL], + signerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], + secondSignerFullName: onyxValues[INPUT_KEYS.SECOND_SIGNER_FULL_NAME], + secondSignerDateOfBirth: onyxValues[INPUT_KEYS.SECOND_SIGNER_DATE_OF_BIRTH], + secondSignerJobTitle: onyxValues[INPUT_KEYS.SECOND_SIGNER_JOB_TITLE], + secondSignerEmail: onyxValues[INPUT_KEYS.SECOND_SIGNER_EMAIL], + secondSignerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], + }, bankAccountID); onSubmit(); } }; From a1f0be5a2207ad02429b8dfb7f9e2d3f87f7b376 Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 2 Dec 2024 09:13:37 +0100 Subject: [PATCH 005/138] prettier fixes --- .../NonUSD/SignerInfo/index.tsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index fe07bc13b1c7..f5240250ec06 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,5 +1,5 @@ -import { ComponentType, useMemo } from "react"; -import React, {useEffect, useState} from 'react'; +import type {ComponentType} from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import YesNoStep from '@components/SubStepForms/YesNoStep'; @@ -7,6 +7,7 @@ import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; import Navigation from '@navigation/Navigation'; +import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -18,7 +19,6 @@ import DateOfBirth from './substeps/DateOfBirth'; import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import UploadDocuments from './substeps/UploadDocuments'; -import getSubstepValues from "@pages/ReimbursementAccount/utils/getSubstepValues"; type SignerInfoProps = { /** Handles back button press */ @@ -83,18 +83,21 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); } else { - BankAccounts.saveCorpayOnboardingDirectorInformation({ - signerFullName: onyxValues[INPUT_KEYS.SIGNER_FULL_NAME], - signerDateOfBirth: onyxValues[INPUT_KEYS.SIGNER_DATE_OF_BIRTH], - signerJobTitle: onyxValues[INPUT_KEYS.SIGNER_JOB_TITLE], - signerEmail: onyxValues[INPUT_KEYS.SIGNER_EMAIL], - signerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], - secondSignerFullName: onyxValues[INPUT_KEYS.SECOND_SIGNER_FULL_NAME], - secondSignerDateOfBirth: onyxValues[INPUT_KEYS.SECOND_SIGNER_DATE_OF_BIRTH], - secondSignerJobTitle: onyxValues[INPUT_KEYS.SECOND_SIGNER_JOB_TITLE], - secondSignerEmail: onyxValues[INPUT_KEYS.SECOND_SIGNER_EMAIL], - secondSignerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], - }, bankAccountID); + BankAccounts.saveCorpayOnboardingDirectorInformation( + { + signerFullName: onyxValues[INPUT_KEYS.SIGNER_FULL_NAME], + signerDateOfBirth: onyxValues[INPUT_KEYS.SIGNER_DATE_OF_BIRTH], + signerJobTitle: onyxValues[INPUT_KEYS.SIGNER_JOB_TITLE], + signerEmail: onyxValues[INPUT_KEYS.SIGNER_EMAIL], + signerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], + secondSignerFullName: onyxValues[INPUT_KEYS.SECOND_SIGNER_FULL_NAME], + secondSignerDateOfBirth: onyxValues[INPUT_KEYS.SECOND_SIGNER_DATE_OF_BIRTH], + secondSignerJobTitle: onyxValues[INPUT_KEYS.SECOND_SIGNER_JOB_TITLE], + secondSignerEmail: onyxValues[INPUT_KEYS.SECOND_SIGNER_EMAIL], + secondSignerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], + }, + bankAccountID, + ); onSubmit(); } }; From 8c0dff5d160c9a73680ce6034cffb84c91ea3579 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 6 Dec 2024 10:18:06 +0100 Subject: [PATCH 006/138] save director information api call temp --- ...rpayOnboardingDirectorInformationParams.ts | 34 +++++++++++++------ .../NonUSD/SignerInfo/index.tsx | 22 ++++++------ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts index 0b216df03de8..d4780d1f070e 100644 --- a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts +++ b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts @@ -1,24 +1,36 @@ -type SaveCorpayOnboardingDirectorInformation = { +import type {FileObject} from '@components/AttachmentModal'; + +// secondSignerFullName?: string; +// secondSignerDateOfBirth?: string; +// secondSignerJobTitle?: string; +// secondSignerEmail?: string; +// secondSignerCompleteResidentialAddress?: string; + +type SaveCorpayOnboardingCompanyDirector = { signerFullName: string; signerDateOfBirth: string; signerJobTitle: string; signerEmail: string; signerCompleteResidentialAddress: string; - secondSignerFullName?: string; - secondSignerDateOfBirth?: string; - secondSignerJobTitle?: string; - secondSignerEmail?: string; - secondSignerCompleteResidentialAddress?: string; +}; + +type SaveCorpayOnboardingDirectorInformation = { + companyDirectors: SaveCorpayOnboardingCompanyDirector[]; + proofOfDirectors?: FileObject | string; + copyOfID?: FileObject | string; + addressProof?: FileObject | string; + codiceProof?: FileObject | string; + pdsAndFSG?: FileObject | string; }; type SaveCorpayOnboardingDirectorInformationParams = { inputs: string; bankAccountID: number; - proofOfDirectors?: File; - copyOfID?: File; - addressProof?: File; - codiceProof?: File; - pdsAndFSG?: File; + proofOfDirectors?: FileObject | string; + copyOfID?: FileObject | string; + addressProof?: FileObject | string; + codiceProof?: FileObject | string; + pdsAndFSG?: FileObject | string; }; export type {SaveCorpayOnboardingDirectorInformation, SaveCorpayOnboardingDirectorInformationParams}; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index f5240250ec06..7d6c56cbcbaf 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -48,6 +48,7 @@ const INPUT_KEYS = { SECOND_SIGNER_JOB_TITLE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_JOB_TITLE, SECOND_SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL, SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, + SIGNER_COPY_OF_ID: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COPY_OF_ID, }; function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { @@ -55,6 +56,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const [account] = useOnyx(ONYXKEYS.ACCOUNT); const policyID = reimbursementAccount?.achData?.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const currency = policy?.outputCurrency ?? ''; @@ -85,16 +87,16 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { } else { BankAccounts.saveCorpayOnboardingDirectorInformation( { - signerFullName: onyxValues[INPUT_KEYS.SIGNER_FULL_NAME], - signerDateOfBirth: onyxValues[INPUT_KEYS.SIGNER_DATE_OF_BIRTH], - signerJobTitle: onyxValues[INPUT_KEYS.SIGNER_JOB_TITLE], - signerEmail: onyxValues[INPUT_KEYS.SIGNER_EMAIL], - signerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], - secondSignerFullName: onyxValues[INPUT_KEYS.SECOND_SIGNER_FULL_NAME], - secondSignerDateOfBirth: onyxValues[INPUT_KEYS.SECOND_SIGNER_DATE_OF_BIRTH], - secondSignerJobTitle: onyxValues[INPUT_KEYS.SECOND_SIGNER_JOB_TITLE], - secondSignerEmail: onyxValues[INPUT_KEYS.SECOND_SIGNER_EMAIL], - secondSignerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], + companyDirectors: [ + { + signerFullName: onyxValues[INPUT_KEYS.SIGNER_FULL_NAME], + signerDateOfBirth: onyxValues[INPUT_KEYS.SIGNER_DATE_OF_BIRTH], + signerJobTitle: onyxValues[INPUT_KEYS.SIGNER_JOB_TITLE], + signerEmail: account?.primaryLogin ?? '', + signerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], + }, + ], + copyOfID: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], }, bankAccountID, ); From cb68762e50d4e2eba2f066dbd25c79620e5b52d1 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 10 Dec 2024 13:45:23 +0100 Subject: [PATCH 007/138] duplicated import removed --- src/libs/actions/BankAccounts.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 911f934cbec6..534341dfcd82 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -17,7 +17,6 @@ import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as Localize from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; -import type {Country} from '@src/CONST'; import CONST from '@src/CONST'; import type {Country} from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From 4d18148f2171d3d3fec7986baa574d1166621b48 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 10 Dec 2024 13:46:05 +0100 Subject: [PATCH 008/138] switched to destination country --- .../NonUSD/Country/substeps/Confirmation.tsx | 4 ++-- src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/Country/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/Country/substeps/Confirmation.tsx index 658f08fbc6d9..84cb59538eca 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Country/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Country/substeps/Confirmation.tsx @@ -50,7 +50,7 @@ function Confirmation({onNext}: SubStepProps) { }; const validate = useCallback((values: FormOnyxValues): FormInputErrors => { - return ValidationUtils.getFieldRequiredErrors(values, [BANK_CURRENCY]); + return ValidationUtils.getFieldRequiredErrors(values, [DESTINATION_COUNTRY]); }, []); useEffect(() => { @@ -110,7 +110,7 @@ function Confirmation({onNext}: SubStepProps) { searchInputTitle={translate('countryStep.findCountry')} shouldAllowChange={shouldAllowChange} value={selectedCountry} - inputID={BANK_CURRENCY} + inputID={DESTINATION_COUNTRY} shouldSaveDraft /> diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 7d6c56cbcbaf..d29055bc4b4a 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -71,7 +71,8 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const [currentSubStep, setCurrentSubStep] = useState(SUBSTEP.IS_DIRECTOR); const [isUserDirector, setIsUserDirector] = useState(false); - const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + const country = + reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.DESTINATION_COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.DESTINATION_COUNTRY] ?? ''; useEffect(() => { if (!country) { From dcdbe8fde8601dee0f2065645912a6fb69518d51 Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 8 Jan 2025 10:30:01 +0100 Subject: [PATCH 009/138] sending documents added --- ...rpayOnboardingDirectorInformationParams.ts | 26 +++++++------------ .../NonUSD/SignerInfo/index.tsx | 12 +++++++-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts index d4780d1f070e..301164e1e4e7 100644 --- a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts +++ b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts @@ -1,11 +1,5 @@ import type {FileObject} from '@components/AttachmentModal'; -// secondSignerFullName?: string; -// secondSignerDateOfBirth?: string; -// secondSignerJobTitle?: string; -// secondSignerEmail?: string; -// secondSignerCompleteResidentialAddress?: string; - type SaveCorpayOnboardingCompanyDirector = { signerFullName: string; signerDateOfBirth: string; @@ -16,21 +10,21 @@ type SaveCorpayOnboardingCompanyDirector = { type SaveCorpayOnboardingDirectorInformation = { companyDirectors: SaveCorpayOnboardingCompanyDirector[]; - proofOfDirectors?: FileObject | string; - copyOfID?: FileObject | string; - addressProof?: FileObject | string; - codiceProof?: FileObject | string; - pdsAndFSG?: FileObject | string; + proofOfDirectors?: FileObject[] | string; + copyOfID?: FileObject[] | string; + addressProof?: FileObject[] | string; + codiceProof?: FileObject[] | string; + pdsAndFSG?: FileObject[] | string; }; type SaveCorpayOnboardingDirectorInformationParams = { inputs: string; bankAccountID: number; - proofOfDirectors?: FileObject | string; - copyOfID?: FileObject | string; - addressProof?: FileObject | string; - codiceProof?: FileObject | string; - pdsAndFSG?: FileObject | string; + proofOfDirectors?: FileObject[] | string; + copyOfID?: FileObject[] | string; + addressProof?: FileObject[] | string; + codiceProof?: FileObject[] | string; + pdsAndFSG?: FileObject[] | string; }; export type {SaveCorpayOnboardingDirectorInformation, SaveCorpayOnboardingDirectorInformationParams}; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index d29055bc4b4a..5f5ca8fae5ec 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -49,6 +49,9 @@ const INPUT_KEYS = { SECOND_SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL, SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SIGNER_COPY_OF_ID: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COPY_OF_ID, + SIGNER_ADDRESS_PROOF: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_ADDRESS_PROOF, + // SIGNER_CODICE_PROOF: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_CODICE_PROOF, + SIGNER_PDS_AND_FSG: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PDS_AND_FSG, }; function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { @@ -71,14 +74,14 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const [currentSubStep, setCurrentSubStep] = useState(SUBSTEP.IS_DIRECTOR); const [isUserDirector, setIsUserDirector] = useState(false); - const country = - reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.DESTINATION_COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.DESTINATION_COUNTRY] ?? ''; + const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; useEffect(() => { if (!country) { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-call BankAccounts.getCorpayOnboardingFields(country); }, [country]); @@ -86,6 +89,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); } else { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call BankAccounts.saveCorpayOnboardingDirectorInformation( { companyDirectors: [ @@ -98,6 +102,10 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }, ], copyOfID: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], + addressProof: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], + // TODO: uncomment when codiceProof is added to the form + // codiceProof: onyxValues[INPUT_KEYS.SIGNER_CODICE_PROOF], + pdsAndFSG: onyxValues[INPUT_KEYS.SIGNER_PDS_AND_FSG], }, bankAccountID, ); From 62e531a04e57b0cd904b1b082eca87f29287efd8 Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 8 Jan 2025 13:33:05 +0100 Subject: [PATCH 010/138] onyx data handling added to the save director information action --- src/libs/actions/BankAccounts.ts | 40 ++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 83e902df3a1f..6a916f0dddb4 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -490,10 +490,46 @@ function saveCorpayOnboardingBeneficialOwners(parameters: SaveCorpayOnboardingBe } function saveCorpayOnboardingDirectorInformation(parameters: SaveCorpayOnboardingDirectorInformation, bankAccountID: number) { - return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION, { + const formattedParams = { inputs: JSON.stringify(parameters), bankAccountID, - }); + }; + + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isSavingCorpayOnboardingDirectorInformation: true, + errors: null, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isSavingCorpayOnboardingDirectorInformation: false, + isSuccess: true, + }, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isSavingCorpayOnboardingDirectorInformation: false, + isSuccess: false, + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + ], + }; + + return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION, formattedParams, onyxData); } function clearReimbursementAccount() { From 531be87117c7d28eab3b17bb4acf0fd35f54abb2 Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 9 Jan 2025 10:43:57 +0100 Subject: [PATCH 011/138] body content usage fixed --- .../NonUSD/SignerInfo/index.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 5f5ca8fae5ec..aa4d6035753c 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -34,8 +34,9 @@ type SignerDetailsFormProps = SubStepProps & {isSecondSigner: boolean}; const SUBSTEP: Record = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SUBSTEP; const {OWNS_MORE_THAN_25_PERCENT, COMPANY_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const bodyContent: Array> = [Name, JobTitle, DateOfBirth, UploadDocuments, Confirmation]; +const fullBodyContent: Array> = [Name, JobTitle, DateOfBirth, UploadDocuments, Confirmation]; const userIsOwnerBodyContent: Array> = [JobTitle, UploadDocuments, Confirmation]; +const userIsOwnerCadBodyContent: Array> = [UploadDocuments, Confirmation]; const INPUT_KEYS = { SIGNER_FULL_NAME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_FULL_NAME, @@ -129,6 +130,18 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); }; + const bodyContent = useMemo(() => { + if (isUserOwner) { + if (currency === CONST.CURRENCY.CAD) { + return userIsOwnerCadBodyContent; + } + + return userIsOwnerBodyContent; + } + + return fullBodyContent; + }, [currency, isUserOwner]); + const { componentToRender: SignerDetailsForm, isEditing, @@ -137,7 +150,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { prevScreen, moveTo, goToTheLastStep, - } = useSubStep({bodyContent: isUserOwner ? userIsOwnerBodyContent : bodyContent, startFrom: 0, onFinished: submit}); + } = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); const handleBackButtonPress = () => { if (isEditing) { From 93444f52ecfc05c11716394ad6cbdca4512f7e5f Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 9 Jan 2025 10:56:05 +0100 Subject: [PATCH 012/138] use callback wrapper utilized --- .../NonUSD/SignerInfo/index.tsx | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index aa4d6035753c..11ac3f3d81fc 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,5 +1,5 @@ import type {ComponentType} from 'react'; -import React, {useEffect, useMemo, useState} from 'react'; +import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import YesNoStep from '@components/SubStepForms/YesNoStep'; @@ -86,7 +86,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { BankAccounts.getCorpayOnboardingFields(country); }, [country]); - const submit = () => { + const submit = useCallback(() => { if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); } else { @@ -112,23 +112,26 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { ); onSubmit(); } - }; + }, [account?.primaryLogin, bankAccountID, currency, onSubmit, onyxValues]); - const handleNextSubStep = (value: boolean) => { - if (currentSubStep !== SUBSTEP.IS_DIRECTOR) { - return; - } + const handleNextSubStep = useCallback( + (value: boolean) => { + if (currentSubStep !== SUBSTEP.IS_DIRECTOR) { + return; + } - // user is director - if (value) { - setIsUserDirector(value); - setCurrentSubStep(SUBSTEP.SIGNER_DETAILS_FORM); - return; - } + // user is director + if (value) { + setIsUserDirector(value); + setCurrentSubStep(SUBSTEP.SIGNER_DETAILS_FORM); + return; + } - setIsUserDirector(value); - setCurrentSubStep(SUBSTEP.ENTER_EMAIL); - }; + setIsUserDirector(value); + setCurrentSubStep(SUBSTEP.ENTER_EMAIL); + }, + [currentSubStep], + ); const bodyContent = useMemo(() => { if (isUserOwner) { @@ -152,7 +155,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { goToTheLastStep, } = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); - const handleBackButtonPress = () => { + const handleBackButtonPress = useCallback(() => { if (isEditing) { goToTheLastStep(); return; @@ -171,12 +174,12 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { } else { setCurrentSubStep((subStep) => subStep - 1); } - }; + }, [currentSubStep, goToTheLastStep, isEditing, isUserDirector, onBackButtonPress, prevScreen, screenIndex]); - const handleEmailSubmit = () => { + const handleEmailSubmit = useCallback(() => { // TODO: the message to the email provided in the previous step should be sent setCurrentSubStep(SUBSTEP.HANG_TIGHT); - }; + }, []); return ( Date: Mon, 20 Jan 2025 14:07:34 +0100 Subject: [PATCH 013/138] removing files fixed --- .../SignerInfo/substeps/UploadDocuments.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx index ed47b4bf235e..ba28bc106a47 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx @@ -17,6 +17,7 @@ import * as FormActions from '@userActions/FormActions'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; +import { setDraftValues } from "@userActions/FormActions"; type UploadDocumentsProps = SubStepProps; @@ -53,21 +54,15 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { setUploadedID((prev) => [...prev, ...files]); }; - const handleRemoveIDFile = (fileUri: string) => { - const newUploadedIDs = uploadedIDs.filter((file) => file.uri !== fileUri); - FormActions.setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[SIGNER_COPY_OF_ID]: newUploadedIDs}); - setUploadedID(newUploadedIDs); - }; - const handleSelectProofOfAddressFile = (files: FileObject[]) => { FormActions.setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[SIGNER_ADDRESS_PROOF]: [...uploadedProofsOfAddress, ...files]}); setUploadedProofOfAddress((prev) => [...prev, ...files]); }; - const handleRemoveProofOfAddressFile = (fileUri: string) => { - const newUploadedProofsOfAddress = uploadedProofsOfAddress.filter((file) => file.uri !== fileUri); - FormActions.setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[SIGNER_ADDRESS_PROOF]: newUploadedProofsOfAddress}); - setUploadedProofOfAddress(newUploadedProofsOfAddress); + const handleRemoveFile = (fileName: string, uploadedFiles: FileObject[], inputID: string, setFiles: React.Dispatch>) => { + const newUploadedIDs = uploadedFiles.filter((file) => file.name !== fileName); + setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[inputID]: newUploadedIDs}); + setFiles(newUploadedIDs); }; // TODO: check if this is necessary @@ -92,7 +87,9 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { buttonText={translate('signerInfoStep.chooseFile')} uploadedFiles={uploadedIDs} onUpload={handleSelectIDFile} - onRemove={handleRemoveIDFile} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedIDs, SIGNER_COPY_OF_ID, setUploadedID); + }} acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} value={uploadedIDs} inputID={SIGNER_COPY_OF_ID} @@ -104,7 +101,9 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { buttonText={translate('signerInfoStep.chooseFile')} uploadedFiles={uploadedProofsOfAddress} onUpload={handleSelectProofOfAddressFile} - onRemove={handleRemoveProofOfAddressFile} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedProofsOfAddress, SIGNER_ADDRESS_PROOF, setUploadedProofOfAddress); + }} acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} value={uploadedProofsOfAddress} inputID={SIGNER_ADDRESS_PROOF} From 3f4a31266ded3c6d4e77a5baa639c79521e7ce6b Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 20 Jan 2025 14:07:48 +0100 Subject: [PATCH 014/138] error utils usage fixed --- src/libs/actions/BankAccounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index f716f766ada2..603c0e30516c 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -557,7 +557,7 @@ function saveCorpayOnboardingDirectorInformation(parameters: SaveCorpayOnboardin value: { isSavingCorpayOnboardingDirectorInformation: false, isSuccess: false, - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + errors: getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), }, }, ], From 7e8bb1056ca12677ed7d33b9817e0fb789e01019 Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 20 Jan 2025 14:10:27 +0100 Subject: [PATCH 015/138] uploading documents improved --- .../SignerInfo/substeps/UploadDocuments.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx index ba28bc106a47..fbfeb21a02ff 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx @@ -49,22 +49,17 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { shouldSaveDraft: isEditing, }); - const handleSelectIDFile = (files: FileObject[]) => { - FormActions.setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[SIGNER_COPY_OF_ID]: [...uploadedIDs, ...files]}); - setUploadedID((prev) => [...prev, ...files]); - }; - - const handleSelectProofOfAddressFile = (files: FileObject[]) => { - FormActions.setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[SIGNER_ADDRESS_PROOF]: [...uploadedProofsOfAddress, ...files]}); - setUploadedProofOfAddress((prev) => [...prev, ...files]); - }; - const handleRemoveFile = (fileName: string, uploadedFiles: FileObject[], inputID: string, setFiles: React.Dispatch>) => { const newUploadedIDs = uploadedFiles.filter((file) => file.name !== fileName); setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[inputID]: newUploadedIDs}); setFiles(newUploadedIDs); }; + const handleSelectFile = (files: FileObject[], uploadedFiles: FileObject[], inputID: string, setFiles: React.Dispatch>) => { + setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[inputID]: [...uploadedFiles, ...files]}); + setFiles((prev) => [...prev, ...files]); + }; + // TODO: check if this is necessary const setError = (error: string) => { // eslint-disable-next-line @@ -86,7 +81,9 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { InputComponent={UploadFile} buttonText={translate('signerInfoStep.chooseFile')} uploadedFiles={uploadedIDs} - onUpload={handleSelectIDFile} + onUpload={(files) => { + handleSelectFile(files, uploadedIDs, SIGNER_COPY_OF_ID, setUploadedID); + }} onRemove={(fileName) => { handleRemoveFile(fileName, uploadedIDs, SIGNER_COPY_OF_ID, setUploadedID); }} @@ -100,7 +97,9 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { InputComponent={UploadFile} buttonText={translate('signerInfoStep.chooseFile')} uploadedFiles={uploadedProofsOfAddress} - onUpload={handleSelectProofOfAddressFile} + onUpload={(files) => { + handleSelectFile(files, uploadedProofsOfAddress, SIGNER_ADDRESS_PROOF, setUploadedProofOfAddress); + }} onRemove={(fileName) => { handleRemoveFile(fileName, uploadedProofsOfAddress, SIGNER_ADDRESS_PROOF, setUploadedProofOfAddress); }} From 9498a17c48ba4369dd64137261fcd9a19b2899df Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 21 Jan 2025 10:01:59 +0100 Subject: [PATCH 016/138] temporary files --- src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 11ac3f3d81fc..5389c173f74f 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -105,8 +105,8 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { copyOfID: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], addressProof: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], // TODO: uncomment when codiceProof is added to the form - // codiceProof: onyxValues[INPUT_KEYS.SIGNER_CODICE_PROOF], - pdsAndFSG: onyxValues[INPUT_KEYS.SIGNER_PDS_AND_FSG], + codiceProof: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], + pdsAndFSG: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], }, bankAccountID, ); From 0ffd2f0c65e4932cc881cb20477cdf0170a1a8bd Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 3 Feb 2025 12:25:24 +0100 Subject: [PATCH 017/138] address page added --- src/CONST.ts | 7 ++ .../NonUSD/SignerInfo/index.tsx | 3 +- .../NonUSD/SignerInfo/substeps/Address.tsx | 105 ++++++++++++++++++ src/types/form/ReimbursementAccountForm.ts | 5 + 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 75779704af26..2e5ec963f267 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -716,6 +716,13 @@ const CONST = { SIGNER_DETAILS_FORM: 3, HANG_TIGHT: 4, }, + SIGNER_INFO_ADDRESS_DATA: { + STREET: 'street', + CITY: 'city', + STATE: 'state', + ZIP_CODE: 'zipCode', + COUNTRY: 'nationality', + }, }, BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX: 'accountHolder', }, diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 5389c173f74f..c461791b2da7 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -14,6 +14,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import EnterEmail from './EnterEmail'; import HangTight from './HangTight'; +import Address from './substeps/Address'; import Confirmation from './substeps/Confirmation'; import DateOfBirth from './substeps/DateOfBirth'; import JobTitle from './substeps/JobTitle'; @@ -34,7 +35,7 @@ type SignerDetailsFormProps = SubStepProps & {isSecondSigner: boolean}; const SUBSTEP: Record = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SUBSTEP; const {OWNS_MORE_THAN_25_PERCENT, COMPANY_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const fullBodyContent: Array> = [Name, JobTitle, DateOfBirth, UploadDocuments, Confirmation]; +const fullBodyContent: Array> = [Name, JobTitle, DateOfBirth, Address, UploadDocuments, Confirmation]; const userIsOwnerBodyContent: Array> = [JobTitle, UploadDocuments, Confirmation]; const userIsOwnerCadBodyContent: Array> = [UploadDocuments, Confirmation]; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx new file mode 100644 index 000000000000..de1f668d91b8 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx @@ -0,0 +1,105 @@ +import React, {useMemo, useState} from 'react'; +import {useOnyx} from 'react-native-onyx'; +import AddressStep from '@components/SubStepForms/AddressStep'; +import useLocalize from '@hooks/useLocalize'; +import useReimbursementAccountStepFormSubmit from '@hooks/useReimbursementAccountStepFormSubmit'; +import type {SubStepProps} from '@hooks/useSubStep/types'; +import CONST from '@src/CONST'; +import type {Country} from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; + +type NameProps = SubStepProps & {isSecondSigner: boolean}; + +const {STREET, CITY, STATE, ZIP_CODE, COUNTRY} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_ADDRESS_DATA; +const {SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; + +function Address({onNext, isEditing, onMove, isSecondSigner}: NameProps) { + const {translate} = useLocalize(); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + const prefix = isSecondSigner ? SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + + const countryInputKey = `${prefix}_${COUNTRY}` as const; + const inputKeys = { + street: `${prefix}_${STREET}`, + city: `${prefix}_${CITY}`, + state: `${prefix}_${STATE}`, + zipCode: `${prefix}_${ZIP_CODE}`, + country: countryInputKey, + } as const; + + const defaultValues = { + street: String(reimbursementAccountDraft?.[inputKeys.street] ?? ''), + city: String(reimbursementAccountDraft?.[inputKeys.city] ?? ''), + state: String(reimbursementAccountDraft?.[inputKeys.state] ?? ''), + zipCode: String(reimbursementAccountDraft?.[inputKeys.zipCode] ?? ''), + country: (reimbursementAccountDraft?.[inputKeys.country] ?? '') as Country | '', + }; + + const formTitle = translate('ownershipInfoStep.whatsYourAddress'); + + // Has to be stored in state and updated on country change due to the fact that we can't relay on onyxValues when user is editing the form (draft values are not being saved in that case) + const [shouldDisplayStateSelector, setShouldDisplayStateSelector] = useState( + defaultValues.country === CONST.COUNTRY.US || defaultValues.country === CONST.COUNTRY.CA || defaultValues.country === '', + ); + + const stepFieldsWithState = useMemo( + () => [inputKeys.street, inputKeys.city, inputKeys.state, inputKeys.zipCode, countryInputKey], + [countryInputKey, inputKeys.city, inputKeys.state, inputKeys.street, inputKeys.zipCode], + ); + const stepFieldsWithoutState = useMemo( + () => [inputKeys.street, inputKeys.city, inputKeys.zipCode, countryInputKey], + [countryInputKey, inputKeys.city, inputKeys.street, inputKeys.zipCode], + ); + + const stepFields = shouldDisplayStateSelector ? stepFieldsWithState : stepFieldsWithoutState; + + const handleCountryChange = (country: unknown) => { + if (typeof country !== 'string' || country === '') { + return; + } + setShouldDisplayStateSelector(country === CONST.COUNTRY.US || country === CONST.COUNTRY.CA); + }; + + const handleNextStep = () => { + // owner is US based we need to gather last four digits of his SSN + if (reimbursementAccountDraft?.[inputKeys.country] === CONST.COUNTRY.US) { + onNext(); + // currency is set to GBP and owner is UK based, so we skip SSN and Documents step + } else if (countryStepCountryValue === CONST.COUNTRY.GB && reimbursementAccountDraft?.[inputKeys.country] === CONST.COUNTRY.GB) { + onMove(6, false); + // owner is not US based so we skip SSN step + } else { + onMove(5, false); + } + }; + + const handleSubmit = useReimbursementAccountStepFormSubmit({ + fieldIds: stepFields, + onNext: handleNextStep, + shouldSaveDraft: isEditing, + }); + + return ( + + isEditing={isEditing} + onNext={onNext} + onMove={onMove} + formID={ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM} + formTitle={formTitle} + formPOBoxDisclaimer={translate('common.noPO')} + onSubmit={handleSubmit} + stepFields={stepFields} + inputFieldsIDs={inputKeys} + defaultValues={defaultValues} + onCountryChange={handleCountryChange} + shouldDisplayStateSelector={shouldDisplayStateSelector} + shouldDisplayCountrySelector + /> + ); +} + +Address.displayName = 'Address'; + +export default Address; diff --git a/src/types/form/ReimbursementAccountForm.ts b/src/types/form/ReimbursementAccountForm.ts index 19e1f28e0613..2812e5502305 100644 --- a/src/types/form/ReimbursementAccountForm.ts +++ b/src/types/form/ReimbursementAccountForm.ts @@ -139,6 +139,10 @@ type BeneficialOwnersStepExtraProps = { beneficialOwnerKeys?: string[]; }; +type SignerInfoStepExtraProps = { + [key: string]: string; +}; + type BeneficialOwnersStepProps = BeneficialOwnersStepBaseProps & BeneficialOwnersStepExtraProps; type BankAccountStepProps = { @@ -375,6 +379,7 @@ type NonUSDReimbursementAccountAdditionalProps = { }; type ReimbursementAccountForm = ReimbursementAccountFormExtraProps & + SignerInfoStepExtraProps & Form< InputID, BeneficialOwnersStepBaseProps & From adbe1db7f839cc37bc95bc22ec4c4208ada3d57a Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 4 Feb 2025 07:18:46 +0100 Subject: [PATCH 018/138] temporary skipping step 4 --- .../ReimbursementAccountPage.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index 35c89cc72285..ea80bdb0c37d 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -469,12 +469,12 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen /> ); case CONST.NON_USD_BANK_ACCOUNT.STEP.BENEFICIAL_OWNER_INFO: - return ( - - ); + // return ( + // + // ); case CONST.NON_USD_BANK_ACCOUNT.STEP.SIGNER_INFO: return ( Date: Tue, 4 Feb 2025 09:38:38 +0100 Subject: [PATCH 019/138] address added to the confirmation substep --- .../SignerInfo/substeps/Confirmation.tsx | 18 ++++++++++-- .../utils/getAddressValuesForSignerInfo.ts | 29 +++++++++++++++++++ .../ReimbursementAccountPage.tsx | 1 + 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx index 56966bc45887..65d0bbc54d0c 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx @@ -6,6 +6,7 @@ import type {SubStepProps} from '@hooks/useSubStep/types'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; +import getAddressValuesForSignerInfo from "@pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo"; type ConfirmationProps = SubStepProps & {isSecondSigner: boolean}; @@ -17,6 +18,8 @@ const { SECOND_SIGNER_JOB_TITLE, SIGNER_DATE_OF_BIRTH, SECOND_SIGNER_DATE_OF_BIRTH, + SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, + SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SIGNER_COPY_OF_ID, SECOND_SIGNER_COPY_OF_ID, SIGNER_ADDRESS_PROOF, @@ -30,7 +33,9 @@ function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationP const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; + const addressPrefix = isSecondSigner ? SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; const values = useMemo(() => getSubstepValues(SINGER_INFO_STEP_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); + const addressValues = useMemo(() => getAddressValuesForSignerInfo(addressPrefix, reimbursementAccountDraft), [addressPrefix, reimbursementAccountDraft]); const IDs = values[isSecondSigner ? SECOND_SIGNER_COPY_OF_ID : SIGNER_COPY_OF_ID]; const proofs = values[isSecondSigner ? SECOND_SIGNER_ADDRESS_PROOF : SIGNER_ADDRESS_PROOF]; @@ -49,7 +54,7 @@ function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationP description: translate('signerInfoStep.id'), shouldShowRightIcon: true, onPress: () => { - onMove(3); + onMove(4); }, }, { @@ -57,7 +62,7 @@ function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationP description: translate('signerInfoStep.proofOf'), shouldShowRightIcon: true, onPress: () => { - onMove(3); + onMove(4); }, }, ]; @@ -80,6 +85,15 @@ function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationP onMove(2); }, }); + + summaryItems.splice(3, 0, { + title: `${addressValues.street}, ${addressValues.city}, ${addressValues.state}, ${addressValues.zipCode}`, + description: translate('ownershipInfoStep.address'), + shouldShowRightIcon: true, + onPress: () => { + onMove(3); + }, + }); } return ( diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts new file mode 100644 index 000000000000..c1634205651f --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts @@ -0,0 +1,29 @@ +import type {OnyxEntry} from 'react-native-onyx'; +import type {ReimbursementAccountForm} from '@src/types/form'; + +type SignerInfoAddressValues = { + street: string; + city: string; + state: string; + zipCode: string; +}; + +function getAddressValuesForSignerInfo(prefix: string, reimbursementAccountDraft: OnyxEntry): SignerInfoAddressValues { + if (!reimbursementAccountDraft) { + return { + street: '', + city: '', + state: '', + zipCode: '', + }; + } + + return { + street: reimbursementAccountDraft[`${prefix}_street`], + city: reimbursementAccountDraft[`${prefix}_city`], + state: reimbursementAccountDraft[`${prefix}_state`], + zipCode: reimbursementAccountDraft[`${prefix}_zipCode`], + }; +} + +export default getAddressValuesForSignerInfo; diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index ea80bdb0c37d..487e84dac9ce 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -475,6 +475,7 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen // onSubmit={handleNextNonUSDBankAccountStep} // /> // ); + // eslint-disable-next-line no-fallthrough case CONST.NON_USD_BANK_ACCOUNT.STEP.SIGNER_INFO: return ( Date: Tue, 4 Feb 2025 14:51:02 +0100 Subject: [PATCH 020/138] wip: merging signer address from onyx and draft --- .../NonUSD/SignerInfo/index.tsx | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index c461791b2da7..c3038ced787d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,6 +1,6 @@ import type {ComponentType} from 'react'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; -import {useOnyx} from 'react-native-onyx'; +import { type OnyxEntry, useOnyx } from "react-native-onyx"; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import YesNoStep from '@components/SubStepForms/YesNoStep'; import useLocalize from '@hooks/useLocalize'; @@ -11,7 +11,7 @@ import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; +import INPUT_IDS, { type ReimbursementAccountForm } from "@src/types/form/ReimbursementAccountForm"; import EnterEmail from './EnterEmail'; import HangTight from './HangTight'; import Address from './substeps/Address'; @@ -20,6 +20,7 @@ import DateOfBirth from './substeps/DateOfBirth'; import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import UploadDocuments from './substeps/UploadDocuments'; +import type { ReimbursementAccount } from "@src/types/onyx"; type SignerInfoProps = { /** Handles back button press */ @@ -56,6 +57,10 @@ const INPUT_KEYS = { SIGNER_PDS_AND_FSG: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PDS_AND_FSG, }; +type SubstepValues = { + [TKey in TProps]: ReimbursementAccountForm[TKey]; +}; + function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const {translate} = useLocalize(); @@ -68,6 +73,28 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const onyxValues = useMemo(() => getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; + const hasDraftSignerAddress = ( + isSecondSigner: boolean, + reimbursementAccountDraft: OnyxEntry, + ) => { + const prefix = isSecondSigner ? INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + + return reimbursementAccountDraft?.[`${prefix}_street`] !== '' && reimbursementAccountDraft?.[`${prefix}_state`] !== '' && reimbursementAccountDraft?.[`${prefix}_city`] !== '' && reimbursementAccountDraft?.[`${prefix}_zipCode`] !== ''; + } + const getSignerAddressSubstepValues = ( + onyxValues: Record, + reimbursementAccountDraft: OnyxEntry, + reimbursementAccount: OnyxEntry, + isSecondSigner: boolean + ): SubstepValues => { + const prefix = isSecondSigner ? INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + + return { + ...onyxValues, + [prefix]: hasDraftSignerAddress(isSecondSigner, reimbursementAccountDraft) ? `${reimbursementAccountDraft?.[`${prefix}_street`]}` : ''; + } + }; + // TODO set this based on param from redirect or BE response const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; From fbe81a25ef990beb16b6da707806eaae464dc9cc Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 5 Feb 2025 10:10:05 +0100 Subject: [PATCH 021/138] get signer address value extracted to separate utils and wrapped up --- .../NonUSD/SignerInfo/index.tsx | 45 +++++-------------- .../utils/getSignerAddressSubstepValue.ts | 35 +++++++++++++++ 2 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index c3038ced787d..a56681d6de91 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,17 +1,18 @@ import type {ComponentType} from 'react'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; -import { type OnyxEntry, useOnyx } from "react-native-onyx"; +import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import YesNoStep from '@components/SubStepForms/YesNoStep'; import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; import Navigation from '@navigation/Navigation'; +import getSignerAddressSubstepValue from '@pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import INPUT_IDS, { type ReimbursementAccountForm } from "@src/types/form/ReimbursementAccountForm"; +import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import EnterEmail from './EnterEmail'; import HangTight from './HangTight'; import Address from './substeps/Address'; @@ -20,7 +21,6 @@ import DateOfBirth from './substeps/DateOfBirth'; import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import UploadDocuments from './substeps/UploadDocuments'; -import type { ReimbursementAccount } from "@src/types/onyx"; type SignerInfoProps = { /** Handles back button press */ @@ -57,10 +57,6 @@ const INPUT_KEYS = { SIGNER_PDS_AND_FSG: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PDS_AND_FSG, }; -type SubstepValues = { - [TKey in TProps]: ReimbursementAccountForm[TKey]; -}; - function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const {translate} = useLocalize(); @@ -70,36 +66,19 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const policyID = reimbursementAccount?.achData?.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const currency = policy?.outputCurrency ?? ''; - const onyxValues = useMemo(() => getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); - const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; - - const hasDraftSignerAddress = ( - isSecondSigner: boolean, - reimbursementAccountDraft: OnyxEntry, - ) => { - const prefix = isSecondSigner ? INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; - - return reimbursementAccountDraft?.[`${prefix}_street`] !== '' && reimbursementAccountDraft?.[`${prefix}_state`] !== '' && reimbursementAccountDraft?.[`${prefix}_city`] !== '' && reimbursementAccountDraft?.[`${prefix}_zipCode`] !== ''; - } - const getSignerAddressSubstepValues = ( - onyxValues: Record, - reimbursementAccountDraft: OnyxEntry, - reimbursementAccount: OnyxEntry, - isSecondSigner: boolean - ): SubstepValues => { - const prefix = isSecondSigner ? INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; - - return { - ...onyxValues, - [prefix]: hasDraftSignerAddress(isSecondSigner, reimbursementAccountDraft) ? `${reimbursementAccountDraft?.[`${prefix}_street`]}` : ''; - } - }; - // TODO set this based on param from redirect or BE response const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; const companyName = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? ''; - + const addressKey = isSecondSigner ? INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + const onyxValues = useMemo( + () => ({ + ...getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), + [addressKey]: getSignerAddressSubstepValue(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount, isSecondSigner), + }), + [addressKey, isSecondSigner, reimbursementAccount, reimbursementAccountDraft], + ); + const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; const [currentSubStep, setCurrentSubStep] = useState(SUBSTEP.IS_DIRECTOR); const [isUserDirector, setIsUserDirector] = useState(false); diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts new file mode 100644 index 000000000000..4f4598af0bc5 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts @@ -0,0 +1,35 @@ +import type {OnyxEntry} from 'react-native-onyx'; +import type {ReimbursementAccountForm} from '@src/types/form'; +import type {ReimbursementAccount} from '@src/types/onyx'; +import type {ACHData} from '@src/types/onyx/ReimbursementAccount'; + +type SubstepValues = { + [TKey in TProps]: ReimbursementAccountForm[TKey]; +}; + +const hasDraftSignerAddress = (inputKeys: Record, isSecondSigner: boolean, reimbursementAccountDraft: OnyxEntry) => { + const prefix = isSecondSigner ? inputKeys.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : inputKeys.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + + return ( + reimbursementAccountDraft?.[`${prefix}_street`] !== '' && + reimbursementAccountDraft?.[`${prefix}_state`] !== '' && + reimbursementAccountDraft?.[`${prefix}_city`] !== '' && + reimbursementAccountDraft?.[`${prefix}_zipCode`] !== '' + ); +}; +const getSignerAddressSubstepValue = ( + inputKeys: Record, + reimbursementAccountDraft: OnyxEntry, + reimbursementAccount: OnyxEntry, + isSecondSigner: boolean, +): string => { + const prefix = isSecondSigner ? inputKeys.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : inputKeys.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + + return hasDraftSignerAddress(inputKeys, isSecondSigner, reimbursementAccountDraft) + ? `${reimbursementAccountDraft?.[`${prefix}_street`]}, ${reimbursementAccountDraft?.[`${prefix}_city`]}, ${reimbursementAccountDraft?.[`${prefix}_state`]}, ${ + reimbursementAccountDraft?.[`${prefix}_zipCode`] + }` + : (reimbursementAccount?.achData?.[prefix as keyof ACHData] as string); +}; + +export default getSignerAddressSubstepValue; From c4ce465d3577eea1646dd1af8770fa9cfff71f88 Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 5 Feb 2025 19:37:56 +0100 Subject: [PATCH 022/138] get signer details and files utility method scaffolded --- .../utils/getSignerDetailsAndSignerFilesForSignerInfo.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts new file mode 100644 index 000000000000..7687f790fe04 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -0,0 +1,6 @@ +function getSignerDetailsAndSignerFilesForSignerInfo() { + // TODO: to be implemented + return null; +} + +export default getSignerDetailsAndSignerFilesForSignerInfo; From 3a43bc7cdeb691a5529ee1430381e9b53371f5f5 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 09:41:11 +0100 Subject: [PATCH 023/138] step 4 enabled back --- .../ReimbursementAccountPage.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index 487e84dac9ce..35c89cc72285 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -469,13 +469,12 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen /> ); case CONST.NON_USD_BANK_ACCOUNT.STEP.BENEFICIAL_OWNER_INFO: - // return ( - // - // ); - // eslint-disable-next-line no-fallthrough + return ( + + ); case CONST.NON_USD_BANK_ACCOUNT.STEP.SIGNER_INFO: return ( Date: Fri, 7 Feb 2025 09:41:47 +0100 Subject: [PATCH 024/138] address prefixes adjusted to new reqs --- .../NonUSD/SignerInfo/substeps/Address.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx index de1f668d91b8..567cdeee3f66 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx @@ -11,14 +11,15 @@ import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; type NameProps = SubStepProps & {isSecondSigner: boolean}; -const {STREET, CITY, STATE, ZIP_CODE, COUNTRY} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_ADDRESS_DATA; -const {SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {STREET, CITY, STATE, ZIP_CODE, COUNTRY} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; +const SIGNER_PREFIX = 'signer'; +const SECOND_SIGNER_PREFIX = 'signerSecond'; function Address({onNext, isEditing, onMove, isSecondSigner}: NameProps) { const {translate} = useLocalize(); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; - const prefix = isSecondSigner ? SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + const prefix = isSecondSigner ? SECOND_SIGNER_PREFIX : SIGNER_PREFIX; const countryInputKey = `${prefix}_${COUNTRY}` as const; const inputKeys = { From 6adcb614d2b9d019a05dfc35d20d405d0f4bc0ce Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 09:42:00 +0100 Subject: [PATCH 025/138] signer data shape adjusted --- src/CONST.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index a7672b4f1374..718d4eb0da9e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -721,12 +721,17 @@ const CONST = { SIGNER_DETAILS_FORM: 3, HANG_TIGHT: 4, }, - SIGNER_INFO_ADDRESS_DATA: { - STREET: 'street', - CITY: 'city', - STATE: 'state', - ZIP_CODE: 'zipCode', - COUNTRY: 'nationality', + SIGNER_INFO_DATA: { + FULL_NAME: 'signerFullName', + DATE_OF_BIRTH: 'signerDateOfBirth', + JOB_TITLE: 'signerJobTitle', + EMAIL: 'signerEmail', + ADDRESS: 'signerCompleteResidentialAddress', + STREET: 'signer_street', + CITY: 'signer_city', + STATE: 'signer_state', + ZIP_CODE: 'signer_zipCode', + COUNTRY: 'signer_nationality', }, }, BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX: 'accountHolder', From d92f37339b7a806bdd78c731d93167ac3ed5e410 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 09:42:15 +0100 Subject: [PATCH 026/138] signer details helper created --- ...ignerDetailsAndSignerFilesForSignerInfo.ts | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index 7687f790fe04..fdb6f67505f9 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -1,5 +1,32 @@ -function getSignerDetailsAndSignerFilesForSignerInfo() { - // TODO: to be implemented +import type {OnyxEntry} from 'react-native-onyx'; +import type {FileObject} from '@components/AttachmentModal'; +import CONST from '@src/CONST'; +import type {ReimbursementAccountForm} from '@src/types/form'; + +const {FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, COUNTRY, STATE, ZIP_CODE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; + +const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE, COUNTRY]; + +function getSignerDetailsAndSignerFilesForSignerInfo(signerKeys: string[], reimbursementAccountDraft: OnyxEntry) { + const signerDetails: Record = {}; + // const signerFiles: Record = {}; + + signerKeys.forEach((signerKey: string) => { + signerDetailsFields.forEach((fieldName: string) => { + if (!reimbursementAccountDraft?.[signerKey]) { + return; + } + + if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { + signerDetails[ADDRESS] = signerDetails[ADDRESS] + ? `${String(signerDetails[ADDRESS])}, ${String(reimbursementAccountDraft?.[signerKey])}` + : reimbursementAccountDraft?.[signerKey]; + } + + signerDetails[signerKey] = reimbursementAccountDraft?.[signerKey]; + }); + }); + return null; } From 670bbb22b4aa46d5f4dc5d9838fdf580db2beab6 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 14:34:42 +0100 Subject: [PATCH 027/138] new version of signer params --- ...rpayOnboardingDirectorInformationParams.ts | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts index 301164e1e4e7..5c6e16bafe03 100644 --- a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts +++ b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts @@ -1,30 +1,37 @@ import type {FileObject} from '@components/AttachmentModal'; -type SaveCorpayOnboardingCompanyDirector = { - signerFullName: string; - signerDateOfBirth: string; - signerJobTitle: string; - signerEmail: string; - signerCompleteResidentialAddress: string; -}; - -type SaveCorpayOnboardingDirectorInformation = { - companyDirectors: SaveCorpayOnboardingCompanyDirector[]; - proofOfDirectors?: FileObject[] | string; - copyOfID?: FileObject[] | string; - addressProof?: FileObject[] | string; - codiceProof?: FileObject[] | string; - pdsAndFSG?: FileObject[] | string; -}; +// type SaveCorpayOnboardingCompanyDirector = { +// signerFullName: string; +// signerDateOfBirth: string; +// signerJobTitle: string; +// signerEmail: string; +// signerCompleteResidentialAddress: string; +// }; +// +// type SaveCorpayOnboardingDirectorInformation = { +// companyDirectors: SaveCorpayOnboardingCompanyDirector[]; +// proofOfDirectors?: FileObject[] | string; +// copyOfID?: FileObject[] | string; +// addressProof?: FileObject[] | string; +// codiceProof?: FileObject[] | string; +// pdsAndFSG?: FileObject[] | string; +// }; +// +// type SaveCorpayOnboardingDirectorInformationParams = { +// inputs: string; +// bankAccountID: number; +// proofOfDirectors?: FileObject[] | string; +// copyOfID?: FileObject[] | string; +// addressProof?: FileObject[] | string; +// codiceProof?: FileObject[] | string; +// pdsAndFSG?: FileObject[] | string; +// }; type SaveCorpayOnboardingDirectorInformationParams = { inputs: string; + directorIDs?: string; + proofOfDirectors?: FileObject[]; bankAccountID: number; - proofOfDirectors?: FileObject[] | string; - copyOfID?: FileObject[] | string; - addressProof?: FileObject[] | string; - codiceProof?: FileObject[] | string; - pdsAndFSG?: FileObject[] | string; }; -export type {SaveCorpayOnboardingDirectorInformation, SaveCorpayOnboardingDirectorInformationParams}; +export default SaveCorpayOnboardingDirectorInformationParams; From 6e2bb3824074fabba6053b8cc52f92e3f489b4f5 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 14:35:15 +0100 Subject: [PATCH 028/138] signer info helper refactored --- ...ignerDetailsAndSignerFilesForSignerInfo.ts | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index fdb6f67505f9..3e3d4eb35ade 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -7,27 +7,22 @@ const {FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, COUNTR const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE, COUNTRY]; -function getSignerDetailsAndSignerFilesForSignerInfo(signerKeys: string[], reimbursementAccountDraft: OnyxEntry) { +function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry) { const signerDetails: Record = {}; - // const signerFiles: Record = {}; - - signerKeys.forEach((signerKey: string) => { - signerDetailsFields.forEach((fieldName: string) => { - if (!reimbursementAccountDraft?.[signerKey]) { - return; - } - - if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { - signerDetails[ADDRESS] = signerDetails[ADDRESS] - ? `${String(signerDetails[ADDRESS])}, ${String(reimbursementAccountDraft?.[signerKey])}` - : reimbursementAccountDraft?.[signerKey]; - } - - signerDetails[signerKey] = reimbursementAccountDraft?.[signerKey]; - }); + + signerDetailsFields.forEach((fieldName: string) => { + if (!reimbursementAccountDraft?.[fieldName]) { + return; + } + + if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { + signerDetails[ADDRESS] = signerDetails[ADDRESS] ? `${String(signerDetails[ADDRESS])}, ${String(reimbursementAccountDraft?.[fieldName])}` : reimbursementAccountDraft?.[fieldName]; + } + + signerDetails[fieldName] = reimbursementAccountDraft?.[fieldName]; }); - return null; + return {signerDetails}; } export default getSignerDetailsAndSignerFilesForSignerInfo; From 84accc32c9cc5e4820b7d86d4da58210898fd57c Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 14:35:55 +0100 Subject: [PATCH 029/138] save signer info API call adjusted to the new shape of payload --- src/libs/actions/BankAccounts.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 20bb3dbcd1c9..f7757a237516 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -13,7 +13,6 @@ import type { VerifyIdentityForBankAccountParams, } from '@libs/API/parameters'; import type {SaveCorpayOnboardingCompanyDetails} from '@libs/API/parameters/SaveCorpayOnboardingCompanyDetailsParams'; -import type {SaveCorpayOnboardingDirectorInformation} from '@libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams'; import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {translateLocal} from '@libs/Localize'; @@ -29,6 +28,8 @@ import type PlaidBankAccount from '@src/types/onyx/PlaidBankAccount'; import type {BankAccountStep, ReimbursementAccountStep, ReimbursementAccountSubStep} from '@src/types/onyx/ReimbursementAccount'; import type {OnyxData} from '@src/types/onyx/Request'; import {setBankAccountSubStep} from './ReimbursementAccount'; +import SaveCorpayOnboardingDirectorInformationParams + from "@libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams"; export { goToWithdrawalAccountSetupStep, @@ -542,12 +543,7 @@ function saveCorpayOnboardingBeneficialOwners(parameters: SaveCorpayOnboardingBe return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_BENEFICIAL_OWNER, parameters, onyxData); } -function saveCorpayOnboardingDirectorInformation(parameters: SaveCorpayOnboardingDirectorInformation, bankAccountID: number) { - const formattedParams = { - inputs: JSON.stringify(parameters), - bankAccountID, - }; - +function saveCorpayOnboardingDirectorInformation(parameters: SaveCorpayOnboardingDirectorInformationParams) { const onyxData: OnyxData = { optimisticData: [ { @@ -582,7 +578,7 @@ function saveCorpayOnboardingDirectorInformation(parameters: SaveCorpayOnboardin ], }; - return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION, formattedParams, onyxData); + return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION, parameters, onyxData); } function clearReimbursementAccount() { From cd985d8d5db6566ffd4eaaed75efdf218f09f2e5 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 7 Feb 2025 14:36:32 +0100 Subject: [PATCH 030/138] calling API call with data prepared with new helper --- .../NonUSD/SignerInfo/index.tsx | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index a56681d6de91..69da68316021 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -8,6 +8,7 @@ import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; import Navigation from '@navigation/Navigation'; import getSignerAddressSubstepValue from '@pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue'; +import getSignerDetailsAndSignerFilesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; @@ -94,32 +95,21 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }, [country]); const submit = useCallback(() => { + const {signerDetails} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft); + if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); } else { // eslint-disable-next-line @typescript-eslint/no-unsafe-call - BankAccounts.saveCorpayOnboardingDirectorInformation( - { - companyDirectors: [ - { - signerFullName: onyxValues[INPUT_KEYS.SIGNER_FULL_NAME], - signerDateOfBirth: onyxValues[INPUT_KEYS.SIGNER_DATE_OF_BIRTH], - signerJobTitle: onyxValues[INPUT_KEYS.SIGNER_JOB_TITLE], - signerEmail: account?.primaryLogin ?? '', - signerCompleteResidentialAddress: onyxValues[INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS], - }, - ], - copyOfID: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], - addressProof: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], - // TODO: uncomment when codiceProof is added to the form - codiceProof: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], - pdsAndFSG: onyxValues[INPUT_KEYS.SIGNER_ADDRESS_PROOF], - }, + BankAccounts.saveCorpayOnboardingDirectorInformation({ + inputs: JSON.stringify(signerDetails), bankAccountID, - ); + directorIDs: 'currentUser', + proofOfDirectors: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], + }); onSubmit(); } - }, [account?.primaryLogin, bankAccountID, currency, onSubmit, onyxValues]); + }, [bankAccountID, currency, onSubmit, onyxValues, reimbursementAccountDraft]); const handleNextSubStep = useCallback( (value: boolean) => { From 5d45d741b9810458de4fa6d43a0d85160fea3411 Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 10 Feb 2025 14:21:01 +0100 Subject: [PATCH 031/138] address component adjusted to the new Onyx keys shape --- .../NonUSD/SignerInfo/substeps/Address.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx index 567cdeee3f66..c3f19947cc84 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Address.tsx @@ -9,24 +9,21 @@ import type {Country} from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -type NameProps = SubStepProps & {isSecondSigner: boolean}; +type NameProps = SubStepProps; const {STREET, CITY, STATE, ZIP_CODE, COUNTRY} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; -const SIGNER_PREFIX = 'signer'; -const SECOND_SIGNER_PREFIX = 'signerSecond'; -function Address({onNext, isEditing, onMove, isSecondSigner}: NameProps) { +function Address({onNext, isEditing, onMove}: NameProps) { const {translate} = useLocalize(); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; - const prefix = isSecondSigner ? SECOND_SIGNER_PREFIX : SIGNER_PREFIX; - const countryInputKey = `${prefix}_${COUNTRY}` as const; + const countryInputKey = COUNTRY; const inputKeys = { - street: `${prefix}_${STREET}`, - city: `${prefix}_${CITY}`, - state: `${prefix}_${STATE}`, - zipCode: `${prefix}_${ZIP_CODE}`, + street: STREET, + city: CITY, + state: STATE, + zipCode: ZIP_CODE, country: countryInputKey, } as const; From 45c65cb4ba08f335fbe3f76cd30275c7ff93ad1a Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 10 Feb 2025 14:21:22 +0100 Subject: [PATCH 032/138] getting address values fixed --- .../NonUSD/utils/getAddressValuesForSignerInfo.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts index c1634205651f..aaf5753c02bf 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts @@ -1,4 +1,5 @@ import type {OnyxEntry} from 'react-native-onyx'; +import CONST from '@src/CONST'; import type {ReimbursementAccountForm} from '@src/types/form'; type SignerInfoAddressValues = { @@ -8,6 +9,8 @@ type SignerInfoAddressValues = { zipCode: string; }; +const {STREET, CITY, STATE, ZIP_CODE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; + function getAddressValuesForSignerInfo(prefix: string, reimbursementAccountDraft: OnyxEntry): SignerInfoAddressValues { if (!reimbursementAccountDraft) { return { @@ -19,10 +22,10 @@ function getAddressValuesForSignerInfo(prefix: string, reimbursementAccountDraft } return { - street: reimbursementAccountDraft[`${prefix}_street`], - city: reimbursementAccountDraft[`${prefix}_city`], - state: reimbursementAccountDraft[`${prefix}_state`], - zipCode: reimbursementAccountDraft[`${prefix}_zipCode`], + street: reimbursementAccountDraft[STREET], + city: reimbursementAccountDraft[CITY], + state: reimbursementAccountDraft[STATE], + zipCode: reimbursementAccountDraft[ZIP_CODE], }; } From 976e41d1ec305e5e0f4c10a5f012fd558fd62381 Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 10 Feb 2025 14:22:06 +0100 Subject: [PATCH 033/138] getting signer details for signer info fixed --- src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 2 +- .../utils/getSignerDetailsAndSignerFilesForSignerInfo.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 69da68316021..2405cf512a4e 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -67,7 +67,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const policyID = reimbursementAccount?.achData?.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const currency = policy?.outputCurrency ?? ''; - // TODO set this based on param from redirect or BE response + // TODO consider if this is needed const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; const companyName = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? ''; diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index 3e3d4eb35ade..c7d43cfdc89b 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -3,9 +3,9 @@ import type {FileObject} from '@components/AttachmentModal'; import CONST from '@src/CONST'; import type {ReimbursementAccountForm} from '@src/types/form'; -const {FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, COUNTRY, STATE, ZIP_CODE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; +const {FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, STATE, ZIP_CODE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; -const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE, COUNTRY]; +const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE]; function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry) { const signerDetails: Record = {}; @@ -17,6 +17,7 @@ function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { signerDetails[ADDRESS] = signerDetails[ADDRESS] ? `${String(signerDetails[ADDRESS])}, ${String(reimbursementAccountDraft?.[fieldName])}` : reimbursementAccountDraft?.[fieldName]; + return; } signerDetails[fieldName] = reimbursementAccountDraft?.[fieldName]; From 73a9bdf020abff012ba6fa3df0daacc3f06447a2 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 11 Feb 2025 09:48:23 +0100 Subject: [PATCH 034/138] unnecessary address helper removed --- .../NonUSD/SignerInfo/index.tsx | 10 +----- .../utils/getSignerAddressSubstepValue.ts | 35 ------------------- 2 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 2405cf512a4e..bead6c6656ae 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -7,7 +7,6 @@ import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; import Navigation from '@navigation/Navigation'; -import getSignerAddressSubstepValue from '@pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue'; import getSignerDetailsAndSignerFilesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import * as BankAccounts from '@userActions/BankAccounts'; @@ -71,14 +70,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; const companyName = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? ''; - const addressKey = isSecondSigner ? INPUT_KEYS.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : INPUT_KEYS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; - const onyxValues = useMemo( - () => ({ - ...getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), - [addressKey]: getSignerAddressSubstepValue(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount, isSecondSigner), - }), - [addressKey, isSecondSigner, reimbursementAccount, reimbursementAccountDraft], - ); + const onyxValues = useMemo(() => getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; const [currentSubStep, setCurrentSubStep] = useState(SUBSTEP.IS_DIRECTOR); const [isUserDirector, setIsUserDirector] = useState(false); diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts deleted file mode 100644 index 4f4598af0bc5..000000000000 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerAddressSubstepValue.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type {OnyxEntry} from 'react-native-onyx'; -import type {ReimbursementAccountForm} from '@src/types/form'; -import type {ReimbursementAccount} from '@src/types/onyx'; -import type {ACHData} from '@src/types/onyx/ReimbursementAccount'; - -type SubstepValues = { - [TKey in TProps]: ReimbursementAccountForm[TKey]; -}; - -const hasDraftSignerAddress = (inputKeys: Record, isSecondSigner: boolean, reimbursementAccountDraft: OnyxEntry) => { - const prefix = isSecondSigner ? inputKeys.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : inputKeys.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; - - return ( - reimbursementAccountDraft?.[`${prefix}_street`] !== '' && - reimbursementAccountDraft?.[`${prefix}_state`] !== '' && - reimbursementAccountDraft?.[`${prefix}_city`] !== '' && - reimbursementAccountDraft?.[`${prefix}_zipCode`] !== '' - ); -}; -const getSignerAddressSubstepValue = ( - inputKeys: Record, - reimbursementAccountDraft: OnyxEntry, - reimbursementAccount: OnyxEntry, - isSecondSigner: boolean, -): string => { - const prefix = isSecondSigner ? inputKeys.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : inputKeys.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; - - return hasDraftSignerAddress(inputKeys, isSecondSigner, reimbursementAccountDraft) - ? `${reimbursementAccountDraft?.[`${prefix}_street`]}, ${reimbursementAccountDraft?.[`${prefix}_city`]}, ${reimbursementAccountDraft?.[`${prefix}_state`]}, ${ - reimbursementAccountDraft?.[`${prefix}_zipCode`] - }` - : (reimbursementAccount?.achData?.[prefix as keyof ACHData] as string); -}; - -export default getSignerAddressSubstepValue; From 27ed2ec418d10848978db996fb1d0464352d3a49 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 11 Feb 2025 09:48:42 +0100 Subject: [PATCH 035/138] collecting signer email as account primary login added --- src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 2 +- .../utils/getSignerDetailsAndSignerFilesForSignerInfo.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index bead6c6656ae..0268e68c30a7 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -87,7 +87,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }, [country]); const submit = useCallback(() => { - const {signerDetails} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft); + const {signerDetails} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? ''); if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index c7d43cfdc89b..230a2ad4ad2e 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -7,10 +7,15 @@ const {FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, STATE, const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE]; -function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry) { +function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry, signerEmail: string) { const signerDetails: Record = {}; signerDetailsFields.forEach((fieldName: string) => { + if (fieldName === EMAIL) { + signerDetails[fieldName] = signerEmail; + return; + } + if (!reimbursementAccountDraft?.[fieldName]) { return; } From 0f92358735fded834ffc4053343ff8fe03d1227f Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 12 Feb 2025 11:33:12 +0100 Subject: [PATCH 036/138] occupation step added --- src/CONST.ts | 4 ++ src/languages/en.ts | 2 + src/languages/es.ts | 3 + .../NonUSD/SignerInfo/substeps/Occupation.tsx | 62 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 81ff0355fc00..81fba6b44fb4 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -722,6 +722,7 @@ const CONST = { HANG_TIGHT: 4, }, SIGNER_INFO_DATA: { + PREFIX: 'director', FULL_NAME: 'signerFullName', DATE_OF_BIRTH: 'signerDateOfBirth', JOB_TITLE: 'signerJobTitle', @@ -732,6 +733,9 @@ const CONST = { STATE: 'signer_state', ZIP_CODE: 'signer_zipCode', COUNTRY: 'signer_nationality', + DIRECTOR_OCCUPATION: 'occupation', + DIRECTOR_FULL_NAME: 'fullName', + DIRECTOR_JOB_TITLE: 'jobTitle', }, }, BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX: 'accountHolder', diff --git a/src/languages/en.ts b/src/languages/en.ts index 1667f328a60f..0e02a36161c0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2481,6 +2481,8 @@ const translations = { sendReminder: 'Send a reminder', chooseFile: 'Choose file', weAreWaiting: "We're waiting for others to verify their identities as directors or senior officers of the business.", + occupation: 'Occupation', + whatsYourOccupation: "What's your occupation?", }, agreementsStep: { agreements: 'Agreements', diff --git a/src/languages/es.ts b/src/languages/es.ts index f4b309b48224..aeabb7d0a3b0 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2506,6 +2506,9 @@ const translations = { sendReminder: 'Enviar un recordatorio', chooseFile: 'Seleccionar archivo', weAreWaiting: 'Estamos esperando que otros verifiquen sus identidades como directores o altos funcionarios de la empresa.', + // TODO: translate it: + occupation: 'Occupation', + whatsYourOccupation: "What's your occupation?", }, agreementsStep: { agreements: 'Acuerdos', diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx new file mode 100644 index 000000000000..e6d7ba3646a9 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx @@ -0,0 +1,62 @@ +import React, {useCallback} from 'react'; +import {useOnyx} from 'react-native-onyx'; +import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; +import SingleFieldStep from '@components/SubStepForms/SingleFieldStep'; +import useLocalize from '@hooks/useLocalize'; +import useReimbursementAccountStepFormSubmit from '@hooks/useReimbursementAccountStepFormSubmit'; +import type {SubStepProps} from '@hooks/useSubStep/types'; +import * as ValidationUtils from '@libs/ValidationUtils'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; + +type OccupationProps = SubStepProps & {directorID: string}; + +const {PREFIX, DIRECTOR_OCCUPATION} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; + +function Occupation({onNext, onMove, isEditing, directorID}: OccupationProps) { + const {translate} = useLocalize(); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + + const inputID = `${PREFIX}_${directorID}_${DIRECTOR_OCCUPATION}`; + const defaultValue = reimbursementAccountDraft?.[inputID] ?? ''; + + const validate = useCallback( + (values: FormOnyxValues): FormInputErrors => { + const errors = ValidationUtils.getFieldRequiredErrors(values, [inputID]); + + if (values[inputID] && !ValidationUtils.isValidLegalName(values[inputID])) { + errors[inputID] = translate('bankAccount.error.fullName'); + } + + return errors; + }, + [inputID, translate], + ); + + const handleSubmit = useReimbursementAccountStepFormSubmit({ + fieldIds: [inputID], + onNext, + shouldSaveDraft: isEditing, + }); + + return ( + + isEditing={isEditing} + onNext={onNext} + onMove={onMove} + formID={ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM} + formTitle={translate('signerInfoStep.whatsYourOccupation')} + validate={validate} + onSubmit={handleSubmit} + inputId={inputID} + inputLabel={translate('signerInfoStep.occupation')} + inputMode={CONST.INPUT_MODE.TEXT} + defaultValue={defaultValue} + shouldShowHelpLinks={false} + /> + ); +} + +Occupation.displayName = 'Occupation'; + +export default Occupation; From 7dd79a0196c1b550bb0890c14598ccb9cb14c9ed Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 12 Feb 2025 11:33:34 +0100 Subject: [PATCH 037/138] reimbursement account form signer info type adjusted --- src/types/form/ReimbursementAccountForm.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/types/form/ReimbursementAccountForm.ts b/src/types/form/ReimbursementAccountForm.ts index 2812e5502305..682b54d7f44c 100644 --- a/src/types/form/ReimbursementAccountForm.ts +++ b/src/types/form/ReimbursementAccountForm.ts @@ -139,9 +139,7 @@ type BeneficialOwnersStepExtraProps = { beneficialOwnerKeys?: string[]; }; -type SignerInfoStepExtraProps = { - [key: string]: string; -}; +type SignerInfoStepExtraProps = Record; type BeneficialOwnersStepProps = BeneficialOwnersStepBaseProps & BeneficialOwnersStepExtraProps; From b4e4cce3fc03c552fb975908838702d3369c8412 Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 12 Feb 2025 11:33:55 +0100 Subject: [PATCH 038/138] collecting additional data of current user handled --- .../NonUSD/SignerInfo/index.tsx | 12 ++++++--- ...ignerDetailsAndSignerFilesForSignerInfo.ts | 25 ++++++++++++++++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 0268e68c30a7..7a6ecc8b0a9c 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -20,6 +20,7 @@ import Confirmation from './substeps/Confirmation'; import DateOfBirth from './substeps/DateOfBirth'; import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; +import Occupation from './substeps/Occupation'; import UploadDocuments from './substeps/UploadDocuments'; type SignerInfoProps = { @@ -30,13 +31,13 @@ type SignerInfoProps = { onSubmit: () => void; }; -type SignerDetailsFormProps = SubStepProps & {isSecondSigner: boolean}; +type SignerDetailsFormProps = SubStepProps & {isSecondSigner: boolean; directorID: string}; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment const SUBSTEP: Record = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SUBSTEP; const {OWNS_MORE_THAN_25_PERCENT, COMPANY_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const fullBodyContent: Array> = [Name, JobTitle, DateOfBirth, Address, UploadDocuments, Confirmation]; +const fullBodyContent: Array> = [Name, JobTitle, Occupation, DateOfBirth, Address, UploadDocuments, Confirmation]; const userIsOwnerBodyContent: Array> = [JobTitle, UploadDocuments, Confirmation]; const userIsOwnerCadBodyContent: Array> = [UploadDocuments, Confirmation]; @@ -60,6 +61,8 @@ const INPUT_KEYS = { function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const {translate} = useLocalize(); + // TODO: change it to be state value (might change if there is more directors) + const directorID = 'currentUser'; const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const [account] = useOnyx(ONYXKEYS.ACCOUNT); @@ -87,7 +90,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }, [country]); const submit = useCallback(() => { - const {signerDetails} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? ''); + const {signerDetails} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorID); if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); @@ -96,7 +99,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { BankAccounts.saveCorpayOnboardingDirectorInformation({ inputs: JSON.stringify(signerDetails), bankAccountID, - directorIDs: 'currentUser', + directorIDs: `${directorID}`, proofOfDirectors: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], }); onSubmit(); @@ -193,6 +196,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { onNext={nextScreen} onMove={moveTo} isSecondSigner={isSecondSigner} + directorID={directorID} /> )} diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index 230a2ad4ad2e..05a68dbbe685 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -3,11 +3,11 @@ import type {FileObject} from '@components/AttachmentModal'; import CONST from '@src/CONST'; import type {ReimbursementAccountForm} from '@src/types/form'; -const {FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, STATE, ZIP_CODE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; +const {PREFIX, FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, STATE, ZIP_CODE, DIRECTOR_OCCUPATION, DIRECTOR_FULL_NAME, DIRECTOR_JOB_TITLE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; -const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE]; +const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE, DIRECTOR_OCCUPATION, DIRECTOR_FULL_NAME, DIRECTOR_JOB_TITLE]; -function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry, signerEmail: string) { +function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry, signerEmail: string, directorID: string) { const signerDetails: Record = {}; signerDetailsFields.forEach((fieldName: string) => { @@ -16,6 +16,25 @@ function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: return; } + if (directorID === 'currentUser') { + const fieldKey = `${PREFIX}_${directorID}_${fieldName}`; + + if (fieldName === DIRECTOR_FULL_NAME) { + signerDetails[fieldKey] = String(reimbursementAccountDraft?.[FULL_NAME]); + return; + } + + if (fieldName === DIRECTOR_JOB_TITLE) { + signerDetails[fieldKey] = String(reimbursementAccountDraft?.[JOB_TITLE]); + return; + } + + if (fieldName === DIRECTOR_OCCUPATION) { + signerDetails[fieldKey] = String(reimbursementAccountDraft?.[fieldKey]); + return; + } + } + if (!reimbursementAccountDraft?.[fieldName]) { return; } From b56ec2cca9e1e5f7aed733bc9857f627434ec36e Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 12 Feb 2025 14:20:48 +0100 Subject: [PATCH 039/138] proof of directors collecting added --- src/CONST.ts | 5 ++ src/languages/en.ts | 1 + src/languages/es.ts | 1 + ...rpayOnboardingDirectorInformationParams.ts | 2 +- .../NonUSD/SignerInfo/index.tsx | 13 ++-- .../SignerInfo/substeps/UploadDocuments.tsx | 44 +++++++++---- ...ignerDetailsAndSignerFilesForSignerInfo.ts | 35 +++++++++- src/types/form/ReimbursementAccountForm.ts | 64 ++++--------------- src/types/onyx/ReimbursementAccount.ts | 32 ++-------- 9 files changed, 96 insertions(+), 101 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 81fba6b44fb4..5b34231c9b8a 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -733,6 +733,11 @@ const CONST = { STATE: 'signer_state', ZIP_CODE: 'signer_zipCode', COUNTRY: 'signer_nationality', + PROOF_OF_DIRECTORS: 'proofOfDirectors', + COPY_OF_ID: 'copyOfID', + ADDRESS_PROOF: 'addressProof', + CODICE_FISCALE: 'codiceFisclaleTaxID', + PRD_AND_SFG: 'PRDAndFSG', DIRECTOR_OCCUPATION: 'occupation', DIRECTOR_FULL_NAME: 'fullName', DIRECTOR_JOB_TITLE: 'jobTitle', diff --git a/src/languages/en.ts b/src/languages/en.ts index d5fcdfacb1b5..9c7533fa3c69 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2483,6 +2483,7 @@ const translations = { weAreWaiting: "We're waiting for others to verify their identities as directors or senior officers of the business.", occupation: 'Occupation', whatsYourOccupation: "What's your occupation?", + proofOfDirectors: 'Proof of directors', }, agreementsStep: { agreements: 'Agreements', diff --git a/src/languages/es.ts b/src/languages/es.ts index 113ed3b808be..5d7077c6bf9c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2509,6 +2509,7 @@ const translations = { // TODO: translate it: occupation: 'Occupation', whatsYourOccupation: "What's your occupation?", + proofOfDirectors: 'Proof of directors', }, agreementsStep: { agreements: 'Acuerdos', diff --git a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts index 5c6e16bafe03..117c6f73769c 100644 --- a/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts +++ b/src/libs/API/parameters/SaveCorpayOnboardingDirectorInformationParams.ts @@ -30,7 +30,7 @@ import type {FileObject} from '@components/AttachmentModal'; type SaveCorpayOnboardingDirectorInformationParams = { inputs: string; directorIDs?: string; - proofOfDirectors?: FileObject[]; + proofOfDirectors?: FileObject; bankAccountID: number; }; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 7a6ecc8b0a9c..b20349ddb0ef 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -22,6 +22,7 @@ import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import Occupation from './substeps/Occupation'; import UploadDocuments from './substeps/UploadDocuments'; +import {FileObject} from '@components/AttachmentModal'; type SignerInfoProps = { /** Handles back button press */ @@ -47,15 +48,11 @@ const INPUT_KEYS = { SIGNER_JOB_TITLE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_JOB_TITLE, SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_EMAIL, SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, - SECOND_SIGNER_FULL_NAME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_FULL_NAME, - SECOND_SIGNER_DATE_OF_BIRTH: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_DATE_OF_BIRTH, - SECOND_SIGNER_JOB_TITLE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_JOB_TITLE, - SECOND_SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL, - SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SIGNER_COPY_OF_ID: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COPY_OF_ID, SIGNER_ADDRESS_PROOF: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_ADDRESS_PROOF, // SIGNER_CODICE_PROOF: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_CODICE_PROOF, - SIGNER_PDS_AND_FSG: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PDS_AND_FSG, + SIGNER_PDS_AND_FSG: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PRD_AND_SFG, + SIGNER_PROOF_OF_DIRECTORS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PROOF_OF_DIRECTORS, }; function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { @@ -90,7 +87,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }, [country]); const submit = useCallback(() => { - const {signerDetails} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorID); + const {signerDetails, signerFiles} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorID); if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); @@ -100,7 +97,7 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { inputs: JSON.stringify(signerDetails), bankAccountID, directorIDs: `${directorID}`, - proofOfDirectors: onyxValues[INPUT_KEYS.SIGNER_COPY_OF_ID], + proofOfDirectors: signerFiles[INPUT_KEYS.SIGNER_PROOF_OF_DIRECTORS] as FileObject, }); onSubmit(); } diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx index fbfeb21a02ff..1aaf945e881d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx @@ -21,8 +21,9 @@ import { setDraftValues } from "@userActions/FormActions"; type UploadDocumentsProps = SubStepProps; -const {SIGNER_ADDRESS_PROOF, SIGNER_COPY_OF_ID} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const STEP_FIELDS = [SIGNER_COPY_OF_ID, SIGNER_ADDRESS_PROOF]; +const {SIGNER_ADDRESS_PROOF, SIGNER_PROOF_OF_DIRECTORS, SIGNER_COPY_OF_ID} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {ADDRESS_PROOF, PROOF_OF_DIRECTORS, COPY_OF_ID} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; +const STEP_FIELDS = [ADDRESS_PROOF, PROOF_OF_DIRECTORS, COPY_OF_ID]; function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { const {translate} = useLocalize(); @@ -32,12 +33,15 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const defaultValues = { - [SIGNER_COPY_OF_ID]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_COPY_OF_ID] ?? reimbursementAccountDraft?.[SIGNER_COPY_OF_ID] ?? [], - [SIGNER_ADDRESS_PROOF]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_ADDRESS_PROOF] ?? reimbursementAccountDraft?.[SIGNER_ADDRESS_PROOF] ?? [], + [`signer_${COPY_OF_ID}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_COPY_OF_ID] ?? reimbursementAccountDraft?.[`signer_${COPY_OF_ID}`] ?? [], + [`signer_${ADDRESS_PROOF}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_ADDRESS_PROOF] ?? reimbursementAccountDraft?.[`signer_${ADDRESS_PROOF}`] ?? [], + [`signer_${PROOF_OF_DIRECTORS}`]: + reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_PROOF_OF_DIRECTORS] ?? reimbursementAccountDraft?.[`signer_${PROOF_OF_DIRECTORS}`] ?? [], }; - const [uploadedIDs, setUploadedID] = useState(defaultValues[SIGNER_ADDRESS_PROOF]); - const [uploadedProofsOfAddress, setUploadedProofOfAddress] = useState(defaultValues[SIGNER_ADDRESS_PROOF]); + const [uploadedIDs, setUploadedID] = useState(defaultValues[`signer_${COPY_OF_ID}`] as FileObject[]); + const [uploadedProofsOfAddress, setUploadedProofOfAddress] = useState(defaultValues[`signer_${ADDRESS_PROOF}`] as FileObject[]); + const [uploadedProofsOfDirectors, setUploadedProofsOfDirectors] = useState(defaultValues[`signer_${PROOF_OF_DIRECTORS}`] as FileObject[]); const validate = useCallback((values: FormOnyxValues): FormInputErrors => { return ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); @@ -82,14 +86,14 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { buttonText={translate('signerInfoStep.chooseFile')} uploadedFiles={uploadedIDs} onUpload={(files) => { - handleSelectFile(files, uploadedIDs, SIGNER_COPY_OF_ID, setUploadedID); + handleSelectFile(files, uploadedIDs, `signer_${COPY_OF_ID}`, setUploadedID); }} onRemove={(fileName) => { - handleRemoveFile(fileName, uploadedIDs, SIGNER_COPY_OF_ID, setUploadedID); + handleRemoveFile(fileName, uploadedIDs, `signer_${COPY_OF_ID}`, setUploadedID); }} acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} value={uploadedIDs} - inputID={SIGNER_COPY_OF_ID} + inputID={`signer_${COPY_OF_ID}`} setError={setError} /> {translate('signerInfoStep.proofOf')} @@ -98,14 +102,30 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { buttonText={translate('signerInfoStep.chooseFile')} uploadedFiles={uploadedProofsOfAddress} onUpload={(files) => { - handleSelectFile(files, uploadedProofsOfAddress, SIGNER_ADDRESS_PROOF, setUploadedProofOfAddress); + handleSelectFile(files, uploadedProofsOfAddress, `signer_${ADDRESS_PROOF}`, setUploadedProofOfAddress); }} onRemove={(fileName) => { - handleRemoveFile(fileName, uploadedProofsOfAddress, SIGNER_ADDRESS_PROOF, setUploadedProofOfAddress); + handleRemoveFile(fileName, uploadedProofsOfAddress, `signer_${ADDRESS_PROOF}`, setUploadedProofOfAddress); }} acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} value={uploadedProofsOfAddress} - inputID={SIGNER_ADDRESS_PROOF} + inputID={`signer_${ADDRESS_PROOF}`} + setError={setError} + /> + {translate('signerInfoStep.proofOfDirectors')} + { + handleSelectFile(files, uploadedProofsOfDirectors, `signer_${PROOF_OF_DIRECTORS}`, setUploadedProofsOfDirectors); + }} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedProofsOfDirectors, `signer_${PROOF_OF_DIRECTORS}`, setUploadedProofsOfDirectors); + }} + acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} + value={uploadedProofsOfDirectors} + inputID={`signer_${PROOF_OF_DIRECTORS}`} setError={setError} /> diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index 05a68dbbe685..2834c17625fb 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -3,12 +3,33 @@ import type {FileObject} from '@components/AttachmentModal'; import CONST from '@src/CONST'; import type {ReimbursementAccountForm} from '@src/types/form'; -const {PREFIX, FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, ADDRESS, STREET, CITY, STATE, ZIP_CODE, DIRECTOR_OCCUPATION, DIRECTOR_FULL_NAME, DIRECTOR_JOB_TITLE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; +const { + PREFIX, + FULL_NAME, + EMAIL, + JOB_TITLE, + DATE_OF_BIRTH, + ADDRESS, + STREET, + CITY, + STATE, + ZIP_CODE, + DIRECTOR_OCCUPATION, + DIRECTOR_FULL_NAME, + DIRECTOR_JOB_TITLE, + PROOF_OF_DIRECTORS, + ADDRESS_PROOF, + COPY_OF_ID, + CODICE_FISCALE, + PRD_AND_SFG, +} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, CITY, STATE, ZIP_CODE, DIRECTOR_OCCUPATION, DIRECTOR_FULL_NAME, DIRECTOR_JOB_TITLE]; +const signerFilesFields = [PROOF_OF_DIRECTORS, ADDRESS_PROOF, COPY_OF_ID, CODICE_FISCALE, PRD_AND_SFG]; function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry, signerEmail: string, directorID: string) { const signerDetails: Record = {}; + const signerFiles: Record = {}; signerDetailsFields.forEach((fieldName: string) => { if (fieldName === EMAIL) { @@ -47,7 +68,17 @@ function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: signerDetails[fieldName] = reimbursementAccountDraft?.[fieldName]; }); - return {signerDetails}; + signerFilesFields.forEach((fieldName) => { + const key = `signer_${fieldName}`; + + if (!reimbursementAccountDraft?.[key]) { + return; + } + + signerFiles[fieldName] = reimbursementAccountDraft?.[key][0]; + }); + + return {signerDetails, signerFiles}; } export default getSignerDetailsAndSignerFilesForSignerInfo; diff --git a/src/types/form/ReimbursementAccountForm.ts b/src/types/form/ReimbursementAccountForm.ts index 682b54d7f44c..e405931941b3 100644 --- a/src/types/form/ReimbursementAccountForm.ts +++ b/src/types/form/ReimbursementAccountForm.ts @@ -99,21 +99,11 @@ const INPUT_IDS = { SIGNER_JOB_TITLE: 'signerJobTitle', SIGNER_EMAIL: 'signerEmail', SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: 'signerCompleteResidentialAddress', - SECOND_SIGNER_FULL_NAME: 'secondSignerFullName', - SECOND_SIGNER_DATE_OF_BIRTH: 'secondSignerDateOfBirth', - SECOND_SIGNER_JOB_TITLE: 'secondSignerJobTitle', - SECOND_SIGNER_EMAIL: 'secondSignerEmail', - SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: 'secondSignerCompleteResidentialAddress', - SIGNER_PROOF_OF_DIRECTOR: 'signerProofOfDirector', - SIGNER_COPY_OF_ID: 'signerCopyOfID', - SIGNER_ADDRESS_PROOF: 'signerAddressProof', - SIGNER_TAX_ID: 'signerTaxID', - SIGNER_PDS_AND_FSG: 'signerPDSAndFSG', - SECOND_SIGNER_PROOF_OF_DIRECTOR: 'secondSignerProofOfDirector', - SECOND_SIGNER_COPY_OF_ID: 'secondSignerCopyOfID', - SECOND_SIGNER_ADDRESS_PROOF: 'secondSignerAddressProof', - SECOND_SIGNER_TAX_ID: 'secondSignerTaxID', - SECOND_SIGNER_PDS_AND_FSG: 'secondSignerPDSAndFSG', + SIGNER_PROOF_OF_DIRECTORS: 'proofOfDirectors', + SIGNER_ADDRESS_PROOF: 'addressProof', + SIGNER_COPY_OF_ID: 'copyOfID', + SIGNER_CODICE_FISCALE: 'codiceFiscaleTaxID', + SIGNER_PRD_AND_SFG: 'PRDAndFSG', PROVIDE_TRUTHFUL_INFORMATION: 'provideTruthfulInformation', AGREE_TO_TERMS_AND_CONDITIONS: 'agreeToTermsAndConditions', CONSENT_TO_PRIVACY_NOTICE: 'consentToPrivacyNotice', @@ -139,7 +129,7 @@ type BeneficialOwnersStepExtraProps = { beneficialOwnerKeys?: string[]; }; -type SignerInfoStepExtraProps = Record; +type SignerInfoStepExtraProps = Record; type BeneficialOwnersStepProps = BeneficialOwnersStepBaseProps & BeneficialOwnersStepExtraProps; @@ -318,50 +308,20 @@ type NonUSDReimbursementAccountAdditionalProps = { /** Signer complete residential address */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS]: string; - /** Second signer full name */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_FULL_NAME]: string; - - /** Second signer date of birth */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_DATE_OF_BIRTH]: string; - - /** Second signer job title */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_JOB_TITLE]: string; - - /** Second signer email */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL]: string; - - /** Second signer complete residential address */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS]: string; - - /** Signer proof of director */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PROOF_OF_DIRECTOR]: FileObject[]; - /** Signer copy of ID */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COPY_OF_ID]: FileObject[]; /** Signer address proof */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_ADDRESS_PROOF]: FileObject[]; - /** Signer tax ID */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_TAX_ID]: string; - - /** Signer PDS and FSG */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PDS_AND_FSG]: string; - - /** Second signer proof of director */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_PROOF_OF_DIRECTOR]: FileObject[]; - - /** Second signer copy of ID */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COPY_OF_ID]: FileObject[]; - - /** Second signer address proof */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_ADDRESS_PROOF]: FileObject[]; + /** Signer proof of directors */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PROOF_OF_DIRECTORS]: FileObject[]; - /** Second signer tax ID */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_TAX_ID]: string; + /** Signer PRD and SFG */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PRD_AND_SFG]: FileObject[]; - /** Second signer PDS and FSG */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_PDS_AND_FSG]: string; + /** Signer Codice Fiscale TAX ID */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_CODICE_FISCALE]: FileObject[]; /** Provide truthful information */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.PROVIDE_TRUTHFUL_INFORMATION]: boolean; diff --git a/src/types/onyx/ReimbursementAccount.ts b/src/types/onyx/ReimbursementAccount.ts index dab606844209..30234c46163b 100644 --- a/src/types/onyx/ReimbursementAccount.ts +++ b/src/types/onyx/ReimbursementAccount.ts @@ -87,36 +87,16 @@ type Corpay = { [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_EMAIL]: string; /** Signer full address */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS]: string; - /** Second signer full name */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_FULL_NAME]?: string; - /** Second signer DOB */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_DATE_OF_BIRTH]?: string; - /** Second signer job title */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_JOB_TITLE]?: string; - /** Second signer email address */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL]?: string; - /** Second signer full address */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS]: string; - /** URL to uploaded proof of signer being a director */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PROOF_OF_DIRECTOR]: FileObject[]; /** URL to uploaded copy of signer ID */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COPY_OF_ID]: FileObject[]; /** URL to uploaded proof of signer address */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_ADDRESS_PROOF]: FileObject[]; - /** Signer tax ID */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_TAX_ID]: string; - /** Signer PDS and FSG */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PDS_AND_FSG]: string; - /** URL to uploaded proof of second signer being a director */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_PROOF_OF_DIRECTOR]?: FileObject[]; - /** URL to uploaded copy of second signer ID */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_COPY_OF_ID]?: FileObject[]; - /** URL to uploaded proof of second signer address */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_ADDRESS_PROOF]?: FileObject[]; - /** Second signer tax ID */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_TAX_ID]?: string; - /** Second signer PDS and FSG */ - [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_PDS_AND_FSG]?: string; + /** URL to proof of directors */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PROOF_OF_DIRECTORS]: FileObject[]; + /** URL to codice fiscale proof */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_CODICE_FISCALE]: FileObject[]; + /** URL to PRD and SFG */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PRD_AND_SFG]: FileObject[]; /** Checkbox - provided truthful information */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.PROVIDE_TRUTHFUL_INFORMATION]: boolean; /** Checkbox - agrees to terms and conditions */ From 692ed1de629d19856c9e6f0fb3c85dfdd8b6d1fd Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 13 Feb 2025 14:37:36 +0100 Subject: [PATCH 040/138] upload signer info files depending on country (WIP) --- .../NonUSD/SignerInfo/index.tsx | 4 +- .../SignerInfo/substeps/UploadDocuments.tsx | 118 ++++++++++-------- .../getNeededDocumentsStatusForSignerInfo.ts | 22 ++++ 3 files changed, 92 insertions(+), 52 deletions(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForSignerInfo.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index b20349ddb0ef..1aa078208646 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -95,13 +95,13 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { // eslint-disable-next-line @typescript-eslint/no-unsafe-call BankAccounts.saveCorpayOnboardingDirectorInformation({ inputs: JSON.stringify(signerDetails), + ...signerFiles, bankAccountID, directorIDs: `${directorID}`, - proofOfDirectors: signerFiles[INPUT_KEYS.SIGNER_PROOF_OF_DIRECTORS] as FileObject, }); onSubmit(); } - }, [bankAccountID, currency, onSubmit, onyxValues, reimbursementAccountDraft]); + }, [account?.primaryLogin, bankAccountID, currency, onSubmit, reimbursementAccountDraft]); const handleNextSubStep = useCallback( (value: boolean) => { diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx index 1aaf945e881d..23a42c45927c 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx @@ -12,12 +12,12 @@ import useReimbursementAccountStepFormSubmit from '@hooks/useReimbursementAccoun import type {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; +import getNeededDocumentsStatusForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForSignerInfo'; import WhyLink from '@pages/ReimbursementAccount/NonUSD/WhyLink'; -import * as FormActions from '@userActions/FormActions'; +import {setDraftValues} from '@userActions/FormActions'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -import { setDraftValues } from "@userActions/FormActions"; type UploadDocumentsProps = SubStepProps; @@ -31,6 +31,12 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const policyID = reimbursementAccount?.achData?.policyID; + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + + const currency = policy?.outputCurrency ?? ''; + const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + const isDocumentNeededStatus = getNeededDocumentsStatusForSignerInfo(currency, countryStepCountryValue); const defaultValues = { [`signer_${COPY_OF_ID}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_COPY_OF_ID] ?? reimbursementAccountDraft?.[`signer_${COPY_OF_ID}`] ?? [], @@ -80,54 +86,66 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { > {translate('signerInfoStep.uploadID')} - {translate('signerInfoStep.id')} - { - handleSelectFile(files, uploadedIDs, `signer_${COPY_OF_ID}`, setUploadedID); - }} - onRemove={(fileName) => { - handleRemoveFile(fileName, uploadedIDs, `signer_${COPY_OF_ID}`, setUploadedID); - }} - acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} - value={uploadedIDs} - inputID={`signer_${COPY_OF_ID}`} - setError={setError} - /> - {translate('signerInfoStep.proofOf')} - { - handleSelectFile(files, uploadedProofsOfAddress, `signer_${ADDRESS_PROOF}`, setUploadedProofOfAddress); - }} - onRemove={(fileName) => { - handleRemoveFile(fileName, uploadedProofsOfAddress, `signer_${ADDRESS_PROOF}`, setUploadedProofOfAddress); - }} - acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} - value={uploadedProofsOfAddress} - inputID={`signer_${ADDRESS_PROOF}`} - setError={setError} - /> - {translate('signerInfoStep.proofOfDirectors')} - { - handleSelectFile(files, uploadedProofsOfDirectors, `signer_${PROOF_OF_DIRECTORS}`, setUploadedProofsOfDirectors); - }} - onRemove={(fileName) => { - handleRemoveFile(fileName, uploadedProofsOfDirectors, `signer_${PROOF_OF_DIRECTORS}`, setUploadedProofsOfDirectors); - }} - acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} - value={uploadedProofsOfDirectors} - inputID={`signer_${PROOF_OF_DIRECTORS}`} - setError={setError} - /> + {isDocumentNeededStatus.isCopyOfIDNeeded && ( + + {translate('signerInfoStep.id')} + { + handleSelectFile(files, uploadedIDs, `signer_${COPY_OF_ID}`, setUploadedID); + }} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedIDs, `signer_${COPY_OF_ID}`, setUploadedID); + }} + acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} + value={uploadedIDs} + inputID={`signer_${COPY_OF_ID}`} + setError={setError} + /> + + )} + {isDocumentNeededStatus.isAddressProofNeeded && ( + + {translate('signerInfoStep.proofOf')} + { + handleSelectFile(files, uploadedProofsOfAddress, `signer_${ADDRESS_PROOF}`, setUploadedProofOfAddress); + }} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedProofsOfAddress, `signer_${ADDRESS_PROOF}`, setUploadedProofOfAddress); + }} + acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} + value={uploadedProofsOfAddress} + inputID={`signer_${ADDRESS_PROOF}`} + setError={setError} + /> + + )} + {isDocumentNeededStatus.isProofOfDirecorsNeeded && ( + + {translate('signerInfoStep.proofOfDirectors')} + { + handleSelectFile(files, uploadedProofsOfDirectors, `signer_${PROOF_OF_DIRECTORS}`, setUploadedProofsOfDirectors); + }} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedProofsOfDirectors, `signer_${PROOF_OF_DIRECTORS}`, setUploadedProofsOfDirectors); + }} + acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} + value={uploadedProofsOfDirectors} + inputID={`signer_${PROOF_OF_DIRECTORS}`} + setError={setError} + /> + + )} diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForSignerInfo.ts new file mode 100644 index 000000000000..45563362586a --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForSignerInfo.ts @@ -0,0 +1,22 @@ +import CONST from '@src/CONST'; + +type NeededDocumentsStatusForBeneficialOwner = { + isProofOfDirecorsNeeded: boolean; + isCopyOfIDNeeded: boolean; + isAddressProofNeeded: boolean; + isCodiceFiscaleNeeded: boolean; + isPRDandFSGNeeded: boolean; +}; + +function getNeededDocumentsStatusForSignerInfo(workspaceCurrency: string, accountCountry: string): NeededDocumentsStatusForBeneficialOwner { + console.log(accountCountry, accountCountry === CONST.COUNTRY.CA || accountCountry === CONST.COUNTRY.AU); + return { + isProofOfDirecorsNeeded: accountCountry === CONST.COUNTRY.CA || accountCountry === CONST.COUNTRY.AU, + isCopyOfIDNeeded: workspaceCurrency === CONST.CURRENCY.EUR || accountCountry === CONST.COUNTRY.AU, + isAddressProofNeeded: workspaceCurrency === CONST.CURRENCY.EUR || accountCountry === CONST.COUNTRY.GB || accountCountry === CONST.COUNTRY.AU, + isCodiceFiscaleNeeded: accountCountry === CONST.COUNTRY.IT, + isPRDandFSGNeeded: accountCountry === CONST.COUNTRY.IT, + }; +} + +export default getNeededDocumentsStatusForSignerInfo; From 00ecd67bd05a87290f0b3ba49fc965697e076cc4 Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 13 Feb 2025 14:51:59 +0100 Subject: [PATCH 041/138] missing file uploaders added --- src/languages/en.ts | 2 + src/languages/es.ts | 2 + .../SignerInfo/substeps/UploadDocuments.tsx | 48 ++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index d7a0141d5478..9095e46ce4c3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2485,6 +2485,8 @@ const translations = { occupation: 'Occupation', whatsYourOccupation: "What's your occupation?", proofOfDirectors: 'Proof of directors', + codiceFiscale: 'Codice fiscale', + PRDandSFD: 'PRD and SFD', }, agreementsStep: { agreements: 'Agreements', diff --git a/src/languages/es.ts b/src/languages/es.ts index 99a3e7bb5c02..b821224d9cc8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2511,6 +2511,8 @@ const translations = { occupation: 'Occupation', whatsYourOccupation: "What's your occupation?", proofOfDirectors: 'Proof of directors', + codiceFiscale: 'Codice fiscale', + PRDandSFD: 'PRD and SFD', }, agreementsStep: { agreements: 'Acuerdos', diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx index 23a42c45927c..e897918c2021 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/UploadDocuments.tsx @@ -21,8 +21,8 @@ import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; type UploadDocumentsProps = SubStepProps; -const {SIGNER_ADDRESS_PROOF, SIGNER_PROOF_OF_DIRECTORS, SIGNER_COPY_OF_ID} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const {ADDRESS_PROOF, PROOF_OF_DIRECTORS, COPY_OF_ID} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; +const {SIGNER_ADDRESS_PROOF, SIGNER_PROOF_OF_DIRECTORS, SIGNER_COPY_OF_ID, SIGNER_CODICE_FISCALE, SIGNER_PRD_AND_SFG} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {ADDRESS_PROOF, PROOF_OF_DIRECTORS, COPY_OF_ID, CODICE_FISCALE, PRD_AND_SFG} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; const STEP_FIELDS = [ADDRESS_PROOF, PROOF_OF_DIRECTORS, COPY_OF_ID]; function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { @@ -43,11 +43,15 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { [`signer_${ADDRESS_PROOF}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_ADDRESS_PROOF] ?? reimbursementAccountDraft?.[`signer_${ADDRESS_PROOF}`] ?? [], [`signer_${PROOF_OF_DIRECTORS}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_PROOF_OF_DIRECTORS] ?? reimbursementAccountDraft?.[`signer_${PROOF_OF_DIRECTORS}`] ?? [], + [`signer_${CODICE_FISCALE}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_CODICE_FISCALE] ?? reimbursementAccountDraft?.[`signer_${CODICE_FISCALE}`] ?? [], + [`signer_${PRD_AND_SFG}`]: reimbursementAccount?.achData?.additionalData?.corpay?.[SIGNER_PRD_AND_SFG] ?? reimbursementAccountDraft?.[`signer_${PRD_AND_SFG}`] ?? [], }; const [uploadedIDs, setUploadedID] = useState(defaultValues[`signer_${COPY_OF_ID}`] as FileObject[]); const [uploadedProofsOfAddress, setUploadedProofOfAddress] = useState(defaultValues[`signer_${ADDRESS_PROOF}`] as FileObject[]); const [uploadedProofsOfDirectors, setUploadedProofsOfDirectors] = useState(defaultValues[`signer_${PROOF_OF_DIRECTORS}`] as FileObject[]); + const [uploadedCodiceFiscale, setUploadedCodiceFiscale] = useState(defaultValues[`signer_${CODICE_FISCALE}`] as FileObject[]); + const [uploadedPRDandSFG, setUploadedPRDandSFG] = useState(defaultValues[`signer_${PRD_AND_SFG}`] as FileObject[]); const validate = useCallback((values: FormOnyxValues): FormInputErrors => { return ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); @@ -146,6 +150,46 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) { /> )} + {isDocumentNeededStatus.isCodiceFiscaleNeeded && ( + + {translate('signerInfoStep.codiceFiscale')} + { + handleSelectFile(files, uploadedCodiceFiscale, `signer_${CODICE_FISCALE}`, setUploadedCodiceFiscale); + }} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedCodiceFiscale, `signer_${CODICE_FISCALE}`, setUploadedCodiceFiscale); + }} + acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} + value={uploadedCodiceFiscale} + inputID={`signer_${CODICE_FISCALE}`} + setError={setError} + /> + + )} + {isDocumentNeededStatus.isPRDandFSGNeeded && ( + + {translate('signerInfoStep.PRDandSFD')} + { + handleSelectFile(files, uploadedPRDandSFG, `signer_${PRD_AND_SFG}`, setUploadedPRDandSFG); + }} + onRemove={(fileName) => { + handleRemoveFile(fileName, uploadedPRDandSFG, `signer_${PRD_AND_SFG}`, setUploadedPRDandSFG); + }} + acceptedFileTypes={[...CONST.NON_USD_BANK_ACCOUNT.ALLOWED_FILE_TYPES]} + value={uploadedPRDandSFG} + inputID={`signer_${PRD_AND_SFG}`} + setError={setError} + /> + + )} From b60d7accaefee2cc336f2f12470623f94c782aac Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 13 Feb 2025 14:54:45 +0100 Subject: [PATCH 042/138] confirmation step cleanup --- .../SignerInfo/substeps/Confirmation.tsx | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx index 65d0bbc54d0c..c5223f43731e 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx @@ -3,46 +3,33 @@ import {useOnyx} from 'react-native-onyx'; import ConfirmationStep from '@components/SubStepForms/ConfirmationStep'; import useLocalize from '@hooks/useLocalize'; import type {SubStepProps} from '@hooks/useSubStep/types'; +import getAddressValuesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -import getAddressValuesForSignerInfo from "@pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo"; -type ConfirmationProps = SubStepProps & {isSecondSigner: boolean}; +type ConfirmationProps = SubStepProps; const SINGER_INFO_STEP_KEYS = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const { - SIGNER_FULL_NAME, - SECOND_SIGNER_FULL_NAME, - SIGNER_JOB_TITLE, - SECOND_SIGNER_JOB_TITLE, - SIGNER_DATE_OF_BIRTH, - SECOND_SIGNER_DATE_OF_BIRTH, - SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, - SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, - SIGNER_COPY_OF_ID, - SECOND_SIGNER_COPY_OF_ID, - SIGNER_ADDRESS_PROOF, - SECOND_SIGNER_ADDRESS_PROOF, - OWNS_MORE_THAN_25_PERCENT, -} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {SIGNER_FULL_NAME, SIGNER_JOB_TITLE, SIGNER_DATE_OF_BIRTH, SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SIGNER_COPY_OF_ID, SIGNER_ADDRESS_PROOF, OWNS_MORE_THAN_25_PERCENT} = + INPUT_IDS.ADDITIONAL_DATA.CORPAY; -function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationProps) { +function Confirmation({onNext, onMove, isEditing}: ConfirmationProps) { const {translate} = useLocalize(); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; - const addressPrefix = isSecondSigner ? SECOND_SIGNER_COMPLETE_RESIDENTIAL_ADDRESS : SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; + const addressPrefix = SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; const values = useMemo(() => getSubstepValues(SINGER_INFO_STEP_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const addressValues = useMemo(() => getAddressValuesForSignerInfo(addressPrefix, reimbursementAccountDraft), [addressPrefix, reimbursementAccountDraft]); - const IDs = values[isSecondSigner ? SECOND_SIGNER_COPY_OF_ID : SIGNER_COPY_OF_ID]; - const proofs = values[isSecondSigner ? SECOND_SIGNER_ADDRESS_PROOF : SIGNER_ADDRESS_PROOF]; + const IDs = values[SIGNER_COPY_OF_ID]; + const proofs = values[SIGNER_ADDRESS_PROOF]; const summaryItems = [ { - title: values[isSecondSigner ? SECOND_SIGNER_JOB_TITLE : SIGNER_JOB_TITLE], + title: values[SIGNER_JOB_TITLE], description: translate('signerInfoStep.jobTitle'), shouldShowRightIcon: true, onPress: () => { @@ -69,7 +56,7 @@ function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationP if (!isUserOwner) { summaryItems.unshift({ - title: `${values[isSecondSigner ? SECOND_SIGNER_FULL_NAME : SIGNER_FULL_NAME]}`, + title: `${values[SIGNER_FULL_NAME]}`, description: translate('signerInfoStep.legalName'), shouldShowRightIcon: true, onPress: () => { @@ -78,7 +65,7 @@ function Confirmation({onNext, onMove, isEditing, isSecondSigner}: ConfirmationP }); summaryItems.splice(2, 0, { - title: values[isSecondSigner ? SECOND_SIGNER_DATE_OF_BIRTH : SIGNER_DATE_OF_BIRTH], + title: values[SIGNER_DATE_OF_BIRTH], description: translate('common.dob'), shouldShowRightIcon: true, onPress: () => { From 5b29968d1accfd6ccb30173760685a2114d05ac4 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 14 Feb 2025 12:02:49 +0100 Subject: [PATCH 043/138] confirmation page addjusted to the new payload shape --- .../SignerInfo/substeps/Confirmation.tsx | 98 ++++++++++++++----- .../utils/getAddressValuesForSignerInfo.ts | 32 ------ .../NonUSD/utils/getValuesForSignerInfo.ts | 76 ++++++++++++++ 3 files changed, 148 insertions(+), 58 deletions(-) delete mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/getValuesForSignerInfo.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx index c5223f43731e..f3daee021e2d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Confirmation.tsx @@ -3,16 +3,14 @@ import {useOnyx} from 'react-native-onyx'; import ConfirmationStep from '@components/SubStepForms/ConfirmationStep'; import useLocalize from '@hooks/useLocalize'; import type {SubStepProps} from '@hooks/useSubStep/types'; -import getAddressValuesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo'; -import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; +import getNeededDocumentsStatusForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForSignerInfo'; +import getValuesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getValuesForSignerInfo'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; type ConfirmationProps = SubStepProps; -const SINGER_INFO_STEP_KEYS = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const {SIGNER_FULL_NAME, SIGNER_JOB_TITLE, SIGNER_DATE_OF_BIRTH, SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, SIGNER_COPY_OF_ID, SIGNER_ADDRESS_PROOF, OWNS_MORE_THAN_25_PERCENT} = - INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {OWNS_MORE_THAN_25_PERCENT} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; function Confirmation({onNext, onMove, isEditing}: ConfirmationProps) { const {translate} = useLocalize(); @@ -20,16 +18,17 @@ function Confirmation({onNext, onMove, isEditing}: ConfirmationProps) { const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; - const addressPrefix = SIGNER_COMPLETE_RESIDENTIAL_ADDRESS; - const values = useMemo(() => getSubstepValues(SINGER_INFO_STEP_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); - const addressValues = useMemo(() => getAddressValuesForSignerInfo(addressPrefix, reimbursementAccountDraft), [addressPrefix, reimbursementAccountDraft]); + const values = useMemo(() => getValuesForSignerInfo(['currentUser'], reimbursementAccountDraft), []); - const IDs = values[SIGNER_COPY_OF_ID]; - const proofs = values[SIGNER_ADDRESS_PROOF]; + const policyID = reimbursementAccount?.achData?.policyID; + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const currency = policy?.outputCurrency ?? ''; + const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + const isDocumentNeededStatus = getNeededDocumentsStatusForSignerInfo(currency, countryStepCountryValue); const summaryItems = [ { - title: values[SIGNER_JOB_TITLE], + title: values.jobTitle, description: translate('signerInfoStep.jobTitle'), shouldShowRightIcon: true, onPress: () => { @@ -37,26 +36,73 @@ function Confirmation({onNext, onMove, isEditing}: ConfirmationProps) { }, }, { - title: IDs ? IDs.map((id) => id.name).join(', ') : '', - description: translate('signerInfoStep.id'), + title: values.jobTitle, + description: translate('signerInfoStep.occupation'), shouldShowRightIcon: true, onPress: () => { - onMove(4); + onMove(2); }, }, - { - title: proofs ? proofs.map((proof) => proof.name).join(', ') : '', + ]; + + if (isDocumentNeededStatus.isCopyOfIDNeeded && values.copyOfId.length > 0) { + summaryItems.push({ + title: values.copyOfId.map((id) => id.name).join(', '), + description: translate('signerInfoStep.id'), + shouldShowRightIcon: true, + onPress: () => { + onMove(5); + }, + }); + } + + if (isDocumentNeededStatus.isAddressProofNeeded && values.addressProof.length > 0) { + summaryItems.push({ + title: values.addressProof.map((proof) => proof.name).join(', '), description: translate('signerInfoStep.proofOf'), shouldShowRightIcon: true, onPress: () => { - onMove(4); + onMove(5); }, - }, - ]; + }); + } + + if (isDocumentNeededStatus.isProofOfDirecorsNeeded && values.proofOfDirectors.length > 0) { + summaryItems.push({ + title: values.proofOfDirectors.map((proof) => proof.name).join(', '), + description: translate('signerInfoStep.proofOfDirectors'), + shouldShowRightIcon: true, + onPress: () => { + onMove(5); + }, + }); + } + + if (isDocumentNeededStatus.isCodiceFiscaleNeeded && values.codiceFisclaleTaxID.length > 0) { + summaryItems.push({ + title: values.proofOfDirectors.map((proof) => proof.name).join(', '), + description: translate('signerInfoStep.codiceFiscale'), + shouldShowRightIcon: true, + onPress: () => { + onMove(5); + }, + }); + } + + if (isDocumentNeededStatus.isPRDandFSGNeeded && values.PRDandFSG.length > 0) { + summaryItems.push({ + title: values.proofOfDirectors.map((proof) => proof.name).join(', '), + description: translate('signerInfoStep.PRDandSFD'), + shouldShowRightIcon: true, + onPress: () => { + onMove(5); + }, + }); + } if (!isUserOwner) { summaryItems.unshift({ - title: `${values[SIGNER_FULL_NAME]}`, + title: values.fullName, description: translate('signerInfoStep.legalName'), shouldShowRightIcon: true, onPress: () => { @@ -64,21 +110,21 @@ function Confirmation({onNext, onMove, isEditing}: ConfirmationProps) { }, }); - summaryItems.splice(2, 0, { - title: values[SIGNER_DATE_OF_BIRTH], + summaryItems.splice(3, 0, { + title: values.dateOfBirth, description: translate('common.dob'), shouldShowRightIcon: true, onPress: () => { - onMove(2); + onMove(3); }, }); - summaryItems.splice(3, 0, { - title: `${addressValues.street}, ${addressValues.city}, ${addressValues.state}, ${addressValues.zipCode}`, + summaryItems.splice(4, 0, { + title: `${values.street}, ${values.city}, ${values.state}, ${values.zipCode}`, description: translate('ownershipInfoStep.address'), shouldShowRightIcon: true, onPress: () => { - onMove(3); + onMove(4); }, }); } diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts deleted file mode 100644 index aaf5753c02bf..000000000000 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getAddressValuesForSignerInfo.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type {OnyxEntry} from 'react-native-onyx'; -import CONST from '@src/CONST'; -import type {ReimbursementAccountForm} from '@src/types/form'; - -type SignerInfoAddressValues = { - street: string; - city: string; - state: string; - zipCode: string; -}; - -const {STREET, CITY, STATE, ZIP_CODE} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; - -function getAddressValuesForSignerInfo(prefix: string, reimbursementAccountDraft: OnyxEntry): SignerInfoAddressValues { - if (!reimbursementAccountDraft) { - return { - street: '', - city: '', - state: '', - zipCode: '', - }; - } - - return { - street: reimbursementAccountDraft[STREET], - city: reimbursementAccountDraft[CITY], - state: reimbursementAccountDraft[STATE], - zipCode: reimbursementAccountDraft[ZIP_CODE], - }; -} - -export default getAddressValuesForSignerInfo; diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForSignerInfo.ts new file mode 100644 index 000000000000..46919860033c --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForSignerInfo.ts @@ -0,0 +1,76 @@ +import type {OnyxEntry} from 'react-native-onyx'; +import type {ReimbursementAccountForm} from '@src/types/form'; +import CONST from '@src/CONST'; +import type {FileObject} from '@components/AttachmentModal'; + +type SignerInfoDirector = { + fullName: string; + jobTitle: string; + occupation: string; +}; + +type SignerInfoValues = { + dateOfBirth: string; + fullName: string; + jobTitle: string; + city: string; + state: string; + street: string; + zipCode: string; + directors: SignerInfoDirector[]; + proofOfDirectors: FileObject[]; + copyOfId: FileObject[]; + addressProof: FileObject[]; + codiceFisclaleTaxID: FileObject[]; + PRDandFSG: FileObject[]; +}; + +function getValuesForSignerInfo(directorIDs: string[], reimbursementAccountDraft: OnyxEntry): SignerInfoValues { + if (!reimbursementAccountDraft) { + return { + dateOfBirth: '', + fullName: '', + jobTitle: '', + city: '', + state: '', + street: '', + zipCode: '', + directors: [], + proofOfDirectors: [], + copyOfId: [], + addressProof: [], + codiceFisclaleTaxID: [], + PRDandFSG: [], + }; + } + + const directorsPrefix = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA.PREFIX; + const signerPrefix = 'signer'; + const signerInfoKeys = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; + + return { + dateOfBirth: reimbursementAccountDraft[signerInfoKeys.DATE_OF_BIRTH] ?? '', + fullName: reimbursementAccountDraft[signerInfoKeys.FULL_NAME] ?? '', + jobTitle: reimbursementAccountDraft[signerInfoKeys.JOB_TITLE] ?? '', + city: reimbursementAccountDraft[signerInfoKeys.CITY] ?? '', + state: reimbursementAccountDraft[signerInfoKeys.STATE] ?? '', + street: reimbursementAccountDraft[signerInfoKeys.STREET] ?? '', + zipCode: reimbursementAccountDraft[signerInfoKeys.ZIP_CODE] ?? '', + directors: directorIDs.map((directorID) => { + const directorKey = `${directorsPrefix}_${directorID}`; + + return { + fullName: reimbursementAccountDraft[`${directorKey}_${signerInfoKeys.DIRECTOR_FULL_NAME}`] ?? '', + jobTitle: reimbursementAccountDraft[`${directorKey}_${signerInfoKeys.DIRECTOR_JOB_TITLE}`] ?? '', + occupation: reimbursementAccountDraft[`${directorKey}_${signerInfoKeys.DIRECTOR_OCCUPATION}`] ?? '', + } as SignerInfoDirector; + }), + proofOfDirectors: reimbursementAccountDraft[`${signerPrefix}_${signerInfoKeys.PROOF_OF_DIRECTORS}`] ?? [], + copyOfId: reimbursementAccountDraft[`${signerPrefix}_${signerInfoKeys.COPY_OF_ID}`] ?? [], + addressProof: reimbursementAccountDraft[`${signerPrefix}_${signerInfoKeys.ADDRESS_PROOF}`] ?? [], + codiceFisclaleTaxID: reimbursementAccountDraft[`${signerPrefix}_${signerInfoKeys.CODICE_FISCALE}`] ?? [], + PRDandFSG: reimbursementAccountDraft[`${signerPrefix}_${signerInfoKeys.PRD_AND_SFG}`] ?? [], + } as SignerInfoValues; +} + +export default getValuesForSignerInfo; From 43010870408acb21010920a58d17ca4851a88eba Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 18 Feb 2025 09:56:15 +0100 Subject: [PATCH 044/138] director details flow added [WIP] --- src/CONST.ts | 6 +- .../BeneficialOwnerInfo.tsx | 6 +- .../NonUSD/SignerInfo/index.tsx | 124 ++++++++++++------ 3 files changed, 89 insertions(+), 47 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index c6963ed02564..9fd588908b5e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -665,6 +665,7 @@ const CONST = { FILE_LIMIT: 10, TOTAL_FILES_SIZE_LIMIT: 5242880, PURPOSE_OF_TRANSACTION_ID: 'Intercompany_Payment', + CURRENT_USER_KEY: 'currentUser', STEP: { COUNTRY: 'CountryStep', BANK_INFO: 'BankInfoStep', @@ -711,7 +712,6 @@ const CONST = { FULL_NAME: 'fullName', RESIDENTIAL_ADDRESS: 'residentialAddress', }, - CURRENT_USER_KEY: 'currentUser', }, STEP_NAMES: ['1', '2', '3', '4', '5', '6'], STEP_HEADER_HEIGHT: 40, @@ -720,7 +720,9 @@ const CONST = { IS_DIRECTOR: 1, ENTER_EMAIL: 2, SIGNER_DETAILS_FORM: 3, - HANG_TIGHT: 4, + DIRECTOR_DETAILS_FORM: 4, + HANG_TIGHT: 5, + IS_ANYONE_ELSE_DIRECTOR: 6, }, SIGNER_INFO_DATA: { PREFIX: 'director', diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx index 6c68afb01604..c8e74eef0d47 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx @@ -51,7 +51,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const [ownerKeys, setOwnerKeys] = useState([]); - const [ownerBeingModifiedID, setOwnerBeingModifiedID] = useState(CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.CURRENT_USER_KEY); + const [ownerBeingModifiedID, setOwnerBeingModifiedID] = useState(CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY); const [isEditingCreatedOwner, setIsEditingCreatedOwner] = useState(false); const [isUserEnteringHisOwnData, setIsUserEnteringHisOwnData] = useState(false); const [isUserOwner, setIsUserOwner] = useState(false); @@ -199,7 +199,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP setIsUserOwner(value); setIsUserEnteringHisOwnData(value); - setOwnerKeys((currentOwnersKeys) => currentOwnersKeys.filter((key) => key !== CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.CURRENT_USER_KEY)); + setOwnerKeys((currentOwnersKeys) => currentOwnersKeys.filter((key) => key !== CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY)); // User is an owner but there are 4 other owners already added, so we remove last one if (value && ownerKeys.length === 4) { @@ -235,7 +235,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP // User is an owner and no one else is an owner if (isUserOwner && !value) { - setOwnerKeys([CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.CURRENT_USER_KEY]); + setOwnerKeys([CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY]); setCurrentSubStep(SUBSTEP.BENEFICIAL_OWNERS_LIST); return; } diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 1aa078208646..93d2a272db06 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -22,7 +22,7 @@ import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import Occupation from './substeps/Occupation'; import UploadDocuments from './substeps/UploadDocuments'; -import {FileObject} from '@components/AttachmentModal'; +import {Str} from 'expensify-common'; type SignerInfoProps = { /** Handles back button press */ @@ -33,6 +33,7 @@ type SignerInfoProps = { }; type SignerDetailsFormProps = SubStepProps & {isSecondSigner: boolean; directorID: string}; +type DirectorDetailsFormProps = SubStepProps & {isSecondSigner: boolean; directorID: string}; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment const SUBSTEP: Record = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SUBSTEP; @@ -41,25 +42,11 @@ const {OWNS_MORE_THAN_25_PERCENT, COMPANY_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORP const fullBodyContent: Array> = [Name, JobTitle, Occupation, DateOfBirth, Address, UploadDocuments, Confirmation]; const userIsOwnerBodyContent: Array> = [JobTitle, UploadDocuments, Confirmation]; const userIsOwnerCadBodyContent: Array> = [UploadDocuments, Confirmation]; - -const INPUT_KEYS = { - SIGNER_FULL_NAME: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_FULL_NAME, - SIGNER_DATE_OF_BIRTH: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_DATE_OF_BIRTH, - SIGNER_JOB_TITLE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_JOB_TITLE, - SIGNER_EMAIL: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_EMAIL, - SIGNER_COMPLETE_RESIDENTIAL_ADDRESS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS, - SIGNER_COPY_OF_ID: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COPY_OF_ID, - SIGNER_ADDRESS_PROOF: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_ADDRESS_PROOF, - // SIGNER_CODICE_PROOF: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_CODICE_PROOF, - SIGNER_PDS_AND_FSG: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PRD_AND_SFG, - SIGNER_PROOF_OF_DIRECTORS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_PROOF_OF_DIRECTORS, -}; +const directorDetailsBodyContent: Array> = [Name, JobTitle, Occupation]; function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const {translate} = useLocalize(); - // TODO: change it to be state value (might change if there is more directors) - const directorID = 'currentUser'; const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const [account] = useOnyx(ONYXKEYS.ACCOUNT); @@ -70,10 +57,11 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; const companyName = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? ''; - const onyxValues = useMemo(() => getSubstepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; const [currentSubStep, setCurrentSubStep] = useState(SUBSTEP.IS_DIRECTOR); const [isUserDirector, setIsUserDirector] = useState(false); + const [isAnyoneElseDirector, setIsAnyoneElseDirector] = useState(false); + const [directorBeingModifiedID, setDirectorBeingModifiedID] = useState(CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY); const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; @@ -86,8 +74,8 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { BankAccounts.getCorpayOnboardingFields(country); }, [country]); - const submit = useCallback(() => { - const {signerDetails, signerFiles} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorID); + const submitSignerDetailsForm = useCallback(() => { + const {signerDetails, signerFiles} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorBeingModifiedID); if (currency === CONST.CURRENCY.AUD) { setCurrentSubStep(SUBSTEP.ENTER_EMAIL); @@ -97,30 +85,15 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { inputs: JSON.stringify(signerDetails), ...signerFiles, bankAccountID, - directorIDs: `${directorID}`, + directorIDs: `${directorBeingModifiedID}`, }); onSubmit(); } - }, [account?.primaryLogin, bankAccountID, currency, onSubmit, reimbursementAccountDraft]); - - const handleNextSubStep = useCallback( - (value: boolean) => { - if (currentSubStep !== SUBSTEP.IS_DIRECTOR) { - return; - } - - // user is director - if (value) { - setIsUserDirector(value); - setCurrentSubStep(SUBSTEP.SIGNER_DETAILS_FORM); - return; - } + }, [account?.primaryLogin, bankAccountID, currency, directorBeingModifiedID, onSubmit, reimbursementAccountDraft]); - setIsUserDirector(value); - setCurrentSubStep(SUBSTEP.ENTER_EMAIL); - }, - [currentSubStep], - ); + const submitDirectorDetailsForm = useCallback(() => { + // TODO: to be implemented + }, []); const bodyContent = useMemo(() => { if (isUserOwner) { @@ -142,7 +115,51 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { prevScreen, moveTo, goToTheLastStep, - } = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); + } = useSubStep({bodyContent, startFrom: 0, onFinished: submitSignerDetailsForm}); + + const { + componentToRender: DirectorDetailsForm, + isEditing: directorsBeingEditing, + screenIndex: directorsScreenIndex, + nextScreen: directorsNextScreen, + prevScreen: directorsPrevScreen, + moveTo: directorsMoveTo, + resetScreenIndex: directorsResetScreenIndex, + } = useSubStep({bodyContent: directorDetailsBodyContent, startFrom: 0, onFinished: submitDirectorDetailsForm}); + + const prepareDirectorDetailsForm = useCallback(() => { + const directorID = Str.guid(); + setDirectorBeingModifiedID(directorID); + directorsResetScreenIndex(); + setCurrentSubStep(SUBSTEP.DIRECTOR_DETAILS_FORM); + }, [directorsResetScreenIndex]); + + const handleNextSubStep = useCallback( + (value: boolean) => { + if (currentSubStep === SUBSTEP.IS_DIRECTOR) { + // user is director so we gather their data + if (value) { + setIsUserDirector(value); + setCurrentSubStep(SUBSTEP.SIGNER_DETAILS_FORM); + return; + } + + setIsUserDirector(value); + setCurrentSubStep(SUBSTEP.ENTER_EMAIL); + return; + } + + if (currentSubStep === SUBSTEP.IS_ANYONE_ELSE_DIRECTOR) { + setIsAnyoneElseDirector(value); + prepareDirectorDetailsForm(); + return; + } + + setIsUserDirector(value); + setCurrentSubStep(SUBSTEP.ENTER_EMAIL); + }, + [currentSubStep, prepareDirectorDetailsForm], + ); const handleBackButtonPress = useCallback(() => { if (isEditing) { @@ -158,12 +175,16 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { prevScreen(); } else if (currentSubStep === SUBSTEP.SIGNER_DETAILS_FORM && screenIndex === 0) { setCurrentSubStep(SUBSTEP.IS_DIRECTOR); + } else if (currentSubStep === SUBSTEP.DIRECTOR_DETAILS_FORM && directorsScreenIndex > 0) { + directorsPrevScreen(); + } else if (currentSubStep === SUBSTEP.DIRECTOR_DETAILS_FORM && directorsScreenIndex === 0) { + setCurrentSubStep(SUBSTEP.SIGNER_DETAILS_FORM); } else if (currentSubStep === SUBSTEP.HANG_TIGHT) { Navigation.goBack(); } else { setCurrentSubStep((subStep) => subStep - 1); } - }, [currentSubStep, goToTheLastStep, isEditing, isUserDirector, onBackButtonPress, prevScreen, screenIndex]); + }, [currentSubStep, directorsPrevScreen, directorsScreenIndex, goToTheLastStep, isEditing, isUserDirector, onBackButtonPress, prevScreen, screenIndex]); const handleEmailSubmit = useCallback(() => { // TODO: the message to the email provided in the previous step should be sent @@ -187,13 +208,32 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { /> )} + {currentSubStep === SUBSTEP.IS_ANYONE_ELSE_DIRECTOR && ( + + )} + {currentSubStep === SUBSTEP.SIGNER_DETAILS_FORM && ( + )} + + {currentSubStep === SUBSTEP.DIRECTOR_DETAILS_FORM && ( + )} From d2ec22be5a957c2adc692f2a1d5eaada5a3dc9fc Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 18 Feb 2025 09:58:06 +0100 Subject: [PATCH 045/138] prettier changes --- src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index 93d2a272db06..b545e85166c4 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -1,3 +1,4 @@ +import {Str} from 'expensify-common'; import type {ComponentType} from 'react'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; @@ -8,7 +9,6 @@ import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; import Navigation from '@navigation/Navigation'; import getSignerDetailsAndSignerFilesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo'; -import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -22,7 +22,6 @@ import JobTitle from './substeps/JobTitle'; import Name from './substeps/Name'; import Occupation from './substeps/Occupation'; import UploadDocuments from './substeps/UploadDocuments'; -import {Str} from 'expensify-common'; type SignerInfoProps = { /** Handles back button press */ From 9d5cb3d238120cbe00ce5cdff807b92865bdf961 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 18 Feb 2025 13:19:41 +0100 Subject: [PATCH 046/138] collecting additional directors details substeps --- .../NonUSD/SignerInfo/index.tsx | 18 ++++++++---------- .../NonUSD/SignerInfo/substeps/DateOfBirth.tsx | 8 ++++---- .../NonUSD/SignerInfo/substeps/JobTitle.tsx | 14 ++++++++------ .../NonUSD/SignerInfo/substeps/Name.tsx | 16 +++++++++------- .../NonUSD/SignerInfo/substeps/Occupation.tsx | 6 +++--- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index b545e85166c4..c3641013f0cc 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -31,8 +31,8 @@ type SignerInfoProps = { onSubmit: () => void; }; -type SignerDetailsFormProps = SubStepProps & {isSecondSigner: boolean; directorID: string}; -type DirectorDetailsFormProps = SubStepProps & {isSecondSigner: boolean; directorID: string}; +type SignerDetailsFormProps = SubStepProps & {directorID?: string}; +type DirectorDetailsFormProps = SubStepProps & {directorID?: string}; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment const SUBSTEP: Record = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SUBSTEP; @@ -52,8 +52,6 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const policyID = reimbursementAccount?.achData?.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const currency = policy?.outputCurrency ?? ''; - // TODO consider if this is needed - const isSecondSigner = false; const isUserOwner = reimbursementAccount?.achData?.additionalData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false; const companyName = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? ''; const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? 0; @@ -74,6 +72,12 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { }, [country]); const submitSignerDetailsForm = useCallback(() => { + setCurrentSubStep(SUBSTEP.IS_ANYONE_ELSE_DIRECTOR); + }, []); + + const submitDirectorDetailsForm = useCallback(() => { + // TODO: handle multiple directors + const {signerDetails, signerFiles} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorBeingModifiedID); if (currency === CONST.CURRENCY.AUD) { @@ -90,10 +94,6 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { } }, [account?.primaryLogin, bankAccountID, currency, directorBeingModifiedID, onSubmit, reimbursementAccountDraft]); - const submitDirectorDetailsForm = useCallback(() => { - // TODO: to be implemented - }, []); - const bodyContent = useMemo(() => { if (isUserOwner) { if (currency === CONST.CURRENCY.CAD) { @@ -221,7 +221,6 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { isEditing={isEditing} onNext={nextScreen} onMove={moveTo} - isSecondSigner={isSecondSigner} directorID={directorBeingModifiedID} /> )} @@ -231,7 +230,6 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { isEditing={directorsBeingEditing} onNext={directorsNextScreen} onMove={directorsMoveTo} - isSecondSigner={isSecondSigner} directorID={directorBeingModifiedID} /> )} diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/DateOfBirth.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/DateOfBirth.tsx index ba83edd08d97..ff3d28e9136a 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/DateOfBirth.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/DateOfBirth.tsx @@ -9,15 +9,15 @@ import WhyLink from '@pages/ReimbursementAccount/NonUSD/WhyLink'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -type DateOfBirthProps = SubStepProps & {isSecondSigner: boolean}; +type DateOfBirthProps = SubStepProps; -const {SIGNER_DATE_OF_BIRTH, SECOND_SIGNER_DATE_OF_BIRTH} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {SIGNER_DATE_OF_BIRTH} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -function DateOfBirth({onNext, onMove, isEditing, isSecondSigner}: DateOfBirthProps) { +function DateOfBirth({onNext, onMove, isEditing}: DateOfBirthProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const inputID = isSecondSigner ? SECOND_SIGNER_DATE_OF_BIRTH : SIGNER_DATE_OF_BIRTH; + const inputID = SIGNER_DATE_OF_BIRTH; const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const defaultValue = reimbursementAccount?.achData?.additionalData?.corpay?.[inputID] ?? reimbursementAccountDraft?.[inputID] ?? ''; diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/JobTitle.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/JobTitle.tsx index 30da9f4f54ec..2573f0d63708 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/JobTitle.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/JobTitle.tsx @@ -10,17 +10,19 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -type JobTitleProps = SubStepProps & {isSecondSigner: boolean}; +type JobTitleProps = SubStepProps & {directorID?: string}; -const {SIGNER_JOB_TITLE, SECOND_SIGNER_JOB_TITLE} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {SIGNER_JOB_TITLE} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -function JobTitle({onNext, onMove, isEditing, isSecondSigner}: JobTitleProps) { +function JobTitle({onNext, onMove, isEditing, directorID}: JobTitleProps) { const {translate} = useLocalize(); - const inputID = isSecondSigner ? SECOND_SIGNER_JOB_TITLE : SIGNER_JOB_TITLE; - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); - const defaultValue = reimbursementAccount?.achData?.additionalData?.corpay?.[inputID] ?? reimbursementAccountDraft?.[inputID] ?? ''; + const inputID = + directorID && directorID !== CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY + ? `${CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA.PREFIX}_${directorID}_${CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA.DIRECTOR_JOB_TITLE}` + : SIGNER_JOB_TITLE; + const defaultValue = String(reimbursementAccountDraft?.[inputID] ?? ''); const validate = useCallback( (values: FormOnyxValues): FormInputErrors => { diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Name.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Name.tsx index 97d3c1f8b27f..594e19fe5116 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Name.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Name.tsx @@ -10,23 +10,25 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -type NameProps = SubStepProps & {isSecondSigner: boolean}; +type NameProps = SubStepProps & {directorID?: string}; -const {SIGNER_FULL_NAME, SECOND_SIGNER_FULL_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const {SIGNER_FULL_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -function Name({onNext, onMove, isEditing, isSecondSigner}: NameProps) { +function Name({onNext, onMove, isEditing, directorID}: NameProps) { const {translate} = useLocalize(); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); - const inputID = isSecondSigner ? SECOND_SIGNER_FULL_NAME : SIGNER_FULL_NAME; - const defaultValue = reimbursementAccount?.achData?.additionalData?.corpay?.[inputID] ?? reimbursementAccountDraft?.[inputID] ?? ''; + const inputID = + directorID && directorID !== CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY + ? `${CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA.PREFIX}_${directorID}_${CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA.DIRECTOR_FULL_NAME}` + : SIGNER_FULL_NAME; + const defaultValue = String(reimbursementAccountDraft?.[inputID] ?? ''); const validate = useCallback( (values: FormOnyxValues): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [inputID]); - if (values[inputID] && !ValidationUtils.isValidLegalName(values[inputID])) { + if (values[inputID] && !ValidationUtils.isValidLegalName(String(values[inputID]))) { errors[inputID] = translate('bankAccount.error.fullName'); } diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx index e6d7ba3646a9..07e37a2030df 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/substeps/Occupation.tsx @@ -9,7 +9,7 @@ import * as ValidationUtils from '@libs/ValidationUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -type OccupationProps = SubStepProps & {directorID: string}; +type OccupationProps = SubStepProps & {directorID?: string}; const {PREFIX, DIRECTOR_OCCUPATION} = CONST.NON_USD_BANK_ACCOUNT.SIGNER_INFO_STEP.SIGNER_INFO_DATA; @@ -18,13 +18,13 @@ function Occupation({onNext, onMove, isEditing, directorID}: OccupationProps) { const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const inputID = `${PREFIX}_${directorID}_${DIRECTOR_OCCUPATION}`; - const defaultValue = reimbursementAccountDraft?.[inputID] ?? ''; + const defaultValue = String(reimbursementAccountDraft?.[inputID] ?? ''); const validate = useCallback( (values: FormOnyxValues): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [inputID]); - if (values[inputID] && !ValidationUtils.isValidLegalName(values[inputID])) { + if (values[inputID] && !ValidationUtils.isValidLegalName(String(values[inputID]))) { errors[inputID] = translate('bankAccount.error.fullName'); } From 387f52ac4a0e9ceca3a8f7242b26a61082897056 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 18 Feb 2025 14:23:52 +0100 Subject: [PATCH 047/138] directors details substeps cleanup --- .../NonUSD/SignerInfo/index.tsx | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx index c3641013f0cc..c4b7c86b219a 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/index.tsx @@ -60,22 +60,18 @@ function SignerInfo({onBackButtonPress, onSubmit}: SignerInfoProps) { const [isAnyoneElseDirector, setIsAnyoneElseDirector] = useState(false); const [directorBeingModifiedID, setDirectorBeingModifiedID] = useState(CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY); - const country = reimbursementAccount?.achData?.additionalData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; - - useEffect(() => { - if (!country) { - return; - } - - // eslint-disable-next-line @typescript-eslint/no-unsafe-call - BankAccounts.getCorpayOnboardingFields(country); - }, [country]); + const submitSignerDetailsForm = () => { + setCurrentSubStep(SUBSTEP.IS_ANYONE_ELSE_DIRECTOR); + }; - const submitSignerDetailsForm = useCallback(() => { + const submitDirectorDetailsForm = () => { + // eslint-disable-next-line @typescript-eslint/no-use-before-define + prepareDirectorDetailsForm(); + setIsAnyoneElseDirector(false); setCurrentSubStep(SUBSTEP.IS_ANYONE_ELSE_DIRECTOR); - }, []); + }; - const submitDirectorDetailsForm = useCallback(() => { + const submit = useCallback(() => { // TODO: handle multiple directors const {signerDetails, signerFiles} = getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft, account?.primaryLogin ?? '', directorBeingModifiedID); From 47ee7d6725adc787688cd8ed041281948c84d388 Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 20 Feb 2025 14:31:49 +0100 Subject: [PATCH 048/138] enter email component fixed --- .../ReimbursementAccount/NonUSD/SignerInfo/EnterEmail.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/EnterEmail.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/EnterEmail.tsx index 11c778bcd5b8..0b72a1e992ab 100644 --- a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/EnterEmail.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/EnterEmail.tsx @@ -36,11 +36,11 @@ function EnterEmail({onSubmit, isUserDirector}: EnterEmailProps) { const validate = useCallback( (values: FormOnyxValues): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, shouldGatherBothEmails ? [SIGNER_EMAIL, SECOND_SIGNER_EMAIL] : [SIGNER_EMAIL]); - if (values[SIGNER_EMAIL] && !Str.isValidEmail(values[SIGNER_EMAIL])) { + if (values[SIGNER_EMAIL] && !Str.isValidEmail(String(values[SIGNER_EMAIL]))) { errors[SIGNER_EMAIL] = translate('bankAccount.error.email'); } - if (shouldGatherBothEmails && values[SECOND_SIGNER_EMAIL] && !Str.isValidEmail(values[SECOND_SIGNER_EMAIL])) { + if (shouldGatherBothEmails && values[SECOND_SIGNER_EMAIL] && !Str.isValidEmail(String(values[SECOND_SIGNER_EMAIL]))) { errors[SECOND_SIGNER_EMAIL] = translate('bankAccount.error.email'); } From de3d4b254f400e802f8e92d4582ee8184642b4cb Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 20 Feb 2025 14:32:07 +0100 Subject: [PATCH 049/138] missing second signer corpay field added --- src/types/form/ReimbursementAccountForm.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/types/form/ReimbursementAccountForm.ts b/src/types/form/ReimbursementAccountForm.ts index e405931941b3..bd4a9925cb81 100644 --- a/src/types/form/ReimbursementAccountForm.ts +++ b/src/types/form/ReimbursementAccountForm.ts @@ -104,6 +104,7 @@ const INPUT_IDS = { SIGNER_COPY_OF_ID: 'copyOfID', SIGNER_CODICE_FISCALE: 'codiceFiscaleTaxID', SIGNER_PRD_AND_SFG: 'PRDAndFSG', + SECOND_SIGNER_EMAIL: 'secondSignerEmail', PROVIDE_TRUTHFUL_INFORMATION: 'provideTruthfulInformation', AGREE_TO_TERMS_AND_CONDITIONS: 'agreeToTermsAndConditions', CONSENT_TO_PRIVACY_NOTICE: 'consentToPrivacyNotice', @@ -305,6 +306,9 @@ type NonUSDReimbursementAccountAdditionalProps = { /** Signer email */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_EMAIL]: string; + /** Second signer email */ + [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SECOND_SIGNER_EMAIL]: string; + /** Signer complete residential address */ [INPUT_IDS.ADDITIONAL_DATA.CORPAY.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS]: string; From eb2d71cd0e2b0ddfc49cc03974a06e7bc6787b49 Mon Sep 17 00:00:00 2001 From: burczu Date: Thu, 20 Feb 2025 14:32:38 +0100 Subject: [PATCH 050/138] multiple directors list confirmation page added (WIP) --- src/CONST.ts | 1 + .../NonUSD/SignerInfo/DirectorsList.tsx | 106 ++++++++++++++++++ .../NonUSD/SignerInfo/index.tsx | 35 +++++- .../NonUSD/utils/getValuesForSignerInfo.ts | 6 +- 4 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/SignerInfo/DirectorsList.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 82aee30eb279..94a9ea78ca20 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -723,6 +723,7 @@ const CONST = { DIRECTOR_DETAILS_FORM: 4, HANG_TIGHT: 5, IS_ANYONE_ELSE_DIRECTOR: 6, + DIRECTORS_LIST: 7, }, SIGNER_INFO_DATA: { PREFIX: 'director', diff --git a/src/pages/ReimbursementAccount/NonUSD/SignerInfo/DirectorsList.tsx b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/DirectorsList.tsx new file mode 100644 index 000000000000..3367c40cfe76 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/SignerInfo/DirectorsList.tsx @@ -0,0 +1,106 @@ +import React from 'react'; +import {View} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; +import Button from '@components/Button'; +import DotIndicatorMessage from '@components/DotIndicatorMessage'; +import {FallbackAvatar} from '@components/Icon/Expensicons'; +import MenuItem from '@components/MenuItem'; +import SafeAreaConsumer from '@components/SafeAreaConsumer'; +import ScrollView from '@components/ScrollView'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {getLatestErrorMessage} from '@libs/ErrorUtils'; +import getValuesForSignerInfo from '@pages/ReimbursementAccount/NonUSD/utils/getValuesForSignerInfo'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; + +type DirectorsListProps = { + /** Method called when user confirms data */ + onConfirm: () => void; + + /** Method called when user presses on one of owners to edit its data */ + onEdit: (value: string) => void; + + /** List of owner keys */ + directorKeys: string[]; +}; + +function DirectorsList({directorKeys, onConfirm, onEdit}: DirectorsListProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {isOffline} = useNetwork(); + + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const error = getLatestErrorMessage(reimbursementAccount); + + const directorData = getValuesForSignerInfo(directorKeys, reimbursementAccountDraft); + const directors = + reimbursementAccountDraft && + directorData.directors.map((director) => { + return ( + { + onEdit(director.directorKey); + }} + iconWidth={40} + iconHeight={40} + interactive + shouldShowRightIcon + displayInDefaultIconColor + /> + ); + }); + + const areThereDirectors = directors !== undefined && directors?.length > 0; + + return ( + + {({safeAreaPaddingBottomStyle}) => ( + + {translate('beneficialOwnerInfoStep.letsDoubleCheck')} + {translate('beneficialOwnerInfoStep.regulationRequiresUsToVerifyTheIdentity')} + {areThereDirectors && ( + + {`${translate('beneficialOwnerInfoStep.owners')}:`} + {directors} + + )} + + {!!error && error.length > 0 && ( + + )} +