From f0132e8c7a12144f0c82b65b58cd11bd1eae3005 Mon Sep 17 00:00:00 2001 From: ele828 Date: Mon, 7 Aug 2017 17:10:23 +0800 Subject: [PATCH] hide extensionNumber in setting page when there is no available extensionNumber --- src/containers/SettingsPage/index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/containers/SettingsPage/index.js b/src/containers/SettingsPage/index.js index c26a4fc5dd..1f143e1c8c 100644 --- a/src/containers/SettingsPage/index.js +++ b/src/containers/SettingsPage/index.js @@ -26,19 +26,23 @@ function mapToProps(_, { presence, params, }) { + let loginNumber = ''; const loggedIn = auth.loginStatus === loginStatus.loggedIn; - const loginNumber = (loggedIn && + if ( + loggedIn && accountInfo.ready && extensionInfo.ready - ) ? - formatNumber({ - phoneNumber: `${ - accountInfo.mainCompanyNumber - }*${extensionInfo.extensionNumber}`, + ) { + // If no extensionNumber, extensionNumber field needs to be omitted + const extensionNumber = extensionInfo.extensionNumber && + extensionInfo.extensionNumber !== '0' ? extensionInfo.extensionNumber : null; + const phoneNumber = [accountInfo.mainCompanyNumber, extensionNumber].join('*'); + loginNumber = formatNumber({ + phoneNumber: phoneNumber, countryCode: regionSettings.countryCode, areaCode: regionSettings.areaCode, - }) : - ''; + }); + } return { showSpinner: !( accountInfo.ready &&