// 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, { useState } from 'react'; import { Button, InputAddress, Input, Modal, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import ValidationSessionKey from './InputValidationSessionKey'; import translate from '../../translate'; interface Props extends I18nProps { controllerId: string; isOpen: boolean; onClose: () => void; sessionIds: string[]; stashId: string; } const EMPTY_PROOF = new Uint8Array(); function SetSessionKey ({ controllerId, isOpen, onClose, sessionIds, stashId, t }: Props): React.ReactElement | null { const { isSubstrateV2 } = useApi(); const [keysError, setKeysError] = useState(null); const [keys, setKeys] = useState( isSubstrateV2 ? null : sessionIds[0] || controllerId ); if (!isOpen) { return null; } const hasError = isSubstrateV2 ? !keys : (!keys || !!keysError); return ( {isSubstrateV2 ? ( ) : ( <> ) }