From e6ae3f10619f28a22a79de7c060afc15edeb8157 Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Fri, 23 Jun 2023 03:41:52 -0400 Subject: [PATCH] feat: show message to allow an account if none are enabled (#278) --- frontend/src/components/ConnectWallet.tsx | 107 ++++++++++++---------- 1 file changed, 58 insertions(+), 49 deletions(-) diff --git a/frontend/src/components/ConnectWallet.tsx b/frontend/src/components/ConnectWallet.tsx index 368e527..132625f 100644 --- a/frontend/src/components/ConnectWallet.tsx +++ b/frontend/src/components/ConnectWallet.tsx @@ -1,7 +1,7 @@ -import { useInstalledWallets, useUninstalledWallets, useWallet } from "useink"; -import { Button } from "./Button"; -import { Modal } from "./Modal"; -import { useEffect } from "react"; +import { useInstalledWallets, useUninstalledWallets, useWallet } from 'useink'; +import { Button } from './Button'; +import { Modal } from './Modal'; +import { useEffect } from 'react'; type Props = { show: boolean; @@ -9,53 +9,62 @@ type Props = { }; export const ConnectWallet: React.FC = ({ show, onClose }) => { - const { account, connect } = useWallet(); - const installed = useInstalledWallets(); - const uninstalled = useUninstalledWallets(); + const { account, connect, accounts } = useWallet(); + const installed = useInstalledWallets(); + const uninstalled = useUninstalledWallets(); - useEffect(() => { account && onClose() }, [account, onClose]) + useEffect(() => { + account && onClose(); + }, [account, onClose]); - return ( - -

Connect Wallet

+ const isConnectedWithZeroEnabledAccounts = !account && accounts?.length === 0; - {!account && installed.length > 0 && ( + return ( + +

Connect Wallet

+ + {isConnectedWithZeroEnabledAccounts ? ( +

Please open your wallet settings and enable at least one account for this URL.

+ ) : ( + !account && + installed.length > 0 && (
    - {installed.map((w => ( -
  • - -
  • - )))} + {installed.map((w) => ( +
  • + +
  • + ))}
- )} - - {!account && uninstalled.length && installed.length === 0 && ( - <> -

- Please install one of these supported wallets. -

- -
    - {uninstalled.map((w => ( -
  • - - -
  • - )))} -
- - )} - - -
- ) -} + ) + )} + + {!account && uninstalled.length && installed.length === 0 && ( + <> +

Please install one of these supported wallets.

+ +
    + {uninstalled.map((w) => ( +
  • + +
  • + ))} +
+ + )} + + +
+ ); +};