From 7254d8a14224e47117097b1db864e9339e952ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ram=C3=ADrez?= Date: Fri, 3 Oct 2025 14:11:51 -0300 Subject: [PATCH 1/5] fix: withdraw recent methods --- src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx b/src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx index 85218f9b3..8d01d563f 100644 --- a/src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx +++ b/src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx @@ -41,8 +41,8 @@ export default function WithdrawBankPage() { )?.currencyCode useEffect(() => { - if (!bankAccount && !amountToWithdraw) { - // If no bank account AND no amount, go back to main page + if (!amountToWithdraw) { + // If no amount, go back to main page router.replace('/withdraw') } else if (!bankAccount && amountToWithdraw) { // If amount is set but no bank account, go to country method selection From 6864ac2c02570feb2adaa9011bb08761f2cd6ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ram=C3=ADrez?= Date: Fri, 3 Oct 2025 16:04:47 -0300 Subject: [PATCH 2/5] fix: correctly route recent methods --- src/app/(mobile-ui)/withdraw/page.tsx | 13 +++++++++++-- src/utils/bridge.utils.ts | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/app/(mobile-ui)/withdraw/page.tsx b/src/app/(mobile-ui)/withdraw/page.tsx index 3aaef1b1f..f4f63b6ee 100644 --- a/src/app/(mobile-ui)/withdraw/page.tsx +++ b/src/app/(mobile-ui)/withdraw/page.tsx @@ -10,6 +10,7 @@ import { useWithdrawFlow } from '@/context/WithdrawFlowContext' import { useWallet } from '@/hooks/wallet/useWallet' import { tokenSelectorContext } from '@/context/tokenSelector.context' import { formatAmount } from '@/utils' +import { getCountryFromAccount } from '@/utils/bridge.utils' import { useRouter } from 'next/navigation' import { useCallback, useEffect, useMemo, useState, useRef, useContext } from 'react' import { formatUnits } from 'viem' @@ -27,12 +28,12 @@ export default function WithdrawPage() { error, setUsdAmount, selectedMethod, + selectedBankAccount, setSelectedMethod, setShowAllWithdrawMethods, } = useWithdrawFlow() - // FIXED FLOW: Only crypto gets amount input on main page, countries route directly - const initialStep: WithdrawStep = selectedMethod ? 'inputAmount' : 'selectMethod' + const initialStep: WithdrawStep = selectedMethod || selectedBankAccount ? 'inputAmount' : 'selectMethod' const [step, setStep] = useState(initialStep) @@ -179,6 +180,14 @@ export default function WithdrawPage() { setUsdAmount(usdVal.toString()) // Route based on selected method type + if (selectedBankAccount) { + const country = getCountryFromAccount(selectedBankAccount) + if (country) { + router.push(`/withdraw/${country.path}/bank`) + } else { + throw new Error('Failed to get country from bank account') + } + } if (selectedMethod.type === 'crypto') { router.push('/withdraw/crypto') } else if (selectedMethod.type === 'manteca') { diff --git a/src/utils/bridge.utils.ts b/src/utils/bridge.utils.ts index 4aa1eeaca..6e07d2fad 100644 --- a/src/utils/bridge.utils.ts +++ b/src/utils/bridge.utils.ts @@ -1,3 +1,6 @@ +import { countryData as ALL_METHODS_DATA, CountryData } from '@/components/AddMoney/consts' +import { Account, AccountType } from '@/interfaces' + export interface CurrencyConfig { currency: string paymentRail: string @@ -76,3 +79,17 @@ export const getPaymentRailDisplayName = (paymentRail: string): string => { } return displayNames[paymentRail] || paymentRail.toUpperCase() } + +export function getCountryFromAccount(account: Account): CountryData | undefined { + const threeLetterCountryCode = (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 +} From caea8b804ab93b2c68654a85796d12696fdd76df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ram=C3=ADrez?= Date: Fri, 3 Oct 2025 16:19:48 -0300 Subject: [PATCH 3/5] fix: stub images before other mappings --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a3f28f673..f19df87e4 100644 --- a/package.json +++ b/package.json @@ -137,11 +137,11 @@ "node_modules/(?!(@wagmi|wagmi|viem|@viem|@squirrel-labs)/)" ], "moduleNameMapper": { + "\\.(svg|png|jpg|jpeg|gif)$": "jest-transform-stub", "^@/(.*)$": "/src/$1", "^wagmi/chains$": "/src/utils/__mocks__/wagmi.ts", "^@squirrel-labs/peanut-sdk$": "/src/utils/__mocks__/peanut-sdk.ts", - "^next/cache$": "/src/utils/__mocks__/next-cache.ts", - "\\.(svg|png|jpg|jpeg|gif)$": "jest-transform-stub" + "^next/cache$": "/src/utils/__mocks__/next-cache.ts" }, "setupFilesAfterEnv": [ "/jest.setup.ts" From 3dabf064608855e7499a179558e5e0bf60b97c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ram=C3=ADrez?= Date: Fri, 3 Oct 2025 16:20:59 -0300 Subject: [PATCH 4/5] fix: double navigations --- src/app/(mobile-ui)/withdraw/page.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/(mobile-ui)/withdraw/page.tsx b/src/app/(mobile-ui)/withdraw/page.tsx index f4f63b6ee..ed7ef7959 100644 --- a/src/app/(mobile-ui)/withdraw/page.tsx +++ b/src/app/(mobile-ui)/withdraw/page.tsx @@ -187,8 +187,7 @@ export default function WithdrawPage() { } else { throw new Error('Failed to get country from bank account') } - } - if (selectedMethod.type === 'crypto') { + } else if (selectedMethod.type === 'crypto') { router.push('/withdraw/crypto') } else if (selectedMethod.type === 'manteca') { // Route directly to Manteca with method and country params From dc16c5714885848c5c626aeccd6e86f31cc7e0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ram=C3=ADrez?= Date: Fri, 3 Oct 2025 16:54:39 -0300 Subject: [PATCH 5/5] fix: correct recent method routing --- src/app/(mobile-ui)/withdraw/page.tsx | 4 +-- .../AddWithdraw/AddWithdrawRouterView.tsx | 25 ++++++++----------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/app/(mobile-ui)/withdraw/page.tsx b/src/app/(mobile-ui)/withdraw/page.tsx index ed7ef7959..0f4a94dd4 100644 --- a/src/app/(mobile-ui)/withdraw/page.tsx +++ b/src/app/(mobile-ui)/withdraw/page.tsx @@ -33,7 +33,7 @@ export default function WithdrawPage() { setShowAllWithdrawMethods, } = useWithdrawFlow() - const initialStep: WithdrawStep = selectedMethod || selectedBankAccount ? 'inputAmount' : 'selectMethod' + const initialStep: WithdrawStep = selectedMethod ? 'inputAmount' : 'selectMethod' const [step, setStep] = useState(initialStep) @@ -218,8 +218,6 @@ export default function WithdrawPage() { }, [rawTokenAmount, maxDecimalAmount, error.showError, selectedTokenData?.price]) if (step === 'inputAmount') { - const methodTitle = selectedMethod?.title || selectedMethod?.countryPath || 'Selected method' - return (
= ({ pageTitle={pageTitle} onPrev={onBackClick || defaultBackNavigation} savedAccounts={savedAccounts} - onAccountClick={(account, path) => { + onAccountClick={(account, _path) => { setSelectedBankAccount(account) - - // FIXED: For withdraw flow, route to saved account path - if (flow === 'withdraw') { - if (account.type === AccountType.MANTECA) { - router.push( - `/withdraw/manteca?country=${account.details.countryName}&destination=${account.identifier}` - ) - } else { - router.push(path) - } - return + setSelectedMethod({ + type: account.type === AccountType.MANTECA ? 'manteca' : 'bridge', + countryPath: account.details.countryName, + title: 'To Bank', + }) + if (account.type === AccountType.MANTECA) { + router.push( + `/withdraw/manteca?country=${account.details.countryName}&destination=${account.identifier}` + ) } - - // Original add flow - router.push(path) }} onSelectNewMethodClick={() => setShouldShowAllMethods(true)} />