LogoutContainer.js 2.05 KB
'use strict';

import React from 'react-native';

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

import {Map} from 'immutable';

import * as userActions from '../reducers/user/userActions';
import * as deviceActions from '../reducers/device/deviceActions';
import Logout from '../components/Logout';

let {
    Component,
    View,
    Text,
    StyleSheet,
    Image,
    TextInput,
    Dimensions,
    Alert,
} = React;

/**
 * ## Actions
 * 3 of our actions will be available as ```actions```
 */
const actions = [
    userActions,
    deviceActions,
];

/**
 *  Save that state
 */
function mapStateToProps(state) {
    return {
        ...state
    };
};

/**
 * Bind all the functions from the ```actions``` and bind them with
 * ```dispatch```
 */
function mapDispatchToProps(dispatch) {

    const creators = Map()
            .merge(...actions)
            .filter(value => typeof value === 'function')
            .toObject();

    return {
        actions: bindActionCreators(creators, dispatch),
        dispatch
    };
}

export default class LogoutContainer extends Component {

    constructor(props) {
        super(props);
        this.onLogoutPress = this.onLogoutPress.bind(this);
        this.onModifyPress = this.onModifyPress.bind(this);
    }

  componentDidMount() {

  }

  componentWillUnmount() {

  }

  onLogoutPress(){
        this.props.actions.logout();
  }

  onModifyPress(){
        this.props.actions.pwdModify();
  }

	render(){
        return (
          <Logout 
              account={this.props.user.profile.account}
              username={this.props.user.profile.username}
              pwd={this.props.user.profile.pid}
              onLogoutPress={this.onLogoutPress}
              onModifyPress={this.onModifyPress}
          />
        );
      }
}
let {height, width} = Dimensions.get('window');
let textPaddingTop = height * 7 / 10;
let buttonMargin = (width - 165) / 2;
var styles = StyleSheet.create({

});

/**
 * Connect the properties
 */
export default connect(mapStateToProps, mapDispatchToProps)(LogoutContainer);