Commit 33af91ea by Tonk

add register function

parent 7e4f60cc
......@@ -40,27 +40,27 @@ class Register extends Component {
<View style={theme.containerWithVerticalMargin}>
<Field
forwardRef
ref={c => (this.name = c)}
refField="name"
ref={c => (this.firstName = c)}
refField="firstName"
returnKeyType="next"
onSubmitEditing={() => this.surname.getRenderedComponent().refs.surname.focus()}
name="name"
onSubmitEditing={() => this.lastName.getRenderedComponent().refs.lastName.focus()}
name="firstName"
keyboardType="default"
component={Input}
validate={[required]}
placeholder="Name"
placeholder="First name"
/>
<Field
forwardRef
ref={c => (this.surname = c)}
refField="surname"
ref={c => (this.lastName = c)}
refField="lastName"
returnKeyType="next"
onSubmitEditing={() => this.email.getRenderedComponent().refs.email.focus()}
name="surname"
name="lastName"
keyboardType="default"
component={Input}
validate={[required]}
placeholder="Surname"
placeholder="Last name"
/>
<Field
forwardRef
......
......@@ -30,8 +30,10 @@ class EditProfileScreen extends React.Component {
phoneNumber: this.props.phoneNumber,
};
componentDidMount() {
const splitName = this.props.displayName ? this.props.displayName.split(' ') : null;
this.setState({ firstName: splitName[0], lastName: splitName[1] });
if (this.props.displayName) {
const splitName = this.props.displayName.split(' ');
this.setState({ firstName: splitName[0], lastName: splitName[1] });
}
}
toggleModal = value => {
this.setState({ confirmModal: value });
......@@ -53,6 +55,7 @@ class EditProfileScreen extends React.Component {
<Text style={theme.description}>First name</Text>
<TextInput
value={firstName}
placeholder="e.g. John"
onChangeText={text => this.setState({ firstName: text })}
style={styles.inputStyle}
/>
......@@ -60,6 +63,7 @@ class EditProfileScreen extends React.Component {
<Text style={theme.description}>Last name</Text>
<TextInput
value={lastName}
placeholder="e.g. Doe"
onChangeText={text => this.setState({ lastName: text })}
style={styles.inputStyle}
/>
......
......@@ -5,8 +5,11 @@ import { Platform, View, ScrollView } from 'react-native';
import RegisterForm from '../../components/Form/RegisterForm';
import { HeaderButtons, Item } from 'react-navigation-header-buttons';
import IoniconsHeaderButton from '../../components/IoniconsHeaderButton';
import app, { fireStore, baseURL } from '../../firebase';
import { connect } from 'react-redux';
import { updateUser } from '../../reduxStore/actions/cerrentUserAction';
export default class RegisterScreen extends Component {
class RegisterScreen extends Component {
static navigationOptions = ({ navigation }) => ({
title: undefined,
......@@ -30,9 +33,26 @@ export default class RegisterScreen extends Component {
this.props.navigation.navigate('Success');
}
}
submit = values => {
this.submitSuccess();
if (this.state.isCheck == false) {
alert('You have to accept Terms and Conditions!');
} else {
this.createAccount(values);
}
};
createAccount = async values => {
const userData = { firstName: values.firstName, lastName: values.lastName, phoneNumber: values.phoneno };
try {
const reg = app.auth().createUserWithEmailAndPassword(values.email, values.password);
if (reg) {
this.props.updateUser(userData);
app.auth().signOut();
this.props.navigation.navigate('Success');
}
} catch (error) {
console.log(error);
}
};
render() {
......@@ -63,3 +83,14 @@ export default class RegisterScreen extends Component {
);
}
}
const mapStateToProps = state => ({});
const mapDispatchToProps = {
updateUser,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(RegisterScreen);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment