import { Card } from 'react-bootstrap' import classNames from 'classnames' import styles from '@/styles/wallet.module.css' import Plug from '@/svgs/plug.svg' import Gear from '@/svgs/settings-5-fill.svg' import Link from 'next/link' import RecvIcon from '@/svgs/arrow-left-down-line.svg' import SendIcon from '@/svgs/arrow-right-up-line.svg' import DragIcon from '@/svgs/draggable.svg' import { useWalletImage, useWalletSupport, useWalletStatus, WalletStatus, useProtocolTemplates } from '@/wallets/client/hooks' import { isWallet, urlify, walletDisplayName } from '@/wallets/lib/util' import { Draggable } from '@/wallets/client/components' export function WalletCard ({ wallet, draggable = false, index, ...props }) { const image = useWalletImage(wallet.name) const status = useWalletStatus(wallet) const support = useWalletSupport(wallet) const card = (
{draggable && } {support.receive && } {support.send && }
{image ? : {walletDisplayName(wallet.name)}}
{isWallet(wallet) ? <>configure : <>attach}
) if (draggable) { return ( {card} ) } return card } function WalletLink ({ wallet, children }) { const support = useWalletSupport(wallet) const protocols = useProtocolTemplates(wallet) const firstSend = protocols.find(p => p.send) const firstRecv = protocols.find(p => !p.send) let href = '/wallets' href += isWallet(wallet) ? `/${wallet.id}` : `/${urlify(wallet.name)}` href += support.send ? `/send/${urlify(firstSend.name)}` : `/receive/${urlify(firstRecv.name)}` return {children} } function statusToClass (status) { switch (status) { case WalletStatus.OK: return styles.success case WalletStatus.ERROR: return styles.error case WalletStatus.WARNING: return styles.warning case WalletStatus.DISABLED: return styles.disabled } }