Skip to content

Commit

Permalink
Merge pull request #3728 from Expensify/joe-phone-number-display
Browse files Browse the repository at this point in the history
Display phone number on DetailsPage for SMS logins with display names
  • Loading branch information
Clement DAL PALU authored Jun 23, 2021
2 parents 2fdb908 + 6c776e0 commit 35c09f6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ const propTypes = {
...withLocalizePropTypes,
};

/**
* Gets the phone number to display for SMS logins
*
* @param {Object} details
* @param {String} details.login
* @param {String} details.displayName
* @returns {String}
*/
const getPhoneNumber = (details) => {
// If the user hasn't set a displayName, it is set to their phone number, so use that
if (Str.isValidPhone(details.displayName)) {
return details.displayName;
}

// If the user has set a displayName, get the phone number from the SMS login
return Str.removeSMSDomain(details.login);
};

const DetailsPage = ({
personalDetails, route, translate, toLocalPhone,
}) => {
Expand Down Expand Up @@ -87,7 +105,7 @@ const DetailsPage = ({
</Text>
<Text style={[styles.textP]} numberOfLines={1}>
{isSMSLogin
? toLocalPhone(details.displayName)
? toLocalPhone(getPhoneNumber(details))
: details.login}
</Text>
</View>
Expand Down

0 comments on commit 35c09f6

Please sign in to comment.