Skip to content

Commit c07ec58

Browse files
Fix excluded currency and countries
1 parent da88626 commit c07ec58

File tree

6 files changed

+26
-13
lines changed

6 files changed

+26
-13
lines changed

src/CONST.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6490,6 +6490,8 @@ const CONST = {
64906490
},
64916491

64926492
CORPAY_FIELDS: {
6493+
EXCLUDED_COUNTRIES: ['IR', 'CU', 'SY', 'UA', 'KP', 'RU'] as string[],
6494+
EXCLUDED_CURRENCIES: ['IRR', 'CUP', 'SYP', 'UAH', 'KPW', 'RUB'] as string[],
64936495
BANK_ACCOUNT_DETAILS_FIELDS: ['accountNumber', 'localAccountNumber', 'routingCode', 'localRoutingCode', 'swiftBicCode'] as string[],
64946496
ACCOUNT_TYPE_KEY: 'BeneficiaryAccountType',
64956497
BANK_INFORMATION_FIELDS: ['bankName', 'bankAddressLine1', 'bankAddressLine2', 'bankCity', 'bankRegion', 'bankPostal', 'BeneficiaryBankBranchName'] as string[],

src/components/CurrencyPicker.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ type CurrencyPickerProps = {
2424

2525
/** Form Error description */
2626
errorText?: string;
27+
28+
/** List of currencies to exclude from the list */
29+
excludeCurrencies?: string[];
2730
};
2831

29-
function CurrencyPicker({value, errorText, headerContent, onInputChange = () => {}}: CurrencyPickerProps) {
32+
function CurrencyPicker({value, errorText, headerContent, excludeCurrencies, onInputChange = () => {}}: CurrencyPickerProps) {
3033
const {translate} = useLocalize();
3134
const [isPickerVisible, setIsPickerVisible] = useState(false);
3235
const styles = useThemeStyles();
@@ -75,6 +78,7 @@ function CurrencyPicker({value, errorText, headerContent, onInputChange = () =>
7578
initiallySelectedCurrencyCode={value}
7679
onSelect={updateInput}
7780
searchInputLabel={translate('common.search')}
81+
excludedCurrencies={excludeCurrencies}
7882
/>
7983
</ScreenWrapper>
8084
</Modal>

src/components/CurrencySelectionList/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function CurrencySelectionList({
1717
selectedCurrencies = [],
1818
canSelectMultiple = false,
1919
recentlyUsedCurrencies,
20+
excludedCurrencies = [],
2021
}: CurrencySelectionListProps) {
2122
const [currencyList] = useOnyx(ONYXKEYS.CURRENCY_LIST);
2223
const [searchValue, setSearchValue] = useState('');
@@ -25,7 +26,7 @@ function CurrencySelectionList({
2526
const {sections, headerMessage} = useMemo(() => {
2627
const currencyOptions: CurrencyListItem[] = Object.entries(currencyList ?? {}).reduce((acc, [currencyCode, currencyInfo]) => {
2728
const isSelectedCurrency = currencyCode === initiallySelectedCurrencyCode || selectedCurrencies.includes(currencyCode);
28-
if (isSelectedCurrency || !currencyInfo?.retired) {
29+
if (!excludedCurrencies.includes(currencyCode) && (isSelectedCurrency || !currencyInfo?.retired)) {
2930
acc.push({
3031
currencyName: currencyInfo?.name ?? '',
3132
text: `${currencyCode} - ${CurrencyUtils.getCurrencySymbol(currencyCode)}`,
@@ -86,7 +87,7 @@ function CurrencySelectionList({
8687
}
8788

8889
return {sections: result, headerMessage: isEmpty ? translate('common.noResultsFound') : ''};
89-
}, [currencyList, searchValue, translate, initiallySelectedCurrencyCode, selectedCurrencies, getUnselectedOptions, recentlyUsedCurrencies]);
90+
}, [currencyList, recentlyUsedCurrencies, searchValue, getUnselectedOptions, translate, initiallySelectedCurrencyCode, selectedCurrencies, excludedCurrencies]);
9091

9192
return (
9293
<SelectionList

src/components/CurrencySelectionList/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ type CurrencySelectionListProps = {
2323

2424
/** Whether this is a multi-select list */
2525
canSelectMultiple?: boolean;
26+
27+
/** List of excluded currency codes */
28+
excludedCurrencies?: string[];
2629
};
2730

2831
export type {CurrencyListItem, CurrencySelectionListProps};

src/pages/settings/Wallet/InternationalDepositAccount/substeps/BankAccountDetails.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function BankAccountDetails({isEditing, onNext, resetScreenIndex, formValues, fi
7272
value={formValues.bankCurrency}
7373
onInputChange={onCurrencySelected}
7474
headerContent={currencyHeaderContent}
75+
excludeCurrencies={CONST.CORPAY_FIELDS.EXCLUDED_CURRENCIES}
7576
/>
7677
</View>
7778
{Object.values(fieldsMap[CONST.CORPAY_FIELDS.STEPS_NAME.BANK_ACCOUNT_DETAILS] ?? {}).map((field) => (

src/pages/settings/Wallet/InternationalDepositAccount/substeps/CountrySelection.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ function CountrySelection({isEditing, onNext, formValues, resetScreenIndex}: Cus
4343

4444
const countries = useMemo(
4545
() =>
46-
Object.keys(CONST.ALL_COUNTRIES).map((countryISO) => {
47-
const countryName = translate(`allCountries.${countryISO}` as TranslationPaths);
48-
return {
49-
value: countryISO,
50-
keyForList: countryISO,
51-
text: countryName,
52-
isSelected: currentCountry === countryISO,
53-
searchValue: StringUtils.sanitizeString(`${countryISO}${countryName}`),
54-
};
55-
}),
46+
Object.keys(CONST.ALL_COUNTRIES)
47+
.filter((countryISO) => !CONST.CORPAY_FIELDS.EXCLUDED_COUNTRIES.includes(countryISO))
48+
.map((countryISO) => {
49+
const countryName = translate(`allCountries.${countryISO}` as TranslationPaths);
50+
return {
51+
value: countryISO,
52+
keyForList: countryISO,
53+
text: countryName,
54+
isSelected: currentCountry === countryISO,
55+
searchValue: StringUtils.sanitizeString(`${countryISO}${countryName}`),
56+
};
57+
}),
5658
[translate, currentCountry],
5759
);
5860

0 commit comments

Comments
 (0)