fix: correctly route recent methods#1283
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds getCountryFromAccount to map a saved bank Account to CountryData and updates the mobile withdraw page to consume selectedBankAccount, adjust initial step selection, and route to /withdraw/{country.path}/bank based on the derived country (errors if derivation fails). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (4)📓 Common learnings📚 Learning: 2025-05-22T15:38:48.586ZApplied to files:
📚 Learning: 2025-09-18T09:30:42.901ZApplied to files:
📚 Learning: 2025-10-02T15:23:01.405ZApplied to files:
🧬 Code graph analysis (1)src/app/(mobile-ui)/withdraw/page.tsx (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/utils/bridge.utils.ts (1)
83-95: Function logic is sound; consider minor defensive improvements.The lookup logic correctly handles US accounts specially and falls back to countryName or code-based lookups. The case-insensitive comparison for
countryNameis appropriate.Optional refinements:
The optional chaining on Line 91 (
account.details.countryName?.toLowerCase()) is redundant since the ternary already checks foraccount.details.countryName. You can simplify toaccount.details.countryName.toLowerCase().Consider adding a defensive check for
account.detailsto prevent potential runtime errors if the account object is malformed:export function getCountryFromAccount(account: Account): CountryData | undefined { + if (!account.details) { + return undefined + } const threeLetterCountryCode = (account.details.countryCode ?? '').toUpperCase()Based on learnings regarding uppercase country code normalization in the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/(mobile-ui)/withdraw/page.tsx(3 hunks)src/utils/bridge.utils.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: kushagrasarathe
PR: peanutprotocol/peanut-ui#869
File: src/app/(mobile-ui)/withdraw/page.tsx:82-88
Timestamp: 2025-05-22T15:38:48.586Z
Learning: The country-specific withdrawal route exists at src/app/(mobile-ui)/withdraw/[...country]/page.tsx and renders the AddWithdrawCountriesList component with flow="withdraw".
Learnt from: kushagrasarathe
PR: peanutprotocol/peanut-ui#869
File: src/app/(mobile-ui)/withdraw/page.tsx:82-88
Timestamp: 2025-05-22T15:38:48.586Z
Learning: The country-specific withdrawal route exists at src/app/(mobile-ui)/withdraw/[...country]/page.tsx and renders the AddWithdrawCountriesList component with flow="withdraw".
📚 Learning: 2025-05-22T15:38:48.586Z
Learnt from: kushagrasarathe
PR: peanutprotocol/peanut-ui#869
File: src/app/(mobile-ui)/withdraw/page.tsx:82-88
Timestamp: 2025-05-22T15:38:48.586Z
Learning: The country-specific withdrawal route exists at src/app/(mobile-ui)/withdraw/[...country]/page.tsx and renders the AddWithdrawCountriesList component with flow="withdraw".
Applied to files:
src/app/(mobile-ui)/withdraw/page.tsx
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1230
File: src/app/(mobile-ui)/withdraw/page.tsx:92-97
Timestamp: 2025-09-18T09:30:42.901Z
Learning: In src/app/(mobile-ui)/withdraw/page.tsx, the useEffect that calls setShowAllWithdrawMethods(true) when amountFromContext exists is intentionally designed to run only on component mount (empty dependency array), not when amountFromContext changes. This is the correct behavior for the withdraw flow where showing all methods should only happen on initial load when an amount is already present.
Applied to files:
src/app/(mobile-ui)/withdraw/page.tsx
📚 Learning: 2025-08-14T14:42:54.411Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1094
File: src/utils/withdraw.utils.ts:181-191
Timestamp: 2025-08-14T14:42:54.411Z
Learning: The countryCodeMap in src/components/AddMoney/consts/index.ts uses uppercase 3-letter country codes as keys (like 'AUT', 'BEL', 'CZE') that map to 2-letter country codes, requiring input normalization to uppercase for proper lookups.
Applied to files:
src/utils/bridge.utils.ts
🧬 Code graph analysis (2)
src/app/(mobile-ui)/withdraw/page.tsx (2)
src/context/WithdrawFlowContext.tsx (1)
useWithdrawFlow(157-163)src/utils/bridge.utils.ts (1)
getCountryFromAccount(83-95)
src/utils/bridge.utils.ts (2)
src/interfaces/interfaces.ts (1)
Account(274-301)src/components/AddMoney/consts/index.ts (1)
CountryData(153-162)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Deploy-Preview
🔇 Additional comments (5)
src/utils/bridge.utils.ts (1)
1-2: LGTM!The imports are appropriate for the new
getCountryFromAccountfunction, bringing in the necessary types and data sources.src/app/(mobile-ui)/withdraw/page.tsx (4)
13-13: LGTM!The import of
getCountryFromAccountis correctly placed and will be used for routing logic.
36-36: LGTM!The updated
initialSteplogic correctly considers bothselectedMethodandselectedBankAccount, allowing users to skip directly to amount input when a bank account is pre-selected.
186-186: Bank withdrawal route exists
src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx handles/withdraw/${country.path}/bank.
31-31: selectedBankAccount is present in WithdrawFlowContextType No update needed.
No description provided.