From 49134c4475538e1c4b3123b5d609e5799a5b4119 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Tue, 13 Aug 2024 09:12:09 +0200 Subject: [PATCH] feat: move function outside html --- .../pages/accounts/ImportPassphrasePage.tsx | 26 +++++++++---------- .../pages/accounts/ImportPrivateKeyPage.tsx | 26 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/wallet/src/ui/app/pages/accounts/ImportPassphrasePage.tsx b/apps/wallet/src/ui/app/pages/accounts/ImportPassphrasePage.tsx index 19d670986b2..cbbf8377457 100644 --- a/apps/wallet/src/ui/app/pages/accounts/ImportPassphrasePage.tsx +++ b/apps/wallet/src/ui/app/pages/accounts/ImportPassphrasePage.tsx @@ -24,6 +24,18 @@ export function ImportPassphrasePage() { setIsTextVisible(!isTextVisible); } + function handleOnSubmit({ recoveryPhrase }: { recoveryPhrase: string[] }) { + setFormValues({ + type: AccountsFormType.ImportMnemonic, + entropy: entropyToSerialized(mnemonicToEntropy(recoveryPhrase.join(' '))), + }); + navigate( + `/accounts/protect-account?${new URLSearchParams({ + accountsFormType: AccountsFormType.ImportMnemonic, + }).toString()}`, + ); + } + const BUTTON_ICON_CLASSES = 'w-5 h-5 text-neutral-10'; return ( @@ -47,19 +59,7 @@ export function ImportPassphrasePage() { cancelButtonText="Back" submitButtonText="Add Profile" isTextVisible={isTextVisible} - onSubmit={({ recoveryPhrase }) => { - setFormValues({ - type: AccountsFormType.ImportMnemonic, - entropy: entropyToSerialized( - mnemonicToEntropy(recoveryPhrase.join(' ')), - ), - }); - navigate( - `/accounts/protect-account?${new URLSearchParams({ - accountsFormType: AccountsFormType.ImportMnemonic, - }).toString()}`, - ); - }} + onSubmit={handleOnSubmit} /> diff --git a/apps/wallet/src/ui/app/pages/accounts/ImportPrivateKeyPage.tsx b/apps/wallet/src/ui/app/pages/accounts/ImportPrivateKeyPage.tsx index eaacdaf54e5..86d9b4ac6c9 100644 --- a/apps/wallet/src/ui/app/pages/accounts/ImportPrivateKeyPage.tsx +++ b/apps/wallet/src/ui/app/pages/accounts/ImportPrivateKeyPage.tsx @@ -15,23 +15,23 @@ export function ImportPrivateKeyPage() { const navigate = useNavigate(); const [, setAccountsFormValues] = useAccountsFormContext(); + function handleOnSubmit({ privateKey }: { privateKey: string }) { + setAccountsFormValues({ + type: AccountsFormType.ImportPrivateKey, + keyPair: privateKey, + }); + navigate( + `/accounts/protect-account?${new URLSearchParams({ + accountsFormType: AccountsFormType.ImportPrivateKey, + }).toString()}`, + ); + } + return (
- { - setAccountsFormValues({ - type: AccountsFormType.ImportPrivateKey, - keyPair: privateKey, - }); - navigate( - `/accounts/protect-account?${new URLSearchParams({ - accountsFormType: AccountsFormType.ImportPrivateKey, - }).toString()}`, - ); - }} - /> +