- The fix is in! Linty fresh and pretty...
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Text, TextInput, View } from 'react-native';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Text, TextInput, View } from 'react-native';
|
||||
import { Avatar } from 'react-native-elements';
|
||||
|
||||
import { getEmailAvailability, getNomAvailability } from '../api/profile.js';
|
||||
|
||||
import EditNomDeBid from './EditNomDeBid.js';
|
||||
import styles from './Profile.styles.js';
|
||||
|
||||
const STRINGS = {
|
||||
CANCEL: 'Cancel',
|
||||
NOM_EXPLANATION: 'Selecting a nom de bid allows you to bid anonymously - or not. By default, we\'ll use your first initial and last name.',
|
||||
SAVE_PROFILE: 'Save profile',
|
||||
CANCEL: 'Cancel',
|
||||
SAVE_PROFILE: 'Save profile',
|
||||
};
|
||||
|
||||
export default class EditProfile extends Component {
|
||||
|
||||
static get propTypes() {
|
||||
return {
|
||||
addresses: PropTypes.array,
|
||||
@@ -22,6 +22,7 @@ export default class EditProfile extends Component {
|
||||
email: PropTypes.string,
|
||||
firstName: PropTypes.string,
|
||||
initials: PropTypes.string,
|
||||
isGeneratedNomDeBid: PropTypes.bool,
|
||||
lastName: PropTypes.string,
|
||||
nomDeBid: PropTypes.string,
|
||||
phones: PropTypes.array,
|
||||
@@ -37,6 +38,7 @@ export default class EditProfile extends Component {
|
||||
email: null,
|
||||
firstName: null,
|
||||
initials: null,
|
||||
isGeneratedNomDeBid: false,
|
||||
lastName: null,
|
||||
nomDeBid: null,
|
||||
phones: null,
|
||||
@@ -44,7 +46,7 @@ export default class EditProfile extends Component {
|
||||
};
|
||||
}
|
||||
|
||||
constructor() {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -65,11 +67,15 @@ export default class EditProfile extends Component {
|
||||
}
|
||||
|
||||
_validateEmail() {
|
||||
getEmailAvailability(this.state.email, (result) => this.setState('invalidEmail', !result.available));
|
||||
getEmailAvailability(this.state.email, (result) =>
|
||||
this.setState('invalidEmail', !result.available),
|
||||
);
|
||||
}
|
||||
|
||||
_validateNomDeBid() {
|
||||
getNomAvailability(this.state.nomDeBid, (result) => this.setState('invalidNomDeBid', !result.available));
|
||||
getNomAvailability(this.state.nomDeBid, (result) =>
|
||||
this.setState('invalidNomDeBid', !result.available),
|
||||
);
|
||||
}
|
||||
|
||||
getProfileFromState() {
|
||||
@@ -100,16 +106,23 @@ export default class EditProfile extends Component {
|
||||
}
|
||||
|
||||
isFormComplete() {
|
||||
return !this.state.invalidEmail && !this.state.invalidNomDeBid &&
|
||||
!!this.state.firstName && !!this.state.lastName && !!this.state.email &&
|
||||
!!this.state.nomDeBid && !!this.state.phones.length && !!this.state.password;
|
||||
return (
|
||||
!this.state.invalidEmail &&
|
||||
!this.state.invalidNomDeBid &&
|
||||
!!this.state.firstName &&
|
||||
!!this.state.lastName &&
|
||||
!!this.state.email &&
|
||||
!!this.state.nomDeBid &&
|
||||
!!this.state.phones.length &&
|
||||
!!this.state.password
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { isGeneratedNomDeBid } = this.props;
|
||||
const { avatar, firstName, lastName } = this.state;
|
||||
const avatarTitle = !avatar && firstName && lastName
|
||||
? `${firstName.substring(0,1)}${lastName.substring(0,1)}`
|
||||
: null;
|
||||
const addressesTitle = 'Addresses';
|
||||
const numbersTitle = 'Numbers';
|
||||
|
||||
return (
|
||||
<View style={styles.profileFormWrap}>
|
||||
@@ -144,29 +157,31 @@ export default class EditProfile extends Component {
|
||||
value={this.state.email}
|
||||
/>
|
||||
</View>
|
||||
<View style={[styles.nomWrap, styles.requiredWrap]}>
|
||||
<Text style={styles.hintText}>{STRINGS.NOM_EXPLANATION}</Text>
|
||||
<TextInput
|
||||
onChangeText={(text) => this.setState({ nomDeBid: text })}
|
||||
onEndEditing={(text) => this._validateEmail(text)}
|
||||
placeholder="nom de bid"
|
||||
style={[styles.textInput, styles.requiredInput]}
|
||||
value={this.state.nomDeBid}
|
||||
/>
|
||||
</View>
|
||||
{isGeneratedNomDeBid && (
|
||||
<View style={[styles.nomWrap, styles.requiredWrap]}>
|
||||
<EditNomDeBid
|
||||
isGeneratedNomDeBid={isGeneratedNomDeBid}
|
||||
isStandalone={false}
|
||||
nomDeBid={this.state.nomDeBid}
|
||||
updateNomDeBid={(nomDeBid) => this.setState({ nomDeBid })}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<View style={styles.phonesWrap}>
|
||||
<Text style={[styles.groupLabel, styles.requiredLabel]}>Numbers</Text>
|
||||
{phones.length > 0 && (
|
||||
// LIST PHONES
|
||||
<Text style={[styles.groupLabel, styles.requiredLabel]}>{numbersTitle}</Text>
|
||||
{this.props.phones.length > 0 && (
|
||||
/* LIST PHONES */
|
||||
<View />
|
||||
)}
|
||||
<Button title="Add number" onPress={() => false}/>
|
||||
<Button title="Add number" onPress={() => false} />
|
||||
</View>
|
||||
<View style={styles.addressesWrap}>
|
||||
<Text style={styles.groupLabel}>Addresses</Text>
|
||||
{addresses.length > 0 && (
|
||||
// LIST ADDRESSES
|
||||
<Text style={styles.groupLabel}>{addressesTitle}</Text>
|
||||
{this.props.addresses.length > 0 && (
|
||||
/* LIST ADDRESSES */
|
||||
<View />
|
||||
)}
|
||||
<Button title="Add address" onPress={() => false}/>
|
||||
<Button title="Add address" onPress={() => false} />
|
||||
</View>
|
||||
<View style={styles.register}>
|
||||
<Button title={this.props.saveProfileLabel} onPress={this.handleSubmit} />
|
||||
|
||||
Reference in New Issue
Block a user