// Copyright 2017-2020 @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 React, { useState } from 'react'; import { Button, ButtonCancel, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import ValidationSessionKey from './InputValidationSessionKey'; import { useTranslation } from '../../translate'; interface Props { controllerId: string; isOpen: boolean; onClose: () => void; sessionIds: string[]; stashId: string; } const EMPTY_PROOF = new Uint8Array(); export default function SetSessionKey ({ controllerId, isOpen, onClose, sessionIds, stashId }: Props): React.ReactElement | null { const { t } = useTranslation(); 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 ? ( ) : ( <> ) } ); }