import { getGetServerSideProps } from '@/api/ssrApollo' import { Button } from 'react-bootstrap' import { useWallets, useTemplates, DndProvider, Status, useStatus } from '@/wallets/client/context' import { WalletCard, WalletLayout, WalletLayoutHeader, WalletLayoutLink, WalletLayoutSubHeader } from '@/wallets/client/components' import styles from '@/styles/wallet.module.css' import { usePassphrasePrompt, useShowPassphrase, useSetWalletPriorities } from '@/wallets/client/hooks' import { WalletSearch } from '@/wallets/client/components/search' import { useMemo, useState } from 'react' import { walletDisplayName } from '@/wallets/lib/util' import Moon from '@/svgs/moon-fill.svg' export const getServerSideProps = getGetServerSideProps({ authRequired: true }) export default function Wallet () { const wallets = useWallets() const status = useStatus() const [showWallets, setShowWallets] = useState(false) const templates = useTemplates() const showPassphrase = useShowPassphrase() const passphrasePrompt = usePassphrasePrompt() const setWalletPriorities = useSetWalletPriorities() const [searchFilter, setSearchFilter] = useState(() => (text) => true) const { wallets: filteredWallets, templates: filteredTemplates } = useMemo(() => { const walletFilter = ({ name }) => searchFilter(walletDisplayName(name)) || searchFilter(name) return { wallets: wallets.filter(walletFilter), templates: templates.filter(walletFilter) } }, [wallets, templates, searchFilter]) if (status === Status.LOADING_WALLETS) { return ( loading wallets ) } if (status === Status.PASSPHRASE_REQUIRED) { return ( unlock wallets your passphrase is required ) } if (status === Status.WALLETS_UNAVAILABLE) { return ( wallets unavailable this device does not support storage of cryptographic keys via IndexedDB ) } if (status instanceof Error) { return ( failed to load wallets {status.message} ) } if (status === Status.NO_WALLETS && !showWallets) { return ( setShowWallets(true)} size='md' variant='secondary' >attach wallet attach a wallet to send and receive sats ) } return ( wallets use real bitcoin wallet logs • settings {showPassphrase && ( <> • passphrase > )} {filteredWallets.length > 0 && ( <> {filteredWallets.map((wallet, index) => ( ))} > )} {filteredTemplates.map((w, i) => )} ) }