This commit is contained in:
Mike Fitzpatrick
2019-08-12 17:44:01 -04:00
parent 0f618fdd78
commit f0460a1b76
21 changed files with 432 additions and 78 deletions

View File

@@ -1,6 +1,7 @@
import { List } from 'immutable';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Button, Text, TextInput, View } from 'react-native';
import { Button, ScrollView, Text, TextInput, View } from 'react-native';
import { Avatar } from 'react-native-elements';
import EditNomDeBid from './EditNomDeBid.container.js';
@@ -23,9 +24,9 @@ export default function ViewProfile({
nomDeBid,
phones,
}) {
const _getSavedText = (count) => `${count} saved`;
const addressesCountString = _getSavedText(addresses.length);
const phonesCountString = _getSavedText(phones.length);
const _getSavedText = (count) => count > 0 ? `${count} saved` : 'None saved';
const addressesCountString = _getSavedText(addresses.size);
const phonesCountString = _getSavedText(phones.size);
const [isEditingNom, setEditNom] = useState(false);
@@ -34,7 +35,7 @@ export default function ViewProfile({
const numbersTitle = 'numbers';
return (
<View style={styles.profileFormWrap}>
<ScrollView style={styles.profileFormWrap}>
<View style={styles.avatarWrap}>
{avatar !== null ? (
<Avatar source={{ uri: avatar }} />
@@ -72,12 +73,12 @@ export default function ViewProfile({
<Button title={STRINGS.EDIT} onPress={editProfileAction} />
</View>
)}
</View>
</ScrollView>
);
}
ViewProfile.propTypes = {
addresses: PropTypes.array,
addresses: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]),
avatar: PropTypes.string,
editProfileAction: PropTypes.func,
email: PropTypes.string,
@@ -86,11 +87,11 @@ ViewProfile.propTypes = {
isGeneratedNomDeBid: PropTypes.bool,
isRegisteredAccount: PropTypes.bool,
nomDeBid: PropTypes.string,
phones: PropTypes.array,
phones: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]),
};
ViewProfile.defaultProps = {
addresses: [],
addresses: new List(),
avatar: null,
editProfileAction: null,
email: null,
@@ -99,5 +100,5 @@ ViewProfile.defaultProps = {
isGeneratedNomDeBid: false,
isRegisteredAccount: false,
nomDeBid: null,
phones: [],
phones: new List(),
};