// Copyright 2019 @polkadot/extension-ui authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import React, { useContext, useEffect, useState } from 'react'; import { ActionContext, Address, Button, Header, Loading, TextArea } from '../components'; import { createAccount, createSeed } from '../messaging'; import { Back, Name, Password } from '../partials'; type Props = {}; export default function Create (): React.ReactElement { const onAction = useContext(ActionContext); const [account, setAccount] = useState(null); const [name, setName] = useState(null); const [password, setPassword] = useState(null); useEffect((): void => { createSeed() .then(setAccount) .catch((error: Error) => console.error(error)); }, []); // FIXME Duplicated between here and Import.tsx const onCreate = (): void => { // this should always be the case if (name && password && account) { createAccount(name, password, account.seed) .then((): void => onAction('/')) .catch((error: Error) => console.error(error)); } }; return (
{account && ( <>