diff options
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}`); +} |