import { useState } from 'react' import Link from 'next/link' import { Menu } from '@headlessui/react' import { DotsHorizontalIcon } from '@heroicons/react/outline' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import useMangoStore from '../stores/useMangoStore' import DepositModal from './DepositModal' import WithdrawModal from './WithdrawModal' import Button from './Button' import AccountsModal from './AccountsModal' export default function MarginBalances() { const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current) const loadingMangoAccount = useMangoStore( (s) => s.selectedMangoAccount.initialLoad ) const connected = useMangoStore((s) => s.wallet.connected) const [showDepositModal, setShowDepositModal] = useState(false) const [showWithdrawModal, setShowWithdrawModal] = useState(false) const [showAccountsModal, setShowAccountsModal] = useState(false) return ( <> {mangoAccount?.name || 'Mango Account'} setShowAccountsModal(true)} > Change Account {mangoAccount ? ( {mangoAccount?.publicKey.toString()} ) : connected ? ( Deposit funds to get started ) : null} setShowDepositModal(true)} className="w-1/2" disabled={!connected || loadingMangoAccount} > Deposit setShowWithdrawModal(true)} className="ml-4 w-1/2" disabled={!connected || !mangoAccount || loadingMangoAccount} > Withdraw {showDepositModal && ( setShowDepositModal(false)} /> )} {showWithdrawModal && ( setShowWithdrawModal(false)} /> )} {showAccountsModal ? ( setShowAccountsModal(false)} isOpen={showAccountsModal} /> ) : null} > ) }