- Wiring up nom and phone registration bits
- Added guided registration
This commit is contained in:
@@ -33,6 +33,11 @@ export const formatPostData = (body) => {
|
|||||||
return postData;
|
return postData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const formatJsonData = (body) => {
|
||||||
|
console.log('formateJsonBody:', body);
|
||||||
|
return body; //JSON.stringify(body);
|
||||||
|
};
|
||||||
|
|
||||||
const parseQueryParamsString = (queryParams) => {
|
const parseQueryParamsString = (queryParams) => {
|
||||||
if (typeof queryParams !== 'string') {
|
if (typeof queryParams !== 'string') {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
constructUrl,
|
constructUrl,
|
||||||
formatPostData,
|
formatPostData,
|
||||||
|
formatJsonData,
|
||||||
parseQueryParams,
|
parseQueryParams,
|
||||||
request,
|
request,
|
||||||
unwrapJson,
|
unwrapJson,
|
||||||
@@ -74,9 +75,15 @@ export const requestPost = (options) => {
|
|||||||
queryParams = [],
|
queryParams = [],
|
||||||
requestOptions = {},
|
requestOptions = {},
|
||||||
isFormattedPostData = false,
|
isFormattedPostData = false,
|
||||||
|
shouldUseFormData = false,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const params = parseQueryParams(queryParams || []);
|
const params = parseQueryParams(queryParams || []);
|
||||||
|
let postData = isFormattedPostData ? body : null;
|
||||||
|
|
||||||
|
if (!postData) {
|
||||||
|
postData = shouldUseFormData ? formatPostData(body) : formatJsonData(body);
|
||||||
|
}
|
||||||
|
|
||||||
if (params === null) {
|
if (params === null) {
|
||||||
throw new Error('invalid queryParams');
|
throw new Error('invalid queryParams');
|
||||||
@@ -88,7 +95,7 @@ export const requestPost = (options) => {
|
|||||||
...DefaultRequestOptions,
|
...DefaultRequestOptions,
|
||||||
...requestOptions,
|
...requestOptions,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: isFormattedPostData ? body : formatPostData(body),
|
body: postData,
|
||||||
})
|
})
|
||||||
.then(validateResponse)
|
.then(validateResponse)
|
||||||
.then(unwrapJson);
|
.then(unwrapJson);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { API_ENDPOINTS, requestGet, requestPost } from './index.js';
|
import { API_ENDPOINTS, requestGet, requestPost } from './index.js';
|
||||||
|
|
||||||
export const getEmailAvailability = (email) =>
|
export const getEmailAvailability = (email) =>
|
||||||
requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_EMAIL}/&{encodeURI(email)}`);
|
requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_EMAIL}/${encodeURI(email)}`);
|
||||||
|
|
||||||
export const getNomAvailaibility = (nomDeBid) =>
|
export const getNomAvailaibility = (nomDeBid) =>
|
||||||
requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_NOM}/${encodeURI(nomDeBid)}`);
|
requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_NOM}/${encodeURI(nomDeBid)}`);
|
||||||
|
|||||||
@@ -22,21 +22,21 @@ export default function EditNomDeBid({
|
|||||||
updateNomDeBid,
|
updateNomDeBid,
|
||||||
}) {
|
}) {
|
||||||
const [newNom, setNomDeBid] = useState(isGeneratedNomDeBid || !nomDeBid ? '' : nomDeBid);
|
const [newNom, setNomDeBid] = useState(isGeneratedNomDeBid || !nomDeBid ? '' : nomDeBid);
|
||||||
const [isNomValid, setValidNom] = useState(false);
|
const [isNomValid, setValidNom] = useState(null);
|
||||||
|
|
||||||
const _handleEndEditing = (nomDeBid) => {
|
const _handleEndEditing = () => {
|
||||||
getNomAvailaibility(nomDeBid).then((result) => {
|
getNomAvailaibility(newNom).then((result) => {
|
||||||
setValidNom(result.available);
|
setValidNom(result.available);
|
||||||
|
|
||||||
if (isStandalone) {
|
if (isStandalone) {
|
||||||
updateNomDeBid({ nomDeBid });
|
updateNomDeBid(newNom);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const _handleSubmitNom = () => {
|
const _handleSubmitNom = () => {
|
||||||
if (isNomValid) {
|
if (isNomValid) {
|
||||||
updateNomDeBid({ newNom });
|
updateNomDeBid(newNom);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,12 +48,19 @@ export default function EditNomDeBid({
|
|||||||
<View style={styles.profileFormWrap}>
|
<View style={styles.profileFormWrap}>
|
||||||
<Text style={styles.hintText}>{explanationString}</Text>
|
<Text style={styles.hintText}>{explanationString}</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
autoCapitalize="none"
|
||||||
onChangeText={(text) => setNomDeBid(text)}
|
onChangeText={(text) => setNomDeBid(text)}
|
||||||
onEndEditing={(text) => _handleEndEditing(text)}
|
onEndEditing={() => _handleEndEditing()}
|
||||||
placeholder="nom de bid"
|
placeholder="nom de bid"
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
value={newNom}
|
value={newNom}
|
||||||
/>
|
/>
|
||||||
|
{isNomValid === false && (
|
||||||
|
<Text style={{color:'red'}}>Nom De Bid is taken!</Text>
|
||||||
|
)}
|
||||||
|
{isNomValid === true && (
|
||||||
|
<Text style={{color:'green'}}>Nom De Bid is available!</Text>
|
||||||
|
)}
|
||||||
{!isStandalone && (
|
{!isStandalone && (
|
||||||
<Button
|
<Button
|
||||||
title={STRINGS.SUBMIT_NOM}
|
title={STRINGS.SUBMIT_NOM}
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ import PhoneListInput from './PhoneInput/PhoneListInput.js';
|
|||||||
import styles from './Profile.styles.js';
|
import styles from './Profile.styles.js';
|
||||||
|
|
||||||
const STRINGS = {
|
const STRINGS = {
|
||||||
|
AVATAR_HEADING: 'Want to add a picture?',
|
||||||
CANCEL: 'Cancel',
|
CANCEL: 'Cancel',
|
||||||
NOM_HEADING: 'Nom de Bid',
|
EMAIL_HEADING: 'Email (this will be your username)',
|
||||||
PASSWORD_HEADING: 'Password',
|
NOM_HEADING: 'and a Nom de Bid - your bidding alias!',
|
||||||
PERSONAL_HEADING: 'A bit about you...',
|
PASSWORD_HEADING: 'For security, let\'s choose a password',
|
||||||
|
PERSONAL_HEADING: 'Great! And now a bit about you...',
|
||||||
SAVE_PROFILE: 'Save profile',
|
SAVE_PROFILE: 'Save profile',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ export default class EditProfile extends Component {
|
|||||||
firstName: PropTypes.string,
|
firstName: PropTypes.string,
|
||||||
initials: PropTypes.string,
|
initials: PropTypes.string,
|
||||||
isGeneratedNomDeBid: PropTypes.bool,
|
isGeneratedNomDeBid: PropTypes.bool,
|
||||||
|
isGuided: PropTypes.bool,
|
||||||
isRegsiteredAccount: PropTypes.bool,
|
isRegsiteredAccount: PropTypes.bool,
|
||||||
lastName: PropTypes.string,
|
lastName: PropTypes.string,
|
||||||
nomDeBid: PropTypes.string,
|
nomDeBid: PropTypes.string,
|
||||||
@@ -46,6 +49,7 @@ export default class EditProfile extends Component {
|
|||||||
firstName: null,
|
firstName: null,
|
||||||
initials: null,
|
initials: null,
|
||||||
isGeneratedNomDeBid: false,
|
isGeneratedNomDeBid: false,
|
||||||
|
isGuided: false,
|
||||||
isRegsiteredAccount: false,
|
isRegsiteredAccount: false,
|
||||||
lastName: null,
|
lastName: null,
|
||||||
nomDeBid: null,
|
nomDeBid: null,
|
||||||
@@ -55,6 +59,16 @@ export default class EditProfile extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static validatePasswordMatch(password, passwordCheck) {
|
||||||
|
if ((!password || !passwordCheck) ||
|
||||||
|
(password || passwordCheck && password.length === passwordCheck.length)
|
||||||
|
){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return password === passwordCheck;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@@ -64,11 +78,10 @@ export default class EditProfile extends Component {
|
|||||||
email: this.props.email,
|
email: this.props.email,
|
||||||
firstName: this.props.firstName,
|
firstName: this.props.firstName,
|
||||||
lastName: this.props.lastName,
|
lastName: this.props.lastName,
|
||||||
invalidEmail: false,
|
invalidEmail: null,
|
||||||
invalidNomDeBid: false,
|
|
||||||
nomDeBid: this.props.nomDeBid,
|
nomDeBid: this.props.nomDeBid,
|
||||||
password: this.props.password,
|
password: this.props.password,
|
||||||
passwordsMismatch: false,
|
passwordCheck: null,
|
||||||
phones: this.props.phones,
|
phones: this.props.phones,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,32 +91,22 @@ export default class EditProfile extends Component {
|
|||||||
|
|
||||||
_validateEmail() {
|
_validateEmail() {
|
||||||
getEmailAvailability(this.state.email)
|
getEmailAvailability(this.state.email)
|
||||||
.then(({ available = false }) =>
|
.then((result) => {
|
||||||
this.setState('invalidEmail', !available),
|
console.log(`_validateEmail => getEmailAvailability(${this.state.email}):`, result);
|
||||||
);
|
this.setState({ invalidEmail: !result.available });
|
||||||
}
|
});
|
||||||
|
|
||||||
_validateNomDeBid() {
|
|
||||||
getNomAvailability(this.state.nomDeBid)
|
|
||||||
.then(({ available = false }) =>
|
|
||||||
this.setState('invalidNomDeBid', !available),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_validatePasswordMatch(password) {
|
|
||||||
this.setState({ passwordsMismatch: this.state.password !== password });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfileFromState() {
|
getProfileFromState() {
|
||||||
return {
|
return {
|
||||||
addresses: this.state.addresses,
|
addresses: this.state.addresses.toArray(),
|
||||||
avatar: this.state.avatar,
|
avatar: this.state.avatar,
|
||||||
email: this.state.email,
|
email: this.state.email,
|
||||||
firstName: this.state.firstName,
|
firstName: this.state.firstName,
|
||||||
lastName: this.state.lastName,
|
lastName: this.state.lastName,
|
||||||
nomDeBid: this.state.nomDeBid,
|
nomDeBid: this.state.nomDeBid,
|
||||||
password: this.state.password,
|
password: this.state.password,
|
||||||
phones: this.state.phones,
|
phones: this.state.phones.toArray(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +126,7 @@ export default class EditProfile extends Component {
|
|||||||
|
|
||||||
isFormComplete() {
|
isFormComplete() {
|
||||||
const { showPasswordEntry } = this.props;
|
const { showPasswordEntry } = this.props;
|
||||||
const { password } = this.state;
|
const { password, passwordCheck } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!this.state.invalidEmail &&
|
!this.state.invalidEmail &&
|
||||||
@@ -133,96 +136,130 @@ export default class EditProfile extends Component {
|
|||||||
!!this.state.email &&
|
!!this.state.email &&
|
||||||
!!this.state.nomDeBid &&
|
!!this.state.nomDeBid &&
|
||||||
!!this.state.phones.size &&
|
!!this.state.phones.size &&
|
||||||
((showPasswordEntry && !!password) || !showPasswordEntry)
|
((showPasswordEntry && EditProfile.validatePasswordMatch(password, passwordCheck)) || !showPasswordEntry)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isGeneratedNomDeBid, isRegsiteredAccount, showPasswordEntry } = this.props;
|
const { isGeneratedNomDeBid, isGuided, isRegsiteredAccount, showPasswordEntry } = this.props;
|
||||||
const { addresses, avatar, firstName, lastName, phones } = this.state;
|
const { addresses, avatar, firstName, invalidEmail, lastName, password, passwordCheck, phones } = this.state;
|
||||||
const addressesTitle = 'Addresses';
|
const addressesTitle = 'Addresses';
|
||||||
const numbersTitle = 'Numbers';
|
const numbersTitle = 'Numbers';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.profileFormWrap}>
|
<ScrollView style={styles.profileFormWrap}>
|
||||||
<View style={[styles.sectionWrap, styles.avatarWrap]}>
|
|
||||||
{avatar !== null ? (
|
|
||||||
<Avatar source={{ uri: this.state.avatar }} showEditButton />
|
|
||||||
) : (
|
|
||||||
<Avatar title={this.props.initials} showEditButton />
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
<View style={[styles.sectionWrap, styles.nameWrap]}>
|
|
||||||
<Text style={styles.groupHeading}>{STRINGS.PERSONAL_HEADING}</Text>
|
|
||||||
<TextInput
|
|
||||||
onChange={(text) => this.setState({ firstName: text })}
|
|
||||||
placeholder="first name"
|
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
|
||||||
value={this.state.firstName}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
onChange={(text) => this.setState({ lastName: text })}
|
|
||||||
placeholder="last name"
|
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
|
||||||
value={this.state.lastName}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={[styles.sectionWrap, styles.emailWrap, styles.requiredWrap]}>
|
<View style={[styles.sectionWrap, styles.emailWrap, styles.requiredWrap]}>
|
||||||
|
<Text style={styles.groupHeading}>{STRINGS.EMAIL_HEADING}</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
autoCapitalize="none"
|
||||||
keyboardType="email-address"
|
keyboardType="email-address"
|
||||||
onChangeText={(text) => this.setState({ email: text })}
|
onChangeText={(text) => this.setState({ email: text })}
|
||||||
onEndEditing={(text) => this._validateEmail(text)}
|
onEndEditing={(text) => this._validateEmail(text)}
|
||||||
placeholder="email address"
|
placeholder="email address"
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
value={this.state.email}
|
value={this.state.email || ''}
|
||||||
/>
|
/>
|
||||||
</View>
|
{invalidEmail === true && (
|
||||||
{showPasswordEntry && (
|
<View style={styles.emailTaken}>
|
||||||
<View style={[styles.sectionWrap, styles.password, styles.requiredWrap]}>
|
<Text style={{color:'red'}}>{`You've already registered!`}</Text>
|
||||||
<Text style={styles.groupHeading}>{STRINGS.PASSWORD_HEADING}</Text>
|
<Button title="Forgot Password" onPress={() => {}} />
|
||||||
<TextInput
|
</View>
|
||||||
onChangeText={(text) => this.setState({ password: text })}
|
)}
|
||||||
placeholder="password"
|
{invalidEmail === false && (
|
||||||
secureTextEntry
|
<Text style={{color:'green'}}>{`Great, lets add a bit more detail...`}</Text>
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
onEndEditing={(text) => this._validatePasswordMatch(text)}
|
|
||||||
placeholder="re-enter password"
|
|
||||||
secureTextEntry
|
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
{(isGeneratedNomDeBid || !isRegsiteredAccount) && (
|
|
||||||
<View style={[styles.sectionWrap, styles.nomWrap, styles.requiredWrap]}>
|
|
||||||
<Text style={styles.groupHeading}>{STRINGS.NOM_HEADING}</Text>
|
|
||||||
<EditNomDeBid
|
|
||||||
isGeneratedNomDeBid={isGeneratedNomDeBid}
|
|
||||||
isStandalone
|
|
||||||
nomDeBid={this.state.nomDeBid}
|
|
||||||
updateNomDeBid={(nomDeBid) => this.setState({ nomDeBid })}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
<View style={[styles.sectionWrap, styles.phonesWrap]}>
|
|
||||||
<PhoneListInput
|
|
||||||
handleAdd={(phones) => this.setState({ phones })}
|
|
||||||
handleDelete={(phones) => this.setState({ phones })}
|
|
||||||
handleEdit={(phones) => this.setState({ phones })}
|
|
||||||
phones={phones}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={[styles.sectionWrap, styles.addressesWrap]}>
|
|
||||||
<Text style={styles.groupHeading}>{addressesTitle}</Text>
|
|
||||||
{addresses !== null && addresses.size > 0 && (
|
|
||||||
/* LIST ADDRESSES */
|
|
||||||
<View />
|
|
||||||
)}
|
)}
|
||||||
<Button title="Add address" onPress={() => false} />
|
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.register}>
|
{(!isGuided || (isGuided && invalidEmail === false)) && (
|
||||||
<Button title={this.props.saveProfileLabel} onPress={this.handleSubmit} />
|
<View style={styles.rollDownPanel}>
|
||||||
|
<View style={[styles.sectionWrap, styles.nameWrap]}>
|
||||||
|
<Text style={styles.groupHeading}>{STRINGS.PERSONAL_HEADING}</Text>
|
||||||
|
<TextInput
|
||||||
|
onChange={(text) => this.setState({ firstName: text })}
|
||||||
|
placeholder="first name"
|
||||||
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
|
value={this.state.firstName || ''}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
onChange={(text) => this.setState({ lastName: text })}
|
||||||
|
placeholder="last name"
|
||||||
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
|
value={this.state.lastName || ''}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
{showPasswordEntry &&
|
||||||
|
(!isGuided || (isGuided && firstName !== null && lastName !== null)) &&
|
||||||
|
(
|
||||||
|
<View style={[styles.sectionWrap, styles.password, styles.requiredWrap]}>
|
||||||
|
<Text style={styles.groupHeading}>{STRINGS.PASSWORD_HEADING}</Text>
|
||||||
|
<TextInput
|
||||||
|
onChangeText={(text) => this.setState({ password: text })}
|
||||||
|
placeholder="password"
|
||||||
|
secureTextEntry
|
||||||
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
onChangeText={(text) => this.setState({ passwordCheck: text })}
|
||||||
|
placeholder="re-enter password"
|
||||||
|
secureTextEntry
|
||||||
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
|
/>
|
||||||
|
{EditProfile.validatePasswordMatch(password, passwordCheck) === true && (
|
||||||
|
<Text style={{ color: 'green' }}>{`That's a match!`}</Text>
|
||||||
|
)}
|
||||||
|
{EditProfile.validatePasswordMatch(password, passwordCheck) === false && (
|
||||||
|
<Text style={{ color: 'red' }}>{`Well that's not a match...`}</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
{(isGeneratedNomDeBid || !isRegsiteredAccount) &&
|
||||||
|
(!isGuided || (isGuided && EditProfile.validatePasswordMatch(password, passwordCheck) === true)) &&
|
||||||
|
(
|
||||||
|
<View style={[styles.sectionWrap, styles.nomWrap, styles.requiredWrap]}>
|
||||||
|
<Text style={styles.groupHeading}>{STRINGS.NOM_HEADING}</Text>
|
||||||
|
<EditNomDeBid
|
||||||
|
isGeneratedNomDeBid={isGeneratedNomDeBid}
|
||||||
|
isStandalone
|
||||||
|
nomDeBid={this.state.nomDeBid}
|
||||||
|
updateNomDeBid={(nomDeBid) => this.setState({ nomDeBid })}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
{(!isGuided || (isGuided && this.state.nomDeBid !== null)) && (
|
||||||
|
<View style={styles.rollDownPanel}>
|
||||||
|
<View style={[styles.sectionWrap, styles.phonesWrap]}>
|
||||||
|
<PhoneListInput
|
||||||
|
handleAdd={(phones) => this.setState({ phones })}
|
||||||
|
handleDelete={(phones) => this.setState({ phones })}
|
||||||
|
handleEdit={(phones) => this.setState({ phones })}
|
||||||
|
phones={phones}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={[styles.sectionWrap, styles.addressesWrap]}>
|
||||||
|
<Text style={styles.groupHeading}>{addressesTitle}</Text>
|
||||||
|
{addresses !== null && addresses.size > 0 && (
|
||||||
|
/* LIST ADDRESSES */
|
||||||
|
<View />
|
||||||
|
)}
|
||||||
|
<Button title="Add address" onPress={() => false} />
|
||||||
|
</View>
|
||||||
|
<View style={[styles.sectionWrap, styles.avatarWrap]}>
|
||||||
|
<Text style={styles.groupHeading}>{STRINGS.AVATAR_HEADING}</Text>
|
||||||
|
{avatar !== null ? (
|
||||||
|
<Avatar source={{ uri: this.state.avatar }} showEditButton />
|
||||||
|
) : (
|
||||||
|
<Avatar title={this.props.initials} showEditButton />
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
{(!isGuided || (isGuided && phones !== null && phones.size > 0)) && (
|
||||||
|
<View style={styles.register}>
|
||||||
|
<Button title={this.props.saveProfileLabel} onPress={this.handleSubmit} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
<View style={styles.cancelWrap}>
|
||||||
<Button title={STRINGS.CANCEL} onPress={this.handleCancel} />
|
<Button title={STRINGS.CANCEL} onPress={this.handleCancel} />
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -34,7 +34,12 @@ export default class PhoneListInput extends Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = { ...defaultState };
|
this.state = { ...defaultState };
|
||||||
|
|
||||||
|
this.handleAdd = this.handleAdd.bind(this);
|
||||||
|
this.handleEdit = this.handleEdit.bind(this);
|
||||||
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
@@ -78,8 +83,8 @@ export default class PhoneListInput extends Component {
|
|||||||
{phones.map((phone, index) =>
|
{phones.map((phone, index) =>
|
||||||
<PhoneListItem
|
<PhoneListItem
|
||||||
index={index}
|
index={index}
|
||||||
label={phone.get('label')}
|
label={phone.label}
|
||||||
number={phone.get('number')}
|
number={phone.number}
|
||||||
handleDelete={this.props.handleDelete}
|
handleDelete={this.props.handleDelete}
|
||||||
handleEdit={this.props.handleEdit ? this.handleEdit : null}
|
handleEdit={this.props.handleEdit ? this.handleEdit : null}
|
||||||
handleEditStart={this.handleEditStart}
|
handleEditStart={this.handleEditStart}
|
||||||
@@ -88,7 +93,7 @@ export default class PhoneListInput extends Component {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
<TextInput
|
<TextInput
|
||||||
onChangeText={(text) => this.setState({ editingPhone: text })}
|
onChangeText={(text) => this.setState({ newPhone: text })}
|
||||||
placeholder="phone number"
|
placeholder="phone number"
|
||||||
style={[styles.textInput, styles.requiredInput]}
|
style={[styles.textInput, styles.requiredInput]}
|
||||||
value={this.state.newPhone}
|
value={this.state.newPhone}
|
||||||
@@ -97,13 +102,19 @@ export default class PhoneListInput extends Component {
|
|||||||
onValueChange={(type, index) => this.setState({ newPhoneType: type })}
|
onValueChange={(type, index) => this.setState({ newPhoneType: type })}
|
||||||
selectedValue={this.state.newPhoneType}
|
selectedValue={this.state.newPhoneType}
|
||||||
>
|
>
|
||||||
{PHONE_TYPES.map((type) => <Picker.Item label={type.label} value={type.value} />)}
|
{PHONE_TYPES.map((type) => <Picker.Item key={type.value} {...type} />)}
|
||||||
</Picker>
|
</Picker>
|
||||||
<Button
|
<Button
|
||||||
disabled={!this.state.newPhone && !this.state.newPhoneType}
|
disabled={!this.state.newPhone && !this.state.newPhoneType}
|
||||||
onPress={isEditing ? () => this.handleEdit(index) : this.handleAdd}
|
onPress={isEditing ? () => this.handleEdit(index) : this.handleAdd}
|
||||||
title={isEditing ? 'update' : 'add number'}
|
title={isEditing ? 'update' : 'add number'}
|
||||||
/>
|
/>
|
||||||
|
{isEditing && (
|
||||||
|
<Button
|
||||||
|
onPress={this.handleEditCancel}
|
||||||
|
title="cancel"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ export default function PhoneListItem({ index, label, number, handleDelete, hand
|
|||||||
return (
|
return (
|
||||||
<View style={styles.listItem}>
|
<View style={styles.listItem}>
|
||||||
<View style={styles.listValue}>
|
<View style={styles.listValue}>
|
||||||
<Text style={styles.value}>{phone.get('number')}</Text>
|
<Text style={styles.value}>{number}</Text>
|
||||||
<Text style={styles.label}>{phone.get('label')}</Text>
|
<Text style={styles.label}>{label}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.listActions}>
|
<View style={styles.listActions}>
|
||||||
{handleEdit !== null && <Button title={`Edit`} onPress={() => this.handleEditStart(index)} />}
|
{handleEdit !== null && <Button title={`Edit`} onPress={() => handleEditStart(index)} />}
|
||||||
<Button title={`X`} onPress={() => this.props.handleDelete(index)} />
|
<Button title={`X`} onPress={() => handleDelete(index)} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import ViewProfile from './ViewProfile.container.js';
|
|||||||
|
|
||||||
export default function Profile({
|
export default function Profile({
|
||||||
cancelEditAction,
|
cancelEditAction,
|
||||||
|
isGuidedRegistration,
|
||||||
isInEditMode,
|
isInEditMode,
|
||||||
saveProfileAction,
|
saveProfileAction,
|
||||||
saveProfileLabel,
|
saveProfileLabel,
|
||||||
@@ -28,6 +29,7 @@ export default function Profile({
|
|||||||
{editMode ? (
|
{editMode ? (
|
||||||
<EditProfile
|
<EditProfile
|
||||||
cancelEditAction={_cancelEditAction}
|
cancelEditAction={_cancelEditAction}
|
||||||
|
isGuided={isGuidedRegistration}
|
||||||
saveProfileAction={_saveProfileAction}
|
saveProfileAction={_saveProfileAction}
|
||||||
saveProfileLabel={saveProfileLabel}
|
saveProfileLabel={saveProfileLabel}
|
||||||
/>
|
/>
|
||||||
@@ -40,12 +42,14 @@ export default function Profile({
|
|||||||
|
|
||||||
Profile.propTypes = {
|
Profile.propTypes = {
|
||||||
cancelEditAction: PropTypes.func.isRequired,
|
cancelEditAction: PropTypes.func.isRequired,
|
||||||
|
isGuidedRegistration: PropTypes.bool,
|
||||||
isInEditMode: PropTypes.bool,
|
isInEditMode: PropTypes.bool,
|
||||||
saveProfileAction: PropTypes.func.isRequired,
|
saveProfileAction: PropTypes.func.isRequired,
|
||||||
saveProfileLabel: PropTypes.string,
|
saveProfileLabel: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
Profile.defaultProps = {
|
Profile.defaultProps = {
|
||||||
|
isGuidedRegistration: false,
|
||||||
isInEditMode: false,
|
isInEditMode: false,
|
||||||
saveProfileLabel: null,
|
saveProfileLabel: null,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ export default StyleSheet.create({
|
|||||||
sectionWrap: {
|
sectionWrap: {
|
||||||
marginBottom: 15,
|
marginBottom: 15,
|
||||||
},
|
},
|
||||||
avatarWrap: {
|
emailWrap: {
|
||||||
marginBottom: 40,
|
marginBottom: 40,
|
||||||
marginTop: 30,
|
marginTop: 20,
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
},
|
},
|
||||||
groupHeading: {
|
groupHeading: {
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ export const PERMISSIONS = {
|
|||||||
FACEBOOK: ['email', 'public_profile'],
|
FACEBOOK: ['email', 'public_profile'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PHONE_TYPES = {
|
export const PHONE_TYPES = [
|
||||||
HOME: { label: 'home', value: 'home' },
|
{ label: 'home', value: 'home' },
|
||||||
MOBILE: { label: 'mobile', value: 'mobile' },
|
{ label: 'mobile', value: 'mobile' },
|
||||||
WORK: { label: 'work', value: 'work' },
|
{ label: 'work', value: 'work' },
|
||||||
};
|
];
|
||||||
|
|
||||||
export const PHONE_TYPE_DEFAULT = PHONE_TYPES.HOME.value;
|
export const PHONE_TYPE_DEFAULT = PHONE_TYPES[0].value;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export default function Register({ doRegistration, navigation }) {
|
|||||||
<Text style={styles.heading}>{title}</Text>
|
<Text style={styles.heading}>{title}</Text>
|
||||||
<EditProfile
|
<EditProfile
|
||||||
cancelEditAction={() => navigation.goBack()}
|
cancelEditAction={() => navigation.goBack()}
|
||||||
|
isGuided
|
||||||
saveProfileAction={_doRegistration}
|
saveProfileAction={_doRegistration}
|
||||||
saveProfileLabel="Register"
|
saveProfileLabel="Register"
|
||||||
showPasswordEntry
|
showPasswordEntry
|
||||||
|
|||||||
Reference in New Issue
Block a user