-
Notifications
You must be signed in to change notification settings - Fork 2
/
CreateAccount.tsx
64 lines (57 loc) · 1.8 KB
/
CreateAccount.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import withSuspense from "@/functions/withSuspense";
import { useStore } from "@/stores/store";
import { Web3BaseWalletAccount } from "@theqrl/web3";
import { observer } from "mobx-react-lite";
import { lazy, useState } from "react";
import { AccountCreationForm } from "./AccountCreationForm/AccountCreationForm";
import { AccountCreationSuccess } from "./AccountCreationSuccess/AccountCreationSuccess";
const MnemonicDisplay = withSuspense(
lazy(
() =>
import(
"@/components/ZondWallet/Body/CreateAccount/MnemonicDisplay/MnemonicDisplay"
),
),
);
const CreateAccount = observer(() => {
const { zondStore } = useStore();
const { setActiveAccount } = zondStore;
const [account, setAccount] = useState<Web3BaseWalletAccount>();
const [hasAccountCreated, setHasAccountCreated] = useState(false);
const [hasMnemonicNoted, setHasMnemonicNoted] = useState(false);
const onAccountCreated = (account?: Web3BaseWalletAccount) => {
window.scrollTo(0, 0);
if (account) {
setAccount(account);
setActiveAccount(account?.address);
setHasAccountCreated(true);
}
};
const onMnemonicNoted = () => {
window.scrollTo(0, 0);
setHasMnemonicNoted(true);
};
return (
<>
<img
className="fixed z-0 h-96 w-96 -translate-x-8 scale-150 overflow-hidden opacity-30"
src="tree.svg"
/>
<div className="relative z-10 p-8">
{hasAccountCreated ? (
hasMnemonicNoted ? (
<AccountCreationSuccess account={account} />
) : (
<MnemonicDisplay
account={account}
onMnemonicNoted={onMnemonicNoted}
/>
)
) : (
<AccountCreationForm onAccountCreated={onAccountCreated} />
)}
</div>
</>
);
});
export default CreateAccount;