|
@@ -2,7 +2,7 @@ import React, { Component} from 'react';
|
|
|
import { Text, ListView } from 'react-native';
|
|
import { Text, ListView } from 'react-native';
|
|
|
import { connect } from 'react-redux';
|
|
import { connect } from 'react-redux';
|
|
|
import { Card, CardSection, Input, Button, Spinner } from './common';
|
|
import { Card, CardSection, Input, Button, Spinner } from './common';
|
|
|
-import { propChanged } from '../actions/';
|
|
|
|
|
|
|
+import { propChanged, registerUser } from '../actions/';
|
|
|
import { Actions } from 'react-native-router-flux';
|
|
import { Actions } from 'react-native-router-flux';
|
|
|
|
|
|
|
|
class RegisterForm extends Component {
|
|
class RegisterForm extends Component {
|
|
@@ -29,10 +29,11 @@ class RegisterForm extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onRegisterPress() {
|
|
onRegisterPress() {
|
|
|
- // Actions.register();
|
|
|
|
|
|
|
+ this.props.registerUser({ user: this.props.user });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
renderButton() {
|
|
renderButton() {
|
|
|
|
|
+ console.log("loading:",this.props.loading);
|
|
|
if (this.props.loading) {
|
|
if (this.props.loading) {
|
|
|
return <Spinner size="large" />;
|
|
return <Spinner size="large" />;
|
|
|
}
|
|
}
|
|
@@ -44,14 +45,13 @@ class RegisterForm extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
renderItem(item) {
|
|
renderItem(item) {
|
|
|
- console.log("renderitem", item);
|
|
|
|
|
- console.log("this", this);
|
|
|
|
|
return (
|
|
return (
|
|
|
<CardSection>
|
|
<CardSection>
|
|
|
<Input
|
|
<Input
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
placeholder={item.placeholder}
|
|
placeholder={item.placeholder}
|
|
|
- value={this.props[item.key]}
|
|
|
|
|
|
|
+ value={this.props.user[item.key]}
|
|
|
|
|
+ editable={false}
|
|
|
onChangeText={ () => this.props.propChanged({ key: item.key, val: this.props[item.key] }) }
|
|
onChangeText={ () => this.props.propChanged({ key: item.key, val: this.props[item.key] }) }
|
|
|
/>
|
|
/>
|
|
|
</CardSection>
|
|
</CardSection>
|
|
@@ -87,9 +87,9 @@ const styles = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = ({ register }) => {
|
|
const mapStateToProps = ({ register }) => {
|
|
|
- const { email, nombre, password, error, loading } = register;
|
|
|
|
|
- return { email, nombre, password, error, loading };
|
|
|
|
|
|
|
+ const { error, user, loading } = register;
|
|
|
|
|
+ return { error, loading, user };
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-export default connect(mapStateToProps, { propChanged } )(RegisterForm);
|
|
|
|
|
|
|
+export default connect(mapStateToProps, { propChanged, registerUser } )(RegisterForm);
|