@@ -9,14 +9,12 @@ import styles from './ContactDescription.module.css';
9
9
10
10
export interface ContactDescriptionProps {
11
11
fields : any ;
12
- settings ? : any ;
13
- phone ? : string ;
14
- maskedPhone ? : string ;
12
+ settings : any ;
13
+ phone : string ;
14
+ maskedPhone : string ;
15
15
collections : any ;
16
- lastMessage ?: string ;
17
- statusMessage ?: string ;
18
- groups ?: boolean ;
19
- customStyles ?: string ;
16
+ lastMessage : string ;
17
+ statusMessage : string ;
20
18
}
21
19
22
20
export const ContactDescription = ( {
@@ -27,15 +25,17 @@ export const ContactDescription = ({
27
25
statusMessage,
28
26
fields,
29
27
settings,
30
- groups = false ,
31
- customStyles,
32
28
} : ContactDescriptionProps ) => {
33
29
const [ showPlainPhone , setShowPlainPhone ] = useState ( false ) ;
34
30
const { t } = useTranslation ( ) ;
35
31
36
32
// list of collections that the contact is assigned
37
33
let assignedToCollection : any = Array . from (
38
- new Set ( [ ] . concat ( ...collections . map ( ( collection : any ) => collection . users . map ( ( user : any ) => user . name ) ) ) )
34
+ new Set (
35
+ [ ] . concat (
36
+ ...collections . map ( ( collection : any ) => collection . users . map ( ( user : any ) => user . name ) )
37
+ )
38
+ )
39
39
) ;
40
40
41
41
if ( assignedToCollection . length > 2 ) {
@@ -49,19 +49,16 @@ export const ContactDescription = ({
49
49
// list of collections that the contact belongs
50
50
const collectionList = collections . map ( ( collection : any ) => collection . label ) . join ( ', ' ) ;
51
51
52
- let collectionDetails = [ { label : t ( 'Collections' ) , value : collectionList || t ( 'None' ) } ] ;
53
- if ( ! groups ) {
54
- collectionDetails = [
55
- ...collectionDetails ,
56
- {
57
- label : t ( 'Assigned to' ) ,
58
- value : assignedToCollection || t ( 'None' ) ,
59
- } ,
60
- ] ;
61
- }
52
+ const collectionDetails = [
53
+ { label : t ( 'Collections' ) , value : collectionList || t ( 'None' ) } ,
54
+ {
55
+ label : t ( 'Assigned to' ) ,
56
+ value : assignedToCollection || t ( 'None' ) ,
57
+ } ,
58
+ ] ;
62
59
63
60
let settingsValue : any = '' ;
64
- if ( settings && typeof settings === 'string' ) {
61
+ if ( typeof settings === 'string' ) {
65
62
settingsValue = JSON . parse ( settings ) ;
66
63
}
67
64
@@ -113,30 +110,23 @@ export const ContactDescription = ({
113
110
) ;
114
111
}
115
112
116
- const numberBlock = (
117
- < >
118
- { ! groups && (
119
- < >
120
- < div className = { styles . DetailBlock } >
121
- < Typography data-testid = "formLabel" variant = "h5" className = { styles . FieldLabel } >
122
- Number
123
- </ Typography >
124
- < div className = { styles . Description } >
125
- { phoneDisplay }
126
- < div className = { styles . SessionTimer } >
127
- < span > { t ( 'Session Timer' ) } </ span >
128
- < Timer time = { lastMessage } variant = "secondary" />
129
- </ div >
130
- </ div >
113
+ return (
114
+ < div className = { styles . DescriptionContainer } data-testid = "contactDescription" >
115
+ < div className = { styles . DetailBlock } >
116
+ < Typography data-testid = "formLabel" variant = "h5" className = { styles . FieldLabel } >
117
+ Number
118
+ </ Typography >
119
+ < div className = { styles . Description } >
120
+ { phoneDisplay }
121
+ < div className = { styles . SessionTimer } >
122
+ < span > { t ( 'Session Timer' ) } </ span >
123
+ < Timer time = { lastMessage } variant = "secondary" />
131
124
</ div >
132
- < div className = { styles . Divider } />
133
- </ >
134
- ) }
135
- </ >
136
- ) ;
125
+ </ div >
126
+ </ div >
127
+
128
+ < div className = { styles . Divider } />
137
129
138
- const collectionBlock = (
139
- < >
140
130
< div className = { styles . DetailBlock } >
141
131
{ collectionDetails . map ( ( collectionItem : any ) => (
142
132
< div key = { collectionItem . label } >
@@ -149,65 +139,38 @@ export const ContactDescription = ({
149
139
</ div >
150
140
151
141
< div className = { styles . Divider } />
152
- </ >
153
- ) ;
154
-
155
- const settingsBlock = (
156
- < >
157
- { settingsValue &&
158
- ! groups &&
159
- typeof settingsValue === 'object' &&
160
- Object . keys ( settingsValue ) . map ( ( key ) => (
161
- < div key = { key } >
162
- < div className = { styles . FieldLabel } > { key } </ div >
163
- < div className = { styles . DescriptionItemValue } >
164
- { Object . keys ( settingsValue [ key ] )
165
- . filter ( ( settingKey ) => settingsValue [ key ] [ settingKey ] === true )
166
- . join ( ', ' ) }
167
- </ div >
168
- < div className = { styles . Divider } />
169
- </ div >
170
- ) ) }
171
- </ >
172
- ) ;
173
142
174
- const statusBlock = (
175
- < >
176
- { ! groups && (
177
- < div className = { styles . DetailBlock } >
178
- < div >
179
- < div className = { styles . FieldLabel } > Status</ div >
180
- < div className = { styles . DescriptionItemValue } > { statusMessage } </ div >
181
- </ div >
182
- < div className = { styles . Divider } />
143
+ < div className = { styles . DetailBlock } >
144
+ < div >
145
+ < div className = { styles . FieldLabel } > Status</ div >
146
+ < div className = { styles . DescriptionItemValue } > { statusMessage } </ div >
183
147
</ div >
184
- ) }
185
- </ >
186
- ) ;
187
-
188
- const fieldsBlock = (
189
- < div className = { styles . DetailBlock } >
190
- { fieldsValue &&
191
- typeof fieldsValue === 'object' &&
192
- Object . keys ( fieldsValue ) . map ( ( key ) => (
193
- < div key = { key } >
194
- < div className = { styles . FieldLabel } >
195
- { fieldsValue [ key ] . label ? fieldsValue [ key ] . label : key . replace ( '_' , ' ' ) }
148
+ < div className = { styles . Divider } />
149
+ { settingsValue &&
150
+ typeof settingsValue === 'object' &&
151
+ Object . keys ( settingsValue ) . map ( ( key ) => (
152
+ < div key = { key } >
153
+ < div className = { styles . FieldLabel } > { key } </ div >
154
+ < div className = { styles . DescriptionItemValue } >
155
+ { Object . keys ( settingsValue [ key ] )
156
+ . filter ( ( settingKey ) => settingsValue [ key ] [ settingKey ] === true )
157
+ . join ( ', ' ) }
158
+ </ div >
159
+ < div className = { styles . Divider } />
196
160
</ div >
197
- < div className = { styles . DescriptionItemValue } > { fieldsValue [ key ] . value } </ div >
198
- < div className = { styles . Divider } />
199
- </ div >
200
- ) ) }
201
- </ div >
202
- ) ;
203
-
204
- return (
205
- < div className = { `${ styles . DescriptionContainer } ${ customStyles } ` } data-testid = "contactDescription" >
206
- { numberBlock }
207
- { collectionBlock }
208
- { settingsBlock }
209
- { statusBlock }
210
- { fieldsBlock }
161
+ ) ) }
162
+ { fieldsValue &&
163
+ typeof fieldsValue === 'object' &&
164
+ Object . keys ( fieldsValue ) . map ( ( key ) => (
165
+ < div key = { key } >
166
+ < div className = { styles . FieldLabel } >
167
+ { fieldsValue [ key ] . label ? fieldsValue [ key ] . label : key . replace ( '_' , ' ' ) }
168
+ </ div >
169
+ < div className = { styles . DescriptionItemValue } > { fieldsValue [ key ] . value } </ div >
170
+ < div className = { styles . Divider } />
171
+ </ div >
172
+ ) ) }
173
+ </ div >
211
174
</ div >
212
175
) ;
213
176
} ;
0 commit comments