@@ -2,16 +2,30 @@ import React from 'react';
22import PropTypes from 'prop-types' ;
33import classnames from 'classnames' ;
44import formatNumber from 'ringcentral-integration/lib/formatNumber' ;
5+ import formatMessage from 'format-message' ;
56import DropdownSelect from '../DropdownSelect' ;
67import i18n from './i18n' ;
78import styles from './styles.scss' ;
89import phoneSourceNames from '../../lib/phoneSourceNames' ;
910
10- const displayFomatter = ( { entityName, entityType, phoneNumber } ) => {
11+ const displayFomatter = ( {
12+ entityName,
13+ entityType,
14+ phoneNumber,
15+ currentLocale,
16+ brand,
17+ } ) => {
18+ let typeName ;
19+ if ( entityType ) {
20+ typeName = formatMessage (
21+ phoneSourceNames . getString ( entityType , currentLocale ) ,
22+ { brand }
23+ ) ;
24+ }
1125 if ( phoneNumber && entityName && entityType ) {
12- return `${ entityName } | ${ phoneSourceNames . getString ( entityType ) } ${ phoneNumber } ` ;
26+ return `${ entityName } | ${ typeName } ${ phoneNumber } ` ;
1327 } else if ( entityName && entityType ) {
14- return `${ entityName } | ${ phoneSourceNames . getString ( entityType ) } ` ;
28+ return `${ entityName } | ${ typeName } ` ;
1529 } else if ( entityName ) {
1630 return entityName ;
1731 } else if ( phoneNumber ) {
@@ -36,6 +50,8 @@ export default function ContactDisplay({
3650 groupNumbers,
3751 showType,
3852 selectClassName,
53+ showPlaceholder,
54+ brand,
3955} ) {
4056 let contentEl ;
4157 if ( groupNumbers ) {
@@ -76,31 +92,41 @@ export default function ContactDisplay({
7692 const options = [
7793 ...contactMatches ,
7894 ] ;
95+ let placeholder ;
96+ if ( showPlaceholder ) {
97+ placeholder = i18n . getString ( 'select' , currentLocale ) ;
98+ }
7999 contentEl = (
80100 < DropdownSelect
81101 className = { classnames ( styles . select , selectClassName ) }
82102 value = { `${ selected } ` }
83103 onChange = { onSelectContact }
84104 disabled = { disabled || isLogging }
85105 options = { options }
86- placeholder = { i18n . getString ( 'select' , currentLocale ) }
106+ placeholder = { placeholder }
87107 renderFunction = { entity => (
88108 displayFomatter ( {
89109 entityName : entity . name ,
90110 entityType : entity . entityType ,
111+ brand,
112+ currentLocale,
91113 } )
92114 ) }
93115 renderValue = { value => (
94116 displayFomatter ( {
95117 entityName : options [ value ] . name ,
96118 entityType : showType && options [ value ] . entityType ,
119+ brand,
120+ currentLocale,
97121 } )
98122 ) }
99123 renderTitle = { entity => (
100124 entity ? displayFomatter ( {
101125 entityName : entity . name ,
102126 entityType : entity . entityType ,
103127 phoneNumber,
128+ brand,
129+ currentLocale,
104130 } ) : phoneNumber )
105131 }
106132 dropdownAlign = "left"
@@ -136,6 +162,8 @@ ContactDisplay.propTypes = {
136162 groupNumbers : PropTypes . arrayOf ( PropTypes . string ) ,
137163 showType : PropTypes . bool ,
138164 selectClassName : PropTypes . string ,
165+ showPlaceholder : PropTypes . bool ,
166+ brand : PropTypes . string ,
139167} ;
140168ContactDisplay . defaultProps = {
141169 className : undefined ,
@@ -146,4 +174,6 @@ ContactDisplay.defaultProps = {
146174 enableContactFallback : undefined ,
147175 showType : true ,
148176 selectClassName : undefined ,
177+ showPlaceholder : true ,
178+ brand : undefined ,
149179} ;
0 commit comments