import WalletDecrypt from 'components/WalletDecrypt'; import { IWallet } from 'libs/wallet/IWallet'; import React from 'react'; import { connect } from 'react-redux'; import { AppState } from 'reducers'; import translate from 'translations'; interface Props { title: string; wallet: IWallet; } interface State { expanded: boolean; } export class UnlockHeader extends React.Component { public state = { expanded: !this.props.wallet }; public componentDidUpdate(prevProps: Props) { if (this.props.wallet && this.props.wallet !== prevProps.wallet) { this.setState({ expanded: false }); } // not sure if could happen if (!this.props.wallet && this.props.wallet !== prevProps.wallet) { this.setState({ expanded: true }); } } public render() { return (
{this.state.expanded ? '-' : '+'}

{translate(this.props.title)}

{this.state.expanded && } {this.state.expanded &&
}
); } public toggleExpanded = () => { this.setState(state => { return { expanded: !state.expanded }; }); }; } function mapStateToProps(state: AppState) { return { wallet: state.wallet.inst }; } export default connect(mapStateToProps)(UnlockHeader);