From e6ffbc468b2db1b9a009725102e18caf71270c76 Mon Sep 17 00:00:00 2001 From: Fouad Date: Wed, 15 Jun 2022 16:50:35 +0100 Subject: [PATCH] Wallet: create forgot password page (#1367) * create forgot password page * navigate back * add rust work * pr update --- .../src/pages/auth/pages/confirm-mnemonic.tsx | 2 +- .../src/pages/auth/pages/existing-account.tsx | 2 +- .../src/pages/auth/pages/forgot-password.tsx | 43 +++++++++++++++++++ .../src/pages/auth/pages/signin-mnemonic.tsx | 11 +++-- .../src/pages/auth/pages/signin-password.tsx | 11 +++-- nym-wallet/src/requests/account.ts | 2 + nym-wallet/src/routes/auth.tsx | 2 + 7 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 nym-wallet/src/pages/auth/pages/forgot-password.tsx diff --git a/nym-wallet/src/pages/auth/pages/confirm-mnemonic.tsx b/nym-wallet/src/pages/auth/pages/confirm-mnemonic.tsx index 73a8cec939..0460dfa71b 100644 --- a/nym-wallet/src/pages/auth/pages/confirm-mnemonic.tsx +++ b/nym-wallet/src/pages/auth/pages/confirm-mnemonic.tsx @@ -16,7 +16,7 @@ export const ConfirmMnemonic = () => { }, [localMnemonic]); return ( - + setLocalMnemonic(mnc)} error={error} /> - diff --git a/nym-wallet/src/pages/auth/pages/forgot-password.tsx b/nym-wallet/src/pages/auth/pages/forgot-password.tsx new file mode 100644 index 0000000000..d0f614856a --- /dev/null +++ b/nym-wallet/src/pages/auth/pages/forgot-password.tsx @@ -0,0 +1,43 @@ +/* eslint-disable react/no-unused-prop-types */ +import React from 'react'; +import { useNavigate } from 'react-router-dom'; +import { Button, Stack, Typography } from '@mui/material'; +import { useSnackbar } from 'notistack'; +import { archiveWalletFile } from 'src/requests'; +import { Console } from 'src/utils/console'; +import { Subtitle } from '../components'; + +export const ForgotPassword = () => { + const navigate = useNavigate(); + const { enqueueSnackbar } = useSnackbar(); + return ( + <> + + + + or + + + + + ); +}; diff --git a/nym-wallet/src/pages/auth/pages/signin-mnemonic.tsx b/nym-wallet/src/pages/auth/pages/signin-mnemonic.tsx index e1cb8d2d15..092b67a7a5 100644 --- a/nym-wallet/src/pages/auth/pages/signin-mnemonic.tsx +++ b/nym-wallet/src/pages/auth/pages/signin-mnemonic.tsx @@ -18,7 +18,7 @@ export const SignInMnemonic = () => { setPasswordExists(hasPassword); }; - const handlePageChange = (page: string) => { + const handlePageChange = (page: any) => { setError(undefined); navigate(page); }; @@ -31,14 +31,19 @@ export const SignInMnemonic = () => { -
logIn({ type: 'mnemonic', value: mnemonic })}> + { + e.preventDefault(); + logIn({ type: 'mnemonic', value: mnemonic }); + }} + > setMnemonic(mnc)} error={error} /> - {!passwordExists && ( diff --git a/nym-wallet/src/pages/auth/pages/signin-password.tsx b/nym-wallet/src/pages/auth/pages/signin-password.tsx index 27b6394059..6a61cff40a 100644 --- a/nym-wallet/src/pages/auth/pages/signin-password.tsx +++ b/nym-wallet/src/pages/auth/pages/signin-password.tsx @@ -14,7 +14,12 @@ export const SignInPassword = () => { - logIn({ type: 'password', value: password })}> + { + e.preventDefault(); + logIn({ type: 'password', value: password }); + }} + > { color="info" onClick={() => { setError(undefined); - navigate('/sign-in-mnemonic'); + navigate('/forgot-password'); }} size="small" > - Forgotten password? + Forgot password? diff --git a/nym-wallet/src/requests/account.ts b/nym-wallet/src/requests/account.ts index 11032682b8..8ba3fc75b5 100644 --- a/nym-wallet/src/requests/account.ts +++ b/nym-wallet/src/requests/account.ts @@ -38,5 +38,7 @@ export const removeAccount = async ({ password, accountName }: { password: strin export const listAccounts = async () => invokeWrapper('list_accounts'); +export const archiveWalletFile = async () => invokeWrapper('archive_wallet_file'); + export const showMnemonicForAccount = async ({ password, accountName }: { password: string; accountName: string }) => invokeWrapper('show_mnemonic_for_account_in_password', { password, accountId: accountName }); diff --git a/nym-wallet/src/routes/auth.tsx b/nym-wallet/src/routes/auth.tsx index a8183bfbdd..a08428d3ac 100644 --- a/nym-wallet/src/routes/auth.tsx +++ b/nym-wallet/src/routes/auth.tsx @@ -13,6 +13,7 @@ import { ConnectPassword, } from 'src/pages/auth/pages'; import { ConfirmMnemonic } from 'src/pages/auth/pages/confirm-mnemonic'; +import { ForgotPassword } from 'src/pages/auth/pages/forgot-password'; import { AuthTheme } from 'src/theme'; export const AuthRoutes = () => ( @@ -29,6 +30,7 @@ export const AuthRoutes = () => ( } /> } /> } /> + } />