"use client"; import React, { useState } from "react"; import { AlertCircle, Check, ChevronDown, Loader2, RefreshCcw, Send, UserCircle2, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Input } from "@/components/ui/input"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; interface SwapLayoutProps { sendTypeDetails: any; sendType: string | null; sourceAmount: any; setSourceAmount: (value: any) => any; sourceTokenSelected: any; balancesLoading: boolean; sourceBalances: any[]; setSourceToken: (token: any) => void; destinationAmount: string; destinationAmountIsLoading: boolean; destinationTokenSelected: any; destinationBalances: any[]; setDestinationToken: (token: any) => void; computeSendType: (sourceToken: any, destinationToken: any) => string | null; addressSelected: any; canChangeAddress: boolean; isAddressSelectedValid: boolean; formatAddress: (address: string) => string; customAddress: string; setCustomAddress: (address: string) => void; isCustomAddressValid: boolean; saveCustomAddress: () => void; crossChainFee: { amount: string | number; decimals: number; symbol: string; formatted: string; } | null; isRightChain: boolean; handleSend: (sendType: any) => void; sendDisabled: boolean; isSending: boolean; sendButtonText: string; handleSwitchNetwork: () => void; } const SwapLayout: React.FC = ({ sendTypeDetails, sendType, sourceAmount, setSourceAmount, sourceTokenSelected, balancesLoading, sourceBalances, setSourceToken, destinationAmount, destinationAmountIsLoading, destinationTokenSelected, destinationBalances, setDestinationToken, computeSendType, addressSelected, canChangeAddress, isAddressSelectedValid, formatAddress, customAddress, setCustomAddress, isCustomAddressValid, saveCustomAddress, crossChainFee, isRightChain, handleSend, sendDisabled, isSending, sendButtonText, handleSwitchNetwork, }) => { const [sourceTokenOpen, setSourceTokenOpen] = useState(false); const [destinationTokenOpen, setDestinationTokenOpen] = useState(false); const [isFeeOpen, setIsFeeOpen] = useState(false); const [customAddressOpen, setCustomAddressOpen] = useState(false); const confirmCustomAddress = () => { saveCustomAddress(); setCustomAddressOpen(false); }; return (

{sendTypeDetails[sendType as any]?.title || "Swap"}

{ e.preventDefault(); }} >
setSourceAmount(e.target.value)} placeholder="0" value={sourceAmount} disabled={isSending || balancesLoading} type="number" step="any" /> No available tokens found. {sourceBalances.map((balances: any) => ( { setSourceToken(c === sourceTokenSelected ? null : c); setSourceTokenOpen(false); }} >
{balances.symbol}
{parseFloat(balances.balance).toFixed(2)}
{balances.chain_name}
))}
{destinationAmountIsLoading && (
)}
No available tokens found. {destinationBalances?.map((balances: any) => ( { setDestinationToken( c === destinationTokenSelected ? null : c ); setDestinationTokenOpen(false); }} >
{balances.symbol}
{parseFloat(balances.balance).toFixed(2)}
{balances.chain_name}
))}
{addressSelected && ( setCustomAddress(e.target.value)} value={customAddress} />
)} {crossChainFee?.formatted && (
Cross-Chain Fee
{crossChainFee?.amount}
)}
{isRightChain ? (
) : ( )}
); }; export default SwapLayout;