Skip to content

Commit

Permalink
Merge pull request #32410 from Expensify/nikki-match-bank-names
Browse files Browse the repository at this point in the history
[CP Staging] Match bank names for credit card icons

(cherry picked from commit 6dbaa4a)
  • Loading branch information
chiragsalian authored and OSBotify committed Dec 4, 2023
1 parent 48915d8 commit 5c0d43f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2873,6 +2873,7 @@ const CONST = {
FIDELITY: 'fidelity',
GENERIC_BANK: 'generic bank',
HUNTINGTON_BANK: 'huntington bank',
HUNTINGTON_NATIONAL: 'huntington national',
NAVY_FEDERAL_CREDIT_UNION: 'navy federal credit union',
PNC: 'pnc',
REGIONS_BANK: 'regions bank',
Expand Down
15 changes: 14 additions & 1 deletion src/components/Icon/BankIcons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ function getAssetIcon(bankNameKey: BankNameKey, isCard: boolean): React.FC<SvgPr
[CONST.BANK_NAMES.HUNTINGTON_BANK]: isCard
? (require('@assets/images/cardicons/huntington-bank.svg').default as React.FC<SvgProps>)
: (require('@assets/images/bankicons/huntington-bank.svg').default as React.FC<SvgProps>),
[CONST.BANK_NAMES.HUNTINGTON_NATIONAL]: isCard
? (require('@assets/images/cardicons/huntington-bank.svg').default as React.FC<SvgProps>)
: (require('@assets/images/bankicons/huntington-bank.svg').default as React.FC<SvgProps>),
[CONST.BANK_NAMES.NAVY_FEDERAL_CREDIT_UNION]: isCard
? (require('@assets/images/cardicons/navy-federal-credit-union.svg').default as React.FC<SvgProps>)
: (require('@assets/images/bankicons/navy-federal-credit-union.svg').default as React.FC<SvgProps>),
Expand Down Expand Up @@ -95,7 +98,17 @@ function getAssetIcon(bankNameKey: BankNameKey, isCard: boolean): React.FC<SvgPr
}

function getBankNameKey(bankName: string): BankNameKey {
const bank = Object.entries(CONST.BANK_NAMES).find(([, value]) => value?.toLowerCase() === bankName);
const bank = Object.entries(CONST.BANK_NAMES).find(([, value]) => {
const condensedValue = value.replace(/\s/g, '');
return (
bankName === value ||
bankName.includes(value) ||
bankName.startsWith(value) ||
bankName === condensedValue ||
bankName.includes(condensedValue) ||
bankName.startsWith(condensedValue)
);
});
return (bank?.[0] as BankNameKey) ?? '';
}

Expand Down

0 comments on commit 5c0d43f

Please sign in to comment.