Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/AddWithdraw/AddWithdrawRouterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,19 @@ export const AddWithdrawRouterView: FC<AddWithdrawRouterViewProps> = ({
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}`
)
}
}}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Claim/Link/views/BankFlowManager.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '',
Expand Down Expand Up @@ -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 ?? '',
Expand Down
6 changes: 5 additions & 1 deletion src/components/Common/SavedAccountsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,18 @@ export function SavedAccountsMapping({
className="p-4 py-2.5"
leftIcon={
<div className="relative h-8 w-8">
{countryCodeForFlag && (
{countryCodeForFlag ? (
<Image
src={getFlagUrl(account.type === AccountType.US ? 'us' : countryCodeForFlag)}
alt={`${details.countryName ?? 'country'} flag`}
width={80}
height={80}
className="h-8 w-8 rounded-full object-cover"
/>
) : (
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-grey-2">
<Icon size={16} name="bank" className="text-n-1" />
</div>
)}
<div className="absolute -bottom-1 -right-1 flex h-5 w-5 items-center justify-center rounded-full bg-yellow-400 p-1">
<Icon size={12} name="bank" className="text-black" />
Expand Down
26 changes: 10 additions & 16 deletions src/components/TransactionDetails/TransactionDetailsHeaderCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<TransactionDirection, string>> = {
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
Expand Down
19 changes: 10 additions & 9 deletions src/utils/bridge.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down
Loading