"use client"; import type { Token } from "../../../../../bridge/types/Token.js"; import type { ThirdwebClient } from "../../../../../client/client.js"; import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js"; import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js"; import { radius, spacing } from "../../../../core/design-system/index.js"; import { formatCurrencyAmount, formatTokenAmount, } from "../../ConnectWallet/screens/formatTokenBalance.js"; import { Container } from "../../components/basic.js"; import { Button } from "../../components/buttons.js"; import { Skeleton } from "../../components/Skeleton.js"; import { Spacer } from "../../components/Spacer.js"; import { Text } from "../../components/text.js"; import { TokenAndChain } from "../common/TokenAndChain.js"; import type { PaymentMethod } from "../types.js"; interface TokenSelectionProps { paymentMethods: PaymentMethod[]; paymentMethodsLoading: boolean; client: ThirdwebClient; onPaymentMethodSelected: (paymentMethod: PaymentMethod) => void; onBack: () => void; destinationToken: Token; destinationAmount: bigint; feePayer?: "sender" | "receiver"; currency?: SupportedFiatCurrency; } // Individual payment method token row component interface PaymentMethodTokenRowProps { paymentMethod: PaymentMethod & { type: "wallet" }; destinationToken: Token; destinationAmount: bigint; client: ThirdwebClient; onPaymentMethodSelected: (paymentMethod: PaymentMethod) => void; feePayer?: "sender" | "receiver"; currency?: SupportedFiatCurrency; } function PaymentMethodTokenRow({ paymentMethod, client, onPaymentMethodSelected, currency, }: PaymentMethodTokenRowProps) { const theme = useCustomTheme(); const hasEnoughBalance = paymentMethod.hasEnoughBalance; const currencyPrice = paymentMethod.originToken.prices[currency || "USD"]; return ( ); } export function TokenSelection({ paymentMethods, paymentMethodsLoading, client, onPaymentMethodSelected, onBack, destinationToken, destinationAmount, feePayer, currency, }: TokenSelectionProps) { const theme = useCustomTheme(); if (paymentMethodsLoading) { return ( {/* Skeleton rows matching PaymentMethodTokenRow structure */} {new Array(10).fill(0).map((_, i) => ( {/* Left side: Token icon and name skeleton */} {/* Token icon skeleton */}
{/* Token name skeleton */} {/* Chain name skeleton */} {/* Right side: Price and balance skeleton */} {/* Price amount skeleton */} {/* Balance skeleton */} ))} ); } if (paymentMethods.length === 0) { return ( No available tokens found for this wallet Try connecting a different wallet or pay with card ); } return ( {paymentMethods .filter((method) => method.type === "wallet") .map((method) => ( ))} ); }