Skip to content

Commit 8b4e2e3

Browse files
authored
Merge pull request #61589 from bernhardoj/fix/60571-address-suggestion-doesnt-show
Show address autocomplete on the bank and account holder details
2 parents 0e4527f + 9fd0e52 commit 8b4e2e3

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/AccountHolderDetails.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useCallback, useMemo} from 'react';
22
import {View} from 'react-native';
33
import {useOnyx} from 'react-native-onyx';
4+
import AddressSearch from '@components/AddressSearch';
45
import FormProvider from '@components/Form/FormProvider';
56
import InputWrapper from '@components/Form/InputWrapper';
67
import type {FormInputErrors, FormOnyxKeys, FormOnyxValues} from '@components/Form/types';
@@ -17,10 +18,18 @@ import CONST from '@src/CONST';
1718
import ONYXKEYS from '@src/ONYXKEYS';
1819
import type {ReimbursementAccountForm} from '@src/types/form/ReimbursementAccountForm';
1920
import INPUT_IDS from '@src/types/form/ReimbursementAccountForm';
21+
import type {CorpayFormField} from '@src/types/onyx';
2022

2123
const {ACCOUNT_HOLDER_COUNTRY} = INPUT_IDS.ADDITIONAL_DATA.CORPAY;
2224
const {COUNTRY} = INPUT_IDS.ADDITIONAL_DATA;
2325

26+
function getInputComponent(field: CorpayFormField) {
27+
if (CONST.CORPAY_FIELDS.SPECIAL_LIST_ADDRESS_KEYS.includes(field.id)) {
28+
return AddressSearch;
29+
}
30+
return TextInput;
31+
}
32+
2433
function AccountHolderDetails({onNext, isEditing, corpayFields}: BankInfoSubStepProps) {
2534
const {translate} = useLocalize();
2635
const styles = useThemeStyles();
@@ -110,13 +119,18 @@ function AccountHolderDetails({onNext, isEditing, corpayFields}: BankInfoSubStep
110119
key={field.id}
111120
>
112121
<InputWrapper
113-
InputComponent={TextInput}
122+
InputComponent={getInputComponent(field)}
114123
inputID={field.id}
115124
label={field.label}
116125
aria-label={field.label}
117126
role={CONST.ROLE.PRESENTATION}
118127
defaultValue={String(defaultValues[field.id as keyof typeof defaultValues]) ?? ''}
119128
shouldSaveDraft={!isEditing}
129+
limitSearchesToCountry={defaultValues.accountHolderCountry || defaultBankAccountCountry}
130+
renamedInputKeys={{
131+
street: 'accountHolderAddress1',
132+
city: 'accountHolderCity',
133+
}}
120134
/>
121135
</View>
122136
);

src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useCallback, useMemo} from 'react';
22
import {ActivityIndicator, View} from 'react-native';
33
import {useOnyx} from 'react-native-onyx';
4+
import AddressSearch from '@components/AddressSearch';
45
import FormProvider from '@components/Form/FormProvider';
56
import InputWrapper from '@components/Form/InputWrapper';
67
import type {FormInputErrors, FormOnyxKeys, FormOnyxValues} from '@components/Form/types';
@@ -16,6 +17,14 @@ import getInputForValueSet from '@pages/ReimbursementAccount/NonUSD/utils/getInp
1617
import CONST from '@src/CONST';
1718
import ONYXKEYS from '@src/ONYXKEYS';
1819
import type {ReimbursementAccountForm} from '@src/types/form';
20+
import type {CorpayFormField} from '@src/types/onyx';
21+
22+
function getInputComponent(field: CorpayFormField) {
23+
if (CONST.CORPAY_FIELDS.SPECIAL_LIST_ADDRESS_KEYS.includes(field.id)) {
24+
return AddressSearch;
25+
}
26+
return TextInput;
27+
}
1928

2029
function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepProps) {
2130
const {translate} = useLocalize();
@@ -87,18 +96,24 @@ function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepPr
8796
key={field.id}
8897
>
8998
<InputWrapper
90-
InputComponent={TextInput}
99+
InputComponent={getInputComponent(field)}
91100
inputID={field.id}
92101
label={field.label}
93102
aria-label={field.label}
94103
role={CONST.ROLE.PRESENTATION}
95104
shouldSaveDraft={!isEditing}
96105
defaultValue={String(defaultValues[field.id as keyof typeof defaultValues]) ?? ''}
106+
limitSearchesToCountry={reimbursementAccountDraft?.country}
107+
renamedInputKeys={{
108+
street: 'bankAddressLine1',
109+
city: 'bankCity',
110+
country: '',
111+
}}
97112
/>
98113
</View>
99114
);
100115
});
101-
}, [bankAccountDetailsFields, styles, isEditing, defaultValues]);
116+
}, [bankAccountDetailsFields, styles, isEditing, defaultValues, reimbursementAccountDraft?.country]);
102117

103118
return (
104119
<FormProvider

0 commit comments

Comments
 (0)