blob: ff800ebdcd9273ae94b596b2c85316b5ff7accf6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { VNode, h } from "preact";
import { OfficerNotReady } from "../hooks/useOfficer.js";
import { CreateAccount } from "./CreateAccount.js";
import { UnlockAccount } from "./UnlockAccount.js";
import { assertUnreachable } from "@gnu-taler/taler-util";
export function HandleAccountNotReady({
officer,
}: {
officer: OfficerNotReady;
}): VNode {
if (officer.state === "not-found") {
return (
<CreateAccount
onNewAccount={(password) => {
officer.create(password);
}}
/>
);
}
if (officer.state === "locked") {
return (
<UnlockAccount
onRemoveAccount={() => {
officer.forget();
}}
onAccountUnlocked={async (pwd) => {
await officer.tryUnlock(pwd);
}}
/>
);
}
assertUnreachable(officer)
}
|