diff --git a/nym-wallet/src/components/Accounts/AddAccountModal.tsx b/nym-wallet/src/components/Accounts/AddAccountModal.tsx index 9c4bea6ca4..60d1963618 100644 --- a/nym-wallet/src/components/Accounts/AddAccountModal.tsx +++ b/nym-wallet/src/components/Accounts/AddAccountModal.tsx @@ -12,7 +12,10 @@ import { TextField, Typography, } from '@mui/material'; -import { Add, Close } from '@mui/icons-material'; +import { Check, Close, ContentCopySharp } from '@mui/icons-material'; +import { useClipboard } from 'use-clipboard-copy'; + +const createAccountSteps = ['Save and copy mnemonic for your new account', 'Name your new account']; const passwordCreationSteps = [ 'Log out', @@ -22,21 +25,92 @@ const passwordCreationSteps = [ 'Now you can create multiple accounts', ]; -const NoPassword = () => ( - - - - You can’t add new accounts if your wallet doesn’t have a password. - - Follow steps below to create password. - - How to create password to your account - {passwordCreationSteps.map((step, i) => ( - {`${i + 1}. ${step}`} - ))} - +const NoPassword = ({ onClose }: { onClose: () => void }) => ( + + + + + + You can’t add new accounts if your wallet doesn’t have a password. + + Follow steps below to create password. + + How to create password to your account + {passwordCreationSteps.map((step, i) => ( + {`${i + 1}. ${step}`} + ))} + + + + + + ); +const MnemonicStep = ({ mnemonic, onSave }: { mnemonic: string; onSave: () => void }) => { + const { copy, copied } = useClipboard({ copiedTimeout: 5000 }); + return ( + + + + + + Below is your 24 word mnemonic, make sure to store it in a safe place for accessing your wallet in the + future + + + + + + + + + + + + ); +}; + +const NameAccount = ({ onAdd }: { onAdd: (value: string) => void }) => { + const [value, setValue] = useState(''); + return ( + + + setValue(e.target.value)} fullWidth /> + + + + + + ); +}; + export const AddAccountModal = ({ show, withoutPassword, @@ -48,11 +122,7 @@ export const AddAccountModal = ({ onClose: () => void; onAdd: (accountName: string) => void; }) => { - const [accountName, setAccountName] = useState(''); - - useEffect(() => { - if (!show) setAccountName(''); - }, [show]); + const [step, setStep] = useState(0); return ( @@ -63,38 +133,30 @@ export const AddAccountModal = ({ - - New wallet address - + {!withoutPassword && ( + + {`Step ${step + 1}/${createAccountSteps.length}`} + + )} + {createAccountSteps[step]} - - - {withoutPassword ? ( - - ) : ( - setAccountName(e.target.value)} - autoFocus - /> - )} - - - - - + {withoutPassword && } + {!withoutPassword && + (() => { + switch (step) { + case 0: + return ( + setStep((s) => s + 1)} + /> + ); + case 1: + return ; + default: + return null; + } + })()} ); }; diff --git a/nym-wallet/src/components/Accounts/index.tsx b/nym-wallet/src/components/Accounts/index.tsx index 44c4bf8d85..ad3f635455 100644 --- a/nym-wallet/src/components/Accounts/index.tsx +++ b/nym-wallet/src/components/Accounts/index.tsx @@ -4,9 +4,9 @@ import { v4 as uuidv4 } from 'uuid'; import { TAccount } from 'src/types'; import { EditAccountModal } from './EditAccountModal'; import { AddAccountModal } from './AddAccountModal'; -import { AccountColor } from './AccountColor'; import { AccountsModal } from './AccountsModal'; import { ImportAccountModal } from './ImportAccountModal'; +import { AccountAvatar } from './AccountAvatar'; export type TDialog = 'Accounts' | 'Add' | 'Edit' | 'Import'; @@ -24,10 +24,9 @@ export const Accounts = ({ storedAccounts }: { storedAccounts: TAccount[] }) => return ( <>