From 3edbfc2d6669cd1e5d2b4641cdbdd8e2484b8518 Mon Sep 17 00:00:00 2001
From: kushagrasarathe <76868364+kushagrasarathe@users.noreply.github.com>
Date: Fri, 24 Oct 2025 19:26:50 +0530
Subject: [PATCH 1/3] feat: update send router payment options
---
.../index.tsx} | 6 +-
.../components/CryptoSourceListCard.tsx | 4 +-
.../AddMoney/components/DepositMethodList.tsx | 4 +-
.../AddMoney/views/TokenSelection.view.tsx | 4 +-
.../AddWithdraw/AddWithdrawCountriesList.tsx | 4 +-
src/components/Common/ActionList.tsx | 59 ++---
.../Common/ActionListDaimoPayButton.tsx | 6 +-
src/components/Common/CountryList.tsx | 8 +-
src/components/Common/CountryListSkeleton.tsx | 4 +-
src/components/Common/SavedAccountsView.tsx | 6 +-
src/components/Global/Icons/user.tsx | 8 +-
src/components/Profile/AvatarWithBadge.tsx | 4 +-
.../Request/views/RequestRouter.view.tsx | 11 +-
src/components/RouterViewWrapper/index.tsx | 93 --------
.../SearchInput.tsx => SearchInput/index.tsx} | 0
src/components/SearchUsers/SearchResults.tsx | 147 -------------
src/components/Send/views/SendRouter.view.tsx | 201 +++++++++++++++++-
src/constants/actionlist.consts.ts | 3 +-
src/hooks/useGeoFilteredPaymentOptions.ts | 77 +++++++
src/hooks/useRecentUsers.ts | 10 +-
src/hooks/useTranslationViewTransition.ts | 33 ---
21 files changed, 325 insertions(+), 367 deletions(-)
rename src/components/{SearchUsers/SearchResultCard.tsx => ActionListCard/index.tsx} (95%)
delete mode 100644 src/components/RouterViewWrapper/index.tsx
rename src/components/{SearchUsers/SearchInput.tsx => SearchInput/index.tsx} (100%)
delete mode 100644 src/components/SearchUsers/SearchResults.tsx
create mode 100644 src/hooks/useGeoFilteredPaymentOptions.ts
delete mode 100644 src/hooks/useTranslationViewTransition.ts
diff --git a/src/components/SearchUsers/SearchResultCard.tsx b/src/components/ActionListCard/index.tsx
similarity index 95%
rename from src/components/SearchUsers/SearchResultCard.tsx
rename to src/components/ActionListCard/index.tsx
index cd17039fd..46976c86e 100644
--- a/src/components/SearchUsers/SearchResultCard.tsx
+++ b/src/components/ActionListCard/index.tsx
@@ -4,7 +4,7 @@ import React from 'react'
import { twMerge } from 'tailwind-merge'
import { Button } from '../0_Bruddle'
-interface SearchResultCardProps {
+interface ActionListCardProps {
title: string | React.ReactNode
description?: string
leftIcon?: React.ReactNode
@@ -16,7 +16,7 @@ interface SearchResultCardProps {
descriptionClassName?: string
}
-export const SearchResultCard = ({
+export const ActionListCard = ({
title,
description,
leftIcon,
@@ -26,7 +26,7 @@ export const SearchResultCard = ({
rightContent,
isDisabled = false,
descriptionClassName,
-}: SearchResultCardProps) => {
+}: ActionListCardProps) => {
const handleCardClick = () => {
onClick()
}
diff --git a/src/components/AddMoney/components/CryptoSourceListCard.tsx b/src/components/AddMoney/components/CryptoSourceListCard.tsx
index 991457348..ca1ce90f4 100644
--- a/src/components/AddMoney/components/CryptoSourceListCard.tsx
+++ b/src/components/AddMoney/components/CryptoSourceListCard.tsx
@@ -1,9 +1,9 @@
'use client'
import AvatarWithBadge from '@/components/Profile/AvatarWithBadge'
-import { SearchResultCard } from '@/components/SearchUsers/SearchResultCard'
import Image, { type StaticImageData } from 'next/image'
import { twMerge } from 'tailwind-merge'
import { type CryptoSource } from '../consts'
+import { ActionListCard } from '@/components/ActionListCard'
interface CryptoSourceListCardProps {
sources: CryptoSource[]
@@ -22,7 +22,7 @@ export const CryptoSourceListCard = ({ sources, onItemClick }: CryptoSourceListC
return (
{sources.map((source, index) => (
-
= ({ headerTitle, on
const isDisabled = token.symbol.toLowerCase() !== PEANUT_WALLET_TOKEN_SYMBOL.toLowerCase()
return (
- {
{title}
{paymentMethods.map((method, index) => (
-
{
+ if (flow === 'claim') {
+ return claimType === BankClaimType.GuestKycNeeded || claimType === BankClaimType.ReceiverKycNeeded
+ }
+ if (flow === 'request') {
+ return requestType === BankRequestType.GuestKycNeeded || requestType === BankRequestType.PayerKycNeeded
+ }
+ return false
+ }, [claimType, requestType, flow])
+
+ // use the hook to filter and sort payment methods based on geolocation
+ const { filteredMethods: sortedActionMethods, isLoading: isGeoLoading } = useGeoFilteredPaymentOptions({
+ sortUnavailable: true,
+ isMethodUnavailable: (method) => method.soon || (method.id === 'bank' && requiresVerification),
+ })
const handleMethodClick = async (method: PaymentMethod) => {
if (flow === 'claim' && claimLinkData) {
@@ -156,41 +170,6 @@ export default function ActionList({
}
}
- const geolocatedMethods = useMemo(() => {
- // show pix in brazil and mercado pago in other countries
- return ACTION_METHODS.filter((method) => {
- if (userGeoLocationCountryCode === 'BR' && method.id === 'mercadopago') {
- return false
- }
- if (userGeoLocationCountryCode !== 'BR' && method.id === 'pix') {
- return false
- }
- return true
- })
- }, [userGeoLocationCountryCode])
-
- const requiresVerification = useMemo(() => {
- if (flow === 'claim') {
- return claimType === BankClaimType.GuestKycNeeded || claimType === BankClaimType.ReceiverKycNeeded
- }
- if (flow === 'request') {
- return requestType === BankRequestType.GuestKycNeeded || requestType === BankRequestType.PayerKycNeeded
- }
- return false
- }, [claimType, requestType, flow])
-
- const sortedActionMethods = useMemo(() => {
- return [...geolocatedMethods].sort((a, b) => {
- const aIsUnavailable = a.soon || (a.id === 'bank' && requiresVerification)
- const bIsUnavailable = b.soon || (b.id === 'bank' && requiresVerification)
-
- if (aIsUnavailable === bIsUnavailable) {
- return 0
- }
- return aIsUnavailable ? 1 : -1
- })
- }, [requiresVerification])
-
const handleContinueWithPeanut = () => {
if (flow === 'claim') {
addParamStep('claim')
@@ -320,7 +299,7 @@ export const MethodCard = ({
requiresVerification?: boolean
}) => {
return (
- void
@@ -162,7 +162,7 @@ const ActionListDaimoPayButton = ({ handleContinueWithPeanut, showConfirmModal }
daimoPayButtonClickRef.current = onClick
return (
-
{!searchTerm && viewMode === 'add-withdraw' && onCryptoClick && (
-
{
{Array.from({ length: 10 }).map((_, index) => {
const position = getCardPosition(index, 5)
return (
- }
position={position}
diff --git a/src/components/Common/SavedAccountsView.tsx b/src/components/Common/SavedAccountsView.tsx
index ff3bf68cb..ff1c95e5c 100644
--- a/src/components/Common/SavedAccountsView.tsx
+++ b/src/components/Common/SavedAccountsView.tsx
@@ -1,14 +1,14 @@
'use client'
import { countryData as ALL_METHODS_DATA, ALL_COUNTRIES_ALPHA3_TO_ALPHA2 } from '@/components/AddMoney/consts'
-import { shortenStringLong, formatIban } from '@/utils/general.utils'
+import { formatIban } from '@/utils/general.utils'
import { AccountType, type Account } from '@/interfaces'
import Image from 'next/image'
import { Icon } from '@/components/Global/Icons/Icon'
-import { SearchResultCard } from '@/components/SearchUsers/SearchResultCard'
import NavHeader from '../Global/NavHeader'
import Divider from '../0_Bruddle/Divider'
import { Button } from '../0_Bruddle'
+import { ActionListCard } from '../ActionListCard'
interface SavedAccountListProps {
pageTitle: string
@@ -101,7 +101,7 @@ export function SavedAccountsMapping({
const title = account.type === AccountType.IBAN ? formatIban(account.identifier) : account.identifier
return (
- > = (props) => (
-