diff options
author | Sebastian <sebasjm@gmail.com> | 2023-05-26 16:52:30 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-05-26 16:52:30 -0300 |
commit | 69b66e715eae039330898f470a8993d1d154b583 (patch) | |
tree | 794cbd7ba6ae8657dbadc96b0576f33ce488546b /packages/exchange-backoffice-ui/src/pages/HandleAccountNotReady.tsx | |
parent | be27647ff73d1529372a80c3e145f3ee4f229a17 (diff) | |
download | wallet-core-69b66e715eae039330898f470a8993d1d154b583.tar.xz |
account as hook
Diffstat (limited to 'packages/exchange-backoffice-ui/src/pages/HandleAccountNotReady.tsx')
-rw-r--r-- | packages/exchange-backoffice-ui/src/pages/HandleAccountNotReady.tsx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/exchange-backoffice-ui/src/pages/HandleAccountNotReady.tsx b/packages/exchange-backoffice-ui/src/pages/HandleAccountNotReady.tsx new file mode 100644 index 000000000..b0c430875 --- /dev/null +++ b/packages/exchange-backoffice-ui/src/pages/HandleAccountNotReady.tsx @@ -0,0 +1,31 @@ +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 + onAccountUnlocked={(pwd) => { + officer.tryUnlock(pwd); + }} + /> + ); + } + throw Error(`unexpected account state ${(officer as any).state}`); +} |