import React, { FunctionComponent, useCallback } from 'react' import { LinkIcon } from '@heroicons/react/outline' import useMangoStore from '../stores/useMangoStore' import { MoveIcon } from './icons' import EmptyState from './EmptyState' import { useTranslation } from 'next-i18next' import { handleWalletConnect } from 'components/ConnectWalletButton' import { useWallet } from '@solana/wallet-adapter-react' import { useRouter } from 'next/router' interface FloatingElementProps { className?: string showConnect?: boolean } const FloatingElement: FunctionComponent = ({ className, children, showConnect, }) => { const { t } = useTranslation('common') const { wallet, connected } = useWallet() const { uiLocked } = useMangoStore((s) => s.settings) const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const router = useRouter() const { pubkey } = router.query const handleConnect = useCallback(() => { if (wallet) { handleWalletConnect(wallet) } }, [wallet]) return (
{!connected && showConnect && !pubkey ? (
} onClickButton={handleConnect} title={t('connect-wallet')} />
) : null} {!uiLocked ? (
{t('reposition')}
) : null} {children}
) } export default FloatingElement