// Copyright 2017-2019 @polkadot/ui-staking 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 { I18nProps } from '@polkadot/react-components/types'; import React from 'react'; import { Button, Icon, InputAddress, Modal, TxButton, TxComponent } from '@polkadot/react-components'; import { withCalls, withMulti } from '@polkadot/react-api'; import translate from '../../translate'; import detectUnsafe from '../../unsafeChains'; import InputValidationController from '../Account/InputValidationController'; interface Props extends I18nProps { defaultControllerId: string; isUnsafeChain?: boolean; isValidating?: boolean; onClose: () => void; stashId: string; } interface State { controllerError: string | null; controllerId: string | null; } class SetControllerAccount extends TxComponent { public constructor (props: Props) { super(props); this.state = { controllerError: null, controllerId: null }; } public render (): React.ReactNode { const { defaultControllerId, isUnsafeChain, onClose, stashId, t } = this.props; const { controllerError, controllerId } = this.state; const canSubmit = isUnsafeChain || (!controllerError && !!controllerId && (defaultControllerId !== controllerId)); return ( {this.renderContent()}