* derive accounts for master account * Add master field to account context (#75) * add master field to account context * add tests for buildHierarchy function * Fix selection master account * Add path numeration for derived accounts (#76) * add path numeration for derived accounts * Fix PR notices. Add util for Path generation. * Correct test Co-authored-by: Ivan Rukhavets <ivanruch@gmail.com> Co-authored-by: VladStarostenko <vlad@DESKTOP-V12SRE8.localdomain> * Add arrows to buttons (#77) * Add parent label (#80) * refactor parent label * refactor parent label * refactor parent label Co-authored-by: Ivan Rukhavets <ivanruch@gmail.com> * Implement new create account flow (#78) * Add copied snackbar (#83) * refactor parent label * Add "Copied" snackbar * Add "Copied" snackbar * Hide suri input behind a spoiler (#84) * Disallow changing parent account when 'Derive' option is clicked (#82) * Add lock to path input (#85) Co-authored-by: VladStarostenko <38181661+VladStarostenko@users.noreply.github.com> Co-authored-by: VladStarostenko <vlad@DESKTOP-V12SRE8.localdomain>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
// Copyright 2019-2020 @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, { useCallback, useState } from 'react';
|
|
import { Address, BackButton, ButtonArea, NextStepButton, VerticalSpace } from '../..//components';
|
|
import { Name, Password } from '../../partials';
|
|
|
|
interface Props {
|
|
address: string;
|
|
onBackClick: () => void;
|
|
onCreate: (name: string, password: string) => void | Promise<void | boolean>;
|
|
}
|
|
|
|
function AccountName ({ address, onBackClick, onCreate }: Props): React.ReactElement<Props> {
|
|
const [name, setName] = useState<string | null>(null);
|
|
const [password, setPassword] = useState<string | null>(null);
|
|
|
|
const _onCreate = useCallback(() => name && password && onCreate(name, password), [name, password, onCreate]);
|
|
|
|
return (
|
|
<>
|
|
<Name
|
|
isFocused
|
|
onChange={setName}
|
|
/>
|
|
{name && <Password onChange={setPassword} />}
|
|
{name && password && (
|
|
<Address
|
|
address={address}
|
|
name={name}
|
|
/>
|
|
)}
|
|
<VerticalSpace />
|
|
<ButtonArea>
|
|
<BackButton onClick={onBackClick} />
|
|
<NextStepButton
|
|
data-button-action='add new root'
|
|
isDisabled={!password || !name}
|
|
onClick={_onCreate}
|
|
>
|
|
Add the account with the generated seed
|
|
</NextStepButton>
|
|
</ButtonArea>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default AccountName;
|