From c680f5aa71b08e978444df07f93c381f9d47ab82 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 5 Jun 2023 10:04:09 -0300
Subject: rename aml

---
 .../src/pages/HandleAccountNotReady.tsx            | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx

(limited to 'packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx')

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}`);
+}
-- 
cgit v1.2.3

