From de8b23389f028d5815210307fa136d57fe5d4bdd Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 16 Aug 2024 14:20:49 +0700 Subject: [PATCH] fix: filter retired currencies --- .../CurrencySelectionList/index.tsx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/CurrencySelectionList/index.tsx b/src/components/CurrencySelectionList/index.tsx index 7bd33252f0ee..9cb0ba270aec 100644 --- a/src/components/CurrencySelectionList/index.tsx +++ b/src/components/CurrencySelectionList/index.tsx @@ -14,16 +14,19 @@ function CurrencySelectionList({searchInputLabel, initiallySelectedCurrencyCode, const {translate} = useLocalize(); const {sections, headerMessage} = useMemo(() => { - const currencyOptions: CurrencyListItem[] = Object.entries(currencyList ?? {}).map(([currencyCode, currencyInfo]) => { + const currencyOptions: CurrencyListItem[] = Object.entries(currencyList ?? {}).reduce((acc, [currencyCode, currencyInfo]) => { const isSelectedCurrency = currencyCode === initiallySelectedCurrencyCode || selectedCurrencies.includes(currencyCode); - return { - currencyName: currencyInfo?.name ?? '', - text: `${currencyCode} - ${CurrencyUtils.getCurrencySymbol(currencyCode)}`, - currencyCode, - keyForList: currencyCode, - isSelected: isSelectedCurrency, - }; - }); + if (isSelectedCurrency || !currencyInfo?.retired) { + acc.push({ + currencyName: currencyInfo?.name ?? '', + text: `${currencyCode} - ${CurrencyUtils.getCurrencySymbol(currencyCode)}`, + currencyCode, + keyForList: currencyCode, + isSelected: isSelectedCurrency, + }); + } + return acc; + }, [] as CurrencyListItem[]); const searchRegex = new RegExp(Str.escapeForRegExp(searchValue.trim()), 'i'); const filteredCurrencies = currencyOptions.filter((currencyOption) => searchRegex.test(currencyOption.text ?? '') || searchRegex.test(currencyOption.currencyName));