diff --git a/app/actions/profile.js b/app/actions/profile.js index b7fb866..8cf39f3 100644 --- a/app/actions/profile.js +++ b/app/actions/profile.js @@ -87,7 +87,7 @@ export const checkEmailAvailability = (email) => (dispatch) => {}; export const checkNomAvailability = (nomDeBid) => (dispatch) => {}; -export const setNomDeBid = (nomDeBid) => (dispatch, getState) => { +export const setNomDeBid = ({ nomDeBid }) => (dispatch, getState) => { const id = getUserId(getState()); const auth = getAuthToken(getState()); diff --git a/app/components/AppHeader/AppHeader.js b/app/components/AppHeader/AppHeader.js index dac5132..9da604b 100644 --- a/app/components/AppHeader/AppHeader.js +++ b/app/components/AppHeader/AppHeader.js @@ -24,9 +24,9 @@ export default class AppHeader extends Component { return (
} centerComponent={} - rightComponent={} + leftComponent={} + rightComponent={} /> ); } diff --git a/app/components/AppHeader/HeaderContentLeft.js b/app/components/AppHeader/HeaderContentLeft.js index 4485c24..1baa754 100644 --- a/app/components/AppHeader/HeaderContentLeft.js +++ b/app/components/AppHeader/HeaderContentLeft.js @@ -32,7 +32,11 @@ export default function HeaderContentLeft({ return ; } - return ; + if (hasMultipleEvents) { + return ; + } + + return null; } HeaderContentLeft.propTypes = { diff --git a/app/components/AppHeader/HeaderContentRight.js b/app/components/AppHeader/HeaderContentRight.js index 07b90df..0b08f9a 100644 --- a/app/components/AppHeader/HeaderContentRight.js +++ b/app/components/AppHeader/HeaderContentRight.js @@ -8,7 +8,7 @@ export default function HeaderContentRight({ hideUserProfileButton, navigation } return null; } - return ; + return ; } HeaderContentRight.propTypes = { diff --git a/app/components/AppHeader/HeaderTitle/HeaderTitle.js b/app/components/AppHeader/HeaderTitle/HeaderTitle.js index 06e5d36..43e4ef8 100644 --- a/app/components/AppHeader/HeaderTitle/HeaderTitle.js +++ b/app/components/AppHeader/HeaderTitle/HeaderTitle.js @@ -8,6 +8,7 @@ import EventTitle from './EventTitle/EventTitle.container.js'; import styles from './HeaderTitle.styles.js'; const STRINGS = { + EVENTS: 'Events', PROFILE: 'Profile', }; @@ -34,7 +35,7 @@ export default function HeaderTitle({ if (activeRoute === 'Events') { return ( - {STRINGS.PROFILE} + {STRINGS.EVENTS} ); } diff --git a/app/components/AppHeader/UserProfileButton/UserProfileButton.js b/app/components/AppHeader/UserProfileButton/UserProfileButton.js index ce99358..f255ece 100644 --- a/app/components/AppHeader/UserProfileButton/UserProfileButton.js +++ b/app/components/AppHeader/UserProfileButton/UserProfileButton.js @@ -13,8 +13,12 @@ export default function UserProfileButton({ navigation, }) { const _goToProfile = () => { - navigation.navigate('Profile'); - return false; + if (isRegisteredAccount) { + navigation.navigate('Profile'); + return false; + } + + navigation.navigate('SignInOrRegister'); }; return ( diff --git a/app/components/Profile/EditNomDeBid.js b/app/components/Profile/EditNomDeBid.js index 235683e..305772b 100644 --- a/app/components/Profile/EditNomDeBid.js +++ b/app/components/Profile/EditNomDeBid.js @@ -29,14 +29,14 @@ export default function EditNomDeBid({ setValidNom(result.available); if (isStandalone) { - updateNomDeBid(nomDeBid); + updateNomDeBid({ nomDeBid }); } }); }; const _handleSubmitNom = () => { if (isNomValid) { - updateNomDeBid(newNom); + updateNomDeBid({ newNom }); } }; diff --git a/app/components/Profile/EditProfile.js b/app/components/Profile/EditProfile.js index 42997c5..b6c2a7d 100644 --- a/app/components/Profile/EditProfile.js +++ b/app/components/Profile/EditProfile.js @@ -1,48 +1,57 @@ +import { List } from 'immutable'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { Button, Text, TextInput, View } from 'react-native'; +import { Button, Picker, ScrollView, 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 PhoneListInput from './PhoneInput/PhoneListInput.js'; import styles from './Profile.styles.js'; const STRINGS = { CANCEL: 'Cancel', + NOM_HEADING: 'Nom de Bid', + PASSWORD_HEADING: 'Password', + PERSONAL_HEADING: 'A bit about you...', SAVE_PROFILE: 'Save profile', }; export default class EditProfile extends Component { static get propTypes() { return { - addresses: PropTypes.array, + addresses: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]), avatar: PropTypes.string, cancelEditAction: PropTypes.func.isRequired, email: PropTypes.string, firstName: PropTypes.string, initials: PropTypes.string, isGeneratedNomDeBid: PropTypes.bool, + isRegsiteredAccount: PropTypes.bool, lastName: PropTypes.string, nomDeBid: PropTypes.string, - phones: PropTypes.array, + phones: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]), saveProfileAction: PropTypes.func.isRequired, saveProfileLabel: PropTypes.string, + showPasswordEntry: PropTypes.bool, }; } static get defaultProps() { return { - addresses: null, + addresses: new List(), avatar: null, email: null, firstName: null, initials: null, isGeneratedNomDeBid: false, + isRegsiteredAccount: false, lastName: null, nomDeBid: null, - phones: null, + phones: new List(), saveProfileLabel: STRINGS.SAVE_PROFILE, + showPasswordEntry: false, }; } @@ -59,6 +68,7 @@ export default class EditProfile extends Component { invalidNomDeBid: false, nomDeBid: this.props.nomDeBid, password: this.props.password, + passwordsMismatch: false, phones: this.props.phones, }; @@ -67,15 +77,21 @@ export default class EditProfile extends Component { } _validateEmail() { - getEmailAvailability(this.state.email, (result) => - this.setState('invalidEmail', !result.available), - ); + getEmailAvailability(this.state.email) + .then(({ available = false }) => + this.setState('invalidEmail', !available), + ); } _validateNomDeBid() { - getNomAvailability(this.state.nomDeBid, (result) => - this.setState('invalidNomDeBid', !result.available), - ); + getNomAvailability(this.state.nomDeBid) + .then(({ available = false }) => + this.setState('invalidNomDeBid', !available), + ); + } + + _validatePasswordMatch(password) { + this.setState({ passwordsMismatch: this.state.password !== password }); } getProfileFromState() { @@ -106,6 +122,9 @@ export default class EditProfile extends Component { } isFormComplete() { + const { showPasswordEntry } = this.props; + const { password } = this.state; + return ( !this.state.invalidEmail && !this.state.invalidNomDeBid && @@ -113,27 +132,28 @@ export default class EditProfile extends Component { !!this.state.lastName && !!this.state.email && !!this.state.nomDeBid && - !!this.state.phones.length && - !!this.state.password + !!this.state.phones.size && + ((showPasswordEntry && !!password) || !showPasswordEntry) ); } render() { - const { isGeneratedNomDeBid } = this.props; - const { avatar, firstName, lastName } = this.state; + const { isGeneratedNomDeBid, isRegsiteredAccount, showPasswordEntry } = this.props; + const { addresses, avatar, firstName, lastName, phones } = this.state; const addressesTitle = 'Addresses'; const numbersTitle = 'Numbers'; return ( - - + + {avatar !== null ? ( ) : ( )} - + + {STRINGS.PERSONAL_HEADING} this.setState({ firstName: text })} placeholder="first name" @@ -147,7 +167,7 @@ export default class EditProfile extends Component { value={this.state.lastName} /> - + this.setState({ email: text })} @@ -157,27 +177,45 @@ export default class EditProfile extends Component { value={this.state.email} /> - {isGeneratedNomDeBid && ( - + {showPasswordEntry && ( + + {STRINGS.PASSWORD_HEADING} + this.setState({ password: text })} + placeholder="password" + secureTextEntry + style={[styles.textInput, styles.requiredInput]} + /> + this._validatePasswordMatch(text)} + placeholder="re-enter password" + secureTextEntry + style={[styles.textInput, styles.requiredInput]} + /> + + )} + {(isGeneratedNomDeBid || !isRegsiteredAccount) && ( + + {STRINGS.NOM_HEADING} this.setState({ nomDeBid })} /> )} - - {numbersTitle} - {this.props.phones.length > 0 && ( - /* LIST PHONES */ - - )} -