aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-06-05 10:04:09 -0300
committerSebastian <sebasjm@gmail.com>2023-06-05 10:04:09 -0300
commitc680f5aa71b08e978444df07f93c381f9d47ab82 (patch)
tree81903fac003bb1e202cf69551e06ba41a6e960a5 /packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx
parentdf53866e6b148ea5fd2ab57e906a4aa36b535ed3 (diff)
downloadwallet-core-c680f5aa71b08e978444df07f93c381f9d47ab82.tar.xz
rename aml
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}`);
+}