diff --git a/src/components/AddWithdraw/AddWithdrawRouterView.tsx b/src/components/AddWithdraw/AddWithdrawRouterView.tsx index 71fc41c2f..6c1925031 100644 --- a/src/components/AddWithdraw/AddWithdrawRouterView.tsx +++ b/src/components/AddWithdraw/AddWithdrawRouterView.tsx @@ -218,18 +218,19 @@ export const AddWithdrawRouterView: FC = ({ pageTitle={pageTitle} onPrev={onBackClick || defaultBackNavigation} savedAccounts={savedAccounts} - onAccountClick={(account, _path) => { + onAccountClick={(account, path) => { setSelectedBankAccount(account) + const countryPath = account.details?.countryName || path || '' setSelectedMethod({ type: account.type === AccountType.MANTECA ? 'manteca' : 'bridge', - countryPath: account.details.countryName, + countryPath, title: 'To Bank', }) if (account.type === AccountType.MANTECA) { // preserve method param if coming from send flow const additionalParams = isBankFromSend ? `&method=${methodParam}` : '' router.push( - `/withdraw/manteca?country=${account.details.countryName}&destination=${account.identifier}&isSavedAccount=true${additionalParams}` + `/withdraw/manteca?country=${encodeURIComponent(countryPath)}&destination=${encodeURIComponent(account.identifier)}&isSavedAccount=true${additionalParams}` ) } }} diff --git a/src/components/Claim/Link/views/BankFlowManager.view.tsx b/src/components/Claim/Link/views/BankFlowManager.view.tsx index 521f54bf9..c7f54eb85 100644 --- a/src/components/Claim/Link/views/BankFlowManager.view.tsx +++ b/src/components/Claim/Link/views/BankFlowManager.view.tsx @@ -270,7 +270,7 @@ export const BankFlowManager = (props: IClaimScreenProps) => { addBankAccountResponse.data.type === 'us' || addBankAccountResponse.data.type === 'gb' ? addBankAccountResponse.data.identifier || '' : '', - country: addBankAccountResponse.data.details.countryCode, + country: addBankAccountResponse.data.details?.countryCode ?? '', id: addBankAccountResponse.data.id, bridgeAccountId: addBankAccountResponse.data.bridgeAccountId, bic: addBankAccountResponse.data.bic ?? '', @@ -387,12 +387,12 @@ export const BankFlowManager = (props: IClaimScreenProps) => { const lastName = lastNameParts.join(' ') const bankDetails = { - name: account.details.accountOwnerName || user?.user.fullName || '', + name: account.details?.accountOwnerName || user?.user.fullName || '', iban: account.type === 'iban' ? account.identifier || '' : '', clabe: account.type === 'clabe' ? account.identifier || '' : '', accountNumber: account.type === 'us' || account.type === 'gb' ? account.identifier || '' : '', - country: account.details.countryCode, + country: account.details?.countryCode ?? '', id: account.id, bridgeAccountId: account.bridgeAccountId, bic: account.bic ?? '', diff --git a/src/components/Common/SavedAccountsView.tsx b/src/components/Common/SavedAccountsView.tsx index 7e4d1e556..9cd8b9b4b 100644 --- a/src/components/Common/SavedAccountsView.tsx +++ b/src/components/Common/SavedAccountsView.tsx @@ -110,7 +110,7 @@ export function SavedAccountsMapping({ className="p-4 py-2.5" leftIcon={
- {countryCodeForFlag && ( + {countryCodeForFlag ? ( {`${details.countryName + ) : ( +
+ +
)}
diff --git a/src/components/TransactionDetails/TransactionDetailsHeaderCard.tsx b/src/components/TransactionDetails/TransactionDetailsHeaderCard.tsx index 52b71f468..d80cf6946 100644 --- a/src/components/TransactionDetails/TransactionDetailsHeaderCard.tsx +++ b/src/components/TransactionDetails/TransactionDetailsHeaderCard.tsx @@ -61,23 +61,17 @@ const getTitle = ( ): React.ReactNode => { let titleText = userName - if (isLinkTransaction && (status === 'pending' || status === 'cancelled' || !userName)) { - const displayName = userName - switch (direction) { - case 'send': - titleText = displayName - break - case 'request_sent': - titleText = 'Requested via Link' - break - case 'receive': - case 'request_received': - titleText = 'Request via Link' - break - default: - titleText = 'Link Transaction' - break + // Link transactions short-circuit; userName is already a self-describing + // label so the "Sent to ${displayName}" prefix doesn't apply. + if (isLinkTransaction) { + const completed = status === 'completed' + const titleByDirection: Partial> = { + send: completed ? 'You sent via link' : userName, + receive: completed ? 'You received via link' : userName, + request_sent: 'Requested via Link', + request_received: 'Request via Link', } + titleText = titleByDirection[direction] ?? userName ?? 'Link Transaction' } else { const isAddress = isWalletAddress(userName) const displayName = isAddress ? printableAddress(userName) : userName diff --git a/src/utils/bridge.utils.ts b/src/utils/bridge.utils.ts index 613ae6698..2c45bc538 100644 --- a/src/utils/bridge.utils.ts +++ b/src/utils/bridge.utils.ts @@ -159,17 +159,18 @@ export function getCountryFromPath(countryPath: string): CountryData | undefined } export function getCountryFromAccount(account: Account): CountryData | undefined { - const threeLetterCountryCode = (account.details.countryCode ?? '').toUpperCase() + const code = (account.details?.countryCode ?? '').toUpperCase() - let countryInfo if (account.type === AccountType.US) { - countryInfo = ALL_METHODS_DATA.find((c) => c.id === 'US') - } else { - countryInfo = account.details.countryName - ? ALL_METHODS_DATA.find((c) => c.path.toLowerCase() === account.details.countryName?.toLowerCase()) - : ALL_METHODS_DATA.find((c) => c.id === threeLetterCountryCode) - } - return countryInfo + return ALL_METHODS_DATA.find((c) => c.id === 'US') + } + // Try countryName first; fall back to the country code. Bridge stores + // ISO3 ('USA', 'GBR'); CountryData carries both `iso3` and `iso2` (= `id`), + // so accept either shape so a name mismatch doesn't drop the lookup. + const byName = account.details?.countryName + ? ALL_METHODS_DATA.find((c) => c.path.toLowerCase() === account.details?.countryName?.toLowerCase()) + : undefined + return byName ?? ALL_METHODS_DATA.find((c) => c.iso3 === code || c.id === code) } /**