Skip to content

Commit

Permalink
feat: move function outside html
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda committed Aug 13, 2024
1 parent 444862a commit 49134c4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions apps/wallet/src/ui/app/pages/accounts/ImportPassphrasePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<PageTemplate title="Import Mnemonic" isTitleCentered showBackButton>
Expand All @@ -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}
/>
</div>
</div>
Expand Down
26 changes: 13 additions & 13 deletions apps/wallet/src/ui/app/pages/accounts/ImportPrivateKeyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<PageTemplate title="Import Private Key" isTitleCentered showBackButton>
<div className="flex h-full w-full flex-col items-center ">
<div className="w-full grow">
<ImportPrivateKeyForm
onSubmit={({ privateKey }) => {
setAccountsFormValues({
type: AccountsFormType.ImportPrivateKey,
keyPair: privateKey,
});
navigate(
`/accounts/protect-account?${new URLSearchParams({
accountsFormType: AccountsFormType.ImportPrivateKey,
}).toString()}`,
);
}}
/>
<ImportPrivateKeyForm onSubmit={handleOnSubmit} />
</div>
</div>
</PageTemplate>
Expand Down

0 comments on commit 49134c4

Please sign in to comment.