// @flow import React from 'react'; import PropTypes from 'prop-types'; import translate from 'translations'; import WalletDecrypt from 'components/WalletDecrypt'; import BaseWallet from 'libs/wallet/base'; import { connect } from 'react-redux'; import type { State } from 'reducers'; type Props = { title: string, wallet: BaseWallet }; export class UnlockHeader extends React.Component { props: Props; static propTypes = { title: PropTypes.string.isRequired }; state: { expanded: boolean } = { expanded: true }; 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 }); } } render() { return (
{this.state.expanded ? '-' : '+'}

{translate(this.props.title)}

{this.state.expanded &&
{/* @@if (site === 'cx' ) { } @@if (site === 'mew' ) { } */}
} {this.state.expanded &&
}
); } toggleExpanded = () => { this.setState(state => { return { expanded: !state.expanded }; }); }; } function mapStateToProps(state: State) { return { wallet: state.wallet }; } export default connect(mapStateToProps)(UnlockHeader);