import React from 'react' import { Button, Glyphicon, Alert } from 'react-bootstrap' import SectionLayout from './section_layout' import UserPasswordForm from './user_password_form' import Login from 'components/login' import Spinner from 'components/spinner' import Account from 'models/account' import bitmask from 'lib/bitmask' import App from 'app' export default class UserSection extends React.Component { static get defaultProps() {return{ account: null, onLogout: null, onLogin: null }} constructor(props) { super(props) this.state = { error: null, loading: false, expanded: false, } this.logout = this.logout.bind(this) this.expand = this.expand.bind(this) } logout() { this.setState({loading: true}) this.props.account.logout().then( account => { this.setState({error: null, loading: false}) if (this.props.onLogout) { this.props.onLogout(account) } }, error => { this.setState({error: error, loading: false}) } ) } expand() { this.setState({expanded: !this.state.expanded}) } render () { if (this.props.account.authenticated) { return this.renderAccount() } else { return this.renderLoginForm() } } renderAccount() { let button = null let message = null let body = null let header =

{this.props.account.address}

if (this.state.error) { // style may be: success, warning, danger, info message = ( {this.state.error} ) } if (this.state.expanded) { body =
} if (this.state.loading) { button = } else { button = } return ( ) } renderLoginForm() { let address = null if (this.props.account.userpart) { address = this.props.account.address } let header = (

  Create a new account...
) return ( ) } }