diff --git a/src/pages/DetailsPage.js b/src/pages/DetailsPage.js index 4f78e9c3b869..2b5be4121760 100755 --- a/src/pages/DetailsPage.js +++ b/src/pages/DetailsPage.js @@ -87,138 +87,137 @@ const getPhoneNumber = (details) => { return details.login ? Str.removeSMSDomain(details.login) : ''; }; -class DetailsPage extends React.PureComponent { - render() { - const login = lodashGet(this.props.route.params, 'login', ''); - let details = _.find(this.props.personalDetails, (detail) => detail.login === login.toLowerCase()); - - if (!details) { - // TODO: these personal details aren't in my local test account but are in - // my staging account, i wonder why! - if (login === CONST.EMAIL.CONCIERGE) { - details = { - accountID: CONST.ACCOUNT_ID.CONCIERGE, - login, - displayName: 'Concierge', - avatar: UserUtils.getDefaultAvatar(CONST.ACCOUNT_ID.CONCIERGE), - }; - } else { - details = { - accountID: -1, - login, - displayName: login, - avatar: UserUtils.getDefaultAvatar(), - }; - } +function DetailsPage(props) { + const login = lodashGet(props.route.params, 'login', ''); + let details = _.find(props.personalDetails, (detail) => detail.login === login.toLowerCase()); + + if (!details) { + // TODO: these personal details aren't in my local test account but are in + // my staging account, i wonder why! + if (login === CONST.EMAIL.CONCIERGE) { + details = { + accountID: CONST.ACCOUNT_ID.CONCIERGE, + login, + displayName: 'Concierge', + avatar: UserUtils.getDefaultAvatar(CONST.ACCOUNT_ID.CONCIERGE), + }; + } else { + details = { + accountID: -1, + login, + displayName: login, + avatar: UserUtils.getDefaultAvatar(), + }; } + } - const isSMSLogin = details.login ? Str.isSMSLogin(details.login) : false; + const isSMSLogin = details.login ? Str.isSMSLogin(details.login) : false; - const shouldShowLocalTime = !ReportUtils.hasAutomatedExpensifyAccountIDs([details.accountID]) && details.timezone; - let pronouns = details.pronouns; + const shouldShowLocalTime = !ReportUtils.hasAutomatedExpensifyAccountIDs([details.accountID]) && details.timezone; + let pronouns = details.pronouns; - if (pronouns && pronouns.startsWith(CONST.PRONOUNS.PREFIX)) { - const localeKey = pronouns.replace(CONST.PRONOUNS.PREFIX, ''); - pronouns = this.props.translate(`pronouns.${localeKey}`); - } + if (pronouns && pronouns.startsWith(CONST.PRONOUNS.PREFIX)) { + const localeKey = pronouns.replace(CONST.PRONOUNS.PREFIX, ''); + pronouns = props.translate(`pronouns.${localeKey}`); + } - const phoneNumber = getPhoneNumber(details); - const phoneOrEmail = isSMSLogin ? getPhoneNumber(details) : details.login; - - const isCurrentUser = _.keys(this.props.loginList).includes(details.login); - - return ( - - - Navigation.goBack(ROUTES.HOME)} - /> - - {details ? ( - - - + + Navigation.goBack(ROUTES.HOME)} + /> + + {details ? ( + + + + {({show}) => ( + + + + + + )} + + {Boolean(details.displayName) && ( + - {({show}) => ( - - - - - - )} - - {Boolean(details.displayName) && ( + {details.displayName} + + )} + {details.login ? ( + - {details.displayName} + {props.translate(isSMSLogin ? 'common.phoneNumber' : 'common.email')} - )} - {details.login ? ( - - - {this.props.translate(isSMSLogin ? 'common.phoneNumber' : 'common.email')} - - - - {isSMSLogin ? this.props.formatPhoneNumber(phoneNumber) : details.login} - - - - ) : null} - {pronouns ? ( - - - {this.props.translate('profilePage.preferredPronouns')} - - {pronouns} - - ) : null} - {shouldShowLocalTime && } - - {!isCurrentUser && ( - Report.navigateToAndOpenReport([login])} - wrapperStyle={styles.breakAll} - shouldShowRightIcon - /> - )} - - ) : null} - - - - ); - } + + + {isSMSLogin ? props.formatPhoneNumber(phoneNumber) : details.login} + + + + ) : null} + {pronouns ? ( + + + {props.translate('profilePage.preferredPronouns')} + + {pronouns} + + ) : null} + {shouldShowLocalTime && } + + {!isCurrentUser && ( + Report.navigateToAndOpenReport([login])} + wrapperStyle={styles.breakAll} + shouldShowRightIcon + /> + )} + + ) : null} + + + + ); } DetailsPage.propTypes = propTypes; DetailsPage.defaultProps = defaultProps; +DetailsPage.displayName = 'DetailsPage'; export default compose( withLocalize,