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 ( { officer.create(password); }} /> ); } if (officer.state === "locked") { return ( { officer.forget(); }} onAccountUnlocked={(pwd) => { officer.tryUnlock(pwd); }} /> ); } throw Error(`unexpected account state ${(officer as any).state}`); }