import { Sheet } from '@/internal/components/Sheet';
import { zIndex } from '@/styles/constants';
import { border, cn, text } from '@/styles/theme';
import { useCallback, useMemo } from 'react';
import { WALLET_ADVANCED_DEFAULT_SWAPPABLE_TOKENS } from '../constants';
import { WalletAdvancedQrReceive } from './WalletAdvancedQrReceive';
import { WalletAdvancedSwap } from './WalletAdvancedSwap';
import { useWalletContext } from './WalletProvider';
import { Send } from './wallet-advanced-send/components/Send';
import { RequestContext } from '@/core/network/constants';
import { usePortfolio } from '@/wallet/hooks/usePortfolio';
import { useAccount } from 'wagmi';
import {
WalletAdvancedQrReceiveProps,
WalletAdvancedSwapProps,
} from '../types';
import { Token } from '@/token';
export type WalletDropdownContentProps = {
children?: React.ReactNode;
swappableTokens?: Token[];
classNames?: {
container?: string;
qr?: WalletAdvancedQrReceiveProps['classNames'];
swap?: WalletAdvancedSwapProps['classNames'];
};
};
export function WalletDropdownContent({
children,
swappableTokens,
classNames,
}: WalletDropdownContentProps) {
const {
isSubComponentOpen,
setIsSubComponentOpen,
isSubComponentClosing,
setIsSubComponentClosing,
breakpoint,
activeFeature,
animations,
} = useWalletContext();
const { address } = useAccount();
const { data: portfolioData } = usePortfolio(
{ address, enabled: Boolean(activeFeature) },
RequestContext.Wallet,
);
const tokenBalances = portfolioData?.tokenBalances;
const handleBottomSheetClose = useCallback(() => {
setIsSubComponentOpen(false);
}, [setIsSubComponentOpen]);
const handleAnimationEnd = useCallback(() => {
if (isSubComponentClosing) {
setIsSubComponentOpen(false);
setIsSubComponentClosing(false);
}
}, [isSubComponentClosing, setIsSubComponentOpen, setIsSubComponentClosing]);
const content = useMemo(() => {
if (activeFeature === 'send') {
return (