Skip to content

Commit

Permalink
display phone number on display page for SMS accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jag96 committed Jun 23, 2021
1 parent 2fdb908 commit a5fec46
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ const propTypes = {
...withLocalizePropTypes,
};

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

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

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

0 comments on commit a5fec46

Please sign in to comment.