diff --git a/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx b/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx new file mode 100644 index 0000000000..0d59306459 --- /dev/null +++ b/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx @@ -0,0 +1,76 @@ +import React, { useContext, useState } from 'react'; +import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Typography } from '@mui/material'; +import { Add, ArrowDownwardSharp, Close } from '@mui/icons-material'; +import { AccountsContext } from 'src/context'; +import { AccountItem } from '../AccountItem'; +import { ConfirmPasswordModal } from './ConfirmPasswordModal'; + +export const AccountsModal = () => { + const { accounts, dialogToDisplay, setDialogToDisplay, setError, handleSelectAccount, selectedAccount } = + useContext(AccountsContext); + const [accountToSwitchTo, setAccountToSwitchTo] = useState(); + + const handleClose = () => { + setDialogToDisplay(undefined); + setError(undefined); + setAccountToSwitchTo(undefined); + }; + + if (accountToSwitchTo) + return ( + { + handleClose(); + setDialogToDisplay('Accounts'); + }} + onConfirm={async (password) => { + const isSuccessful = await handleSelectAccount({ password, accountName: accountToSwitchTo }); + if (isSuccessful) handleClose(); + }} + /> + ); + + return ( + + + + Accounts + + + + + + Switch between accounts + + + + {accounts?.map(({ id, address }) => ( + { + if (selectedAccount?.id !== id) { + setAccountToSwitchTo(id); + } + }} + /> + ))} + + + + + + + ); +};