import React from 'react'; import { connect } from 'react-redux'; import { AppState } from 'reducers'; import translate, { TranslateType } from 'translations'; import WalletDecrypt, { DisabledWallets } from 'components/WalletDecrypt'; import { IWallet } from 'libs/wallet/IWallet'; import closeIcon from 'assets/images/close.svg'; import './UnlockHeader.scss'; interface Props { title: TranslateType; wallet: IWallet; disabledWallets?: DisabledWallets; showGenerateLink?: boolean; } interface State { isExpanded: boolean; } export class UnlockHeader extends React.PureComponent { public state = { isExpanded: !this.props.wallet }; public componentDidUpdate(prevProps: Props) { if (this.props.wallet !== prevProps.wallet) { this.setState({ isExpanded: !this.state.isExpanded }); } } public render() { const { title, wallet, disabledWallets, showGenerateLink } = this.props; const { isExpanded } = this.state; return (

{title}

{wallet && !isExpanded && ( )} {wallet && isExpanded && ( )}
); } public toggleisExpanded = (_: React.FormEvent) => { this.setState(state => { return { isExpanded: !state.isExpanded }; }); }; } function mapStateToProps(state: AppState) { return { wallet: state.wallet.inst }; } export default connect(mapStateToProps)(UnlockHeader);