import { TranslatedString, UnwrapKeyError } from "@gnu-taler/taler-util"; import { notifyError, notifyInfo, useTranslationContext } from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { createNewForm } from "../handlers/forms.js"; export function UnlockAccount({ onAccountUnlocked, onRemoveAccount, }: { onAccountUnlocked: (password: string) => Promise; onRemoveAccount: () => void; }): VNode { const { i18n } = useTranslationContext() const Form = createNewForm<{ password: string; }>(); return (

Account locked

Your account is normally locked anytime you reload. To unlock type your password again.

{ try { await onAccountUnlocked(v.password!); notifyInfo("Account unlocked" as TranslatedString); } catch (e) { if (e instanceof UnwrapKeyError) { notifyError( "Could not unlock account" as any, e.message as any, ); } else { throw e; } } }} >
); }