add how-to modal for creating multi accounts
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import { Button } from '@mui/material';
|
||||
import { AccountEntry } from 'src/types';
|
||||
import { AccountAvatar } from './AccountAvatar';
|
||||
|
||||
export const AccountOverview = ({ account, onClick }: { account: AccountEntry; onClick: () => void }) => (
|
||||
<Button
|
||||
startIcon={<AccountAvatar name={account.id} />}
|
||||
sx={{ color: 'nym.text.dark' }}
|
||||
onClick={onClick}
|
||||
disableRipple
|
||||
>
|
||||
{account.id}
|
||||
</Button>
|
||||
);
|
||||
@@ -1,25 +1,18 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Button } from '@mui/material';
|
||||
import { AccountsContext } from 'src/context';
|
||||
import React, { useContext, useState } from 'react';
|
||||
import { AccountsContext, AppContext } from 'src/context';
|
||||
import { EditAccountModal } from './EditAccountModal';
|
||||
import { AddAccountModal } from './AddAccountModal';
|
||||
import { AccountsModal } from './AccountsModal';
|
||||
import { AccountAvatar } from './AccountAvatar';
|
||||
import { MnemonicModal } from './MnemonicModal';
|
||||
import { AccountOverview } from './AccountOverview';
|
||||
import { MultiAccountHowTo } from './MultiAccountHowTo';
|
||||
|
||||
export const Accounts = () => {
|
||||
const { accounts, selectedAccount, setDialogToDisplay } = useContext(AccountsContext);
|
||||
|
||||
return accounts && selectedAccount ? (
|
||||
<>
|
||||
<Button
|
||||
startIcon={<AccountAvatar name={selectedAccount.id} />}
|
||||
sx={{ color: 'nym.text.dark' }}
|
||||
onClick={() => setDialogToDisplay('Accounts')}
|
||||
disableRipple
|
||||
>
|
||||
{selectedAccount.id}
|
||||
</Button>
|
||||
<AccountOverview account={selectedAccount} onClick={() => setDialogToDisplay('Accounts')} />
|
||||
<AccountsModal />
|
||||
<AddAccountModal />
|
||||
<EditAccountModal />
|
||||
@@ -27,3 +20,17 @@ export const Accounts = () => {
|
||||
</>
|
||||
) : null;
|
||||
};
|
||||
|
||||
export const SingleAccount = () => {
|
||||
const [showHowToDialog, setShowHowToDialog] = useState(false);
|
||||
const { clientDetails } = useContext(AppContext);
|
||||
return (
|
||||
<>
|
||||
<AccountOverview
|
||||
account={{ id: 'Account 1', address: clientDetails?.client_address || '' }}
|
||||
onClick={() => setShowHowToDialog(true)}
|
||||
/>
|
||||
<MultiAccountHowTo show={showHowToDialog} handleClose={() => setShowHowToDialog(false)} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { Alert, Box, Dialog, DialogContent, DialogTitle, IconButton, Stack, Typography } from '@mui/material';
|
||||
import { Close } from '@mui/icons-material';
|
||||
|
||||
const passwordCreationSteps = [
|
||||
'Log out',
|
||||
'When signing in, select “Sign in with mnemonic”',
|
||||
'On the next screen click “Create a password for your account”',
|
||||
'Sign in to wallet with your new password',
|
||||
'Now you can create multiple accounts',
|
||||
];
|
||||
|
||||
export const MultiAccountHowTo = ({ show, handleClose }: { show: boolean; handleClose: () => void }) => (
|
||||
<Dialog open={show} onClose={handleClose} fullWidth hideBackdrop>
|
||||
<DialogTitle>
|
||||
<Box display="flex" justifyContent="space-between" alignItems="center">
|
||||
<Typography variant="h6">Multi accounts</Typography>
|
||||
<IconButton onClick={handleClose}>
|
||||
<Close />
|
||||
</IconButton>
|
||||
</Box>
|
||||
<Typography variant="body1" sx={{ color: 'grey.600' }}>
|
||||
How to set up multiple accounts
|
||||
</Typography>
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Alert severity="warning" icon={false}>
|
||||
<Typography>In order to create multiple accounts your wallet need password.</Typography>
|
||||
<Typography>Follow steps below to create password.</Typography>
|
||||
</Alert>
|
||||
<Typography>How to create a password for your account</Typography>
|
||||
{passwordCreationSteps.map((step, index) => (
|
||||
<Typography key={step}>{`${index + 1}. ${step}`}</Typography>
|
||||
))}
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
@@ -1,9 +1,16 @@
|
||||
import React from 'react';
|
||||
import { AccountsProvider } from 'src/context';
|
||||
import { Accounts } from './Accounts';
|
||||
import React, { useContext } from 'react';
|
||||
import { AccountsProvider, AppContext } from 'src/context';
|
||||
import { Accounts, SingleAccount } from './Accounts';
|
||||
|
||||
export const MultiAccounts = () => (
|
||||
<AccountsProvider>
|
||||
<Accounts />
|
||||
</AccountsProvider>
|
||||
);
|
||||
export const MultiAccounts = () => {
|
||||
const { loginType } = useContext(AppContext);
|
||||
|
||||
if (loginType === 'password') {
|
||||
return (
|
||||
<AccountsProvider>
|
||||
<Accounts />
|
||||
</AccountsProvider>
|
||||
);
|
||||
}
|
||||
return <SingleAccount />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user