aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx')
-rw-r--r--packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx34
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx b/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx
new file mode 100644
index 000000000..05fd0a019
--- /dev/null
+++ b/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx
@@ -0,0 +1,34 @@
+import { VNode, h } from "preact";
+import { OfficerNotReady } from "../hooks/useOfficer.js";
+import { CreateAccount } from "./CreateAccount.js";
+import { UnlockAccount } from "./UnlockAccount.js";
+
+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={(pwd) => {
+ officer.tryUnlock(pwd);
+ }}
+ />
+ );
+ }
+ throw Error(`unexpected account state ${(officer as any).state}`);
+}