@@ -39,7 +39,7 @@ type useQueryType = (
3939 itemsPerPage : 25 | 50 | 100 ;
4040 current : number ;
4141 } ,
42- customFields : { [ key : string ] : string } ,
42+ customFields : { [ key : string ] : string } | undefined ,
4343 [ column , direction ] : [ string , 'asc' | 'desc' ] ,
4444) => LivechatRoomsProps | undefined ;
4545
@@ -101,7 +101,7 @@ const useQuery: useQueryType = (
101101 }
102102
103103 if ( customFields && Object . keys ( customFields ) . length > 0 ) {
104- const customFieldsQuery = Object . fromEntries ( Object . entries ( customFields ) . filter ( ( item ) => item [ 1 ] !== '' ) ) ;
104+ const customFieldsQuery = Object . fromEntries ( Object . entries ( customFields ) . filter ( ( item ) => item [ 1 ] !== undefined && item [ 1 ] !== '' ) ) ;
105105 if ( Object . keys ( customFieldsQuery ) . length > 0 ) {
106106 query . customFields = JSON . stringify ( customFieldsQuery ) ;
107107 }
@@ -112,7 +112,7 @@ const useQuery: useQueryType = (
112112
113113const CurrentChatsRoute = ( ) : ReactElement => {
114114 const { sortBy, sortDirection, setSort } = useSort < 'fname' | 'departmentId' | 'servedBy' | 'ts' | 'lm' | 'open' > ( 'fname' ) ;
115- const [ customFields , setCustomFields ] = useState < { [ key : string ] : string } > ( { } ) ;
115+ const [ customFields , setCustomFields ] = useState < { [ key : string ] : string } > ( ) ;
116116 const [ params , setParams ] = useState ( {
117117 guest : '' ,
118118 fname : '' ,
@@ -128,12 +128,6 @@ const CurrentChatsRoute = (): ReactElement => {
128128 const t = useTranslation ( ) ;
129129 const id = useRouteParameter ( 'id' ) ;
130130
131- const onHeaderClick = useMutableCallback ( ( id ) => {
132- if ( sortBy === id ) {
133- setSort ( id , sortDirection === 'asc' ? 'desc' : 'asc' ) ;
134- }
135- } ) ;
136-
137131 const debouncedParams = useDebouncedValue ( params , 500 ) ;
138132 const debouncedCustomFields = useDebouncedValue ( customFields , 500 ) ;
139133
@@ -224,7 +218,7 @@ const CurrentChatsRoute = (): ReactElement => {
224218 key = 'fname'
225219 direction = { sortDirection }
226220 active = { sortBy === 'fname' }
227- onClick = { onHeaderClick }
221+ onClick = { setSort }
228222 sort = 'fname'
229223 data-qa = 'current-chats-header-name'
230224 >
@@ -234,7 +228,7 @@ const CurrentChatsRoute = (): ReactElement => {
234228 key = 'departmentId'
235229 direction = { sortDirection }
236230 active = { sortBy === 'departmentId' }
237- onClick = { onHeaderClick }
231+ onClick = { setSort }
238232 sort = 'departmentId'
239233 data-qa = 'current-chats-header-department'
240234 >
@@ -244,7 +238,7 @@ const CurrentChatsRoute = (): ReactElement => {
244238 key = 'servedBy'
245239 direction = { sortDirection }
246240 active = { sortBy === 'servedBy' }
247- onClick = { onHeaderClick }
241+ onClick = { setSort }
248242 sort = 'servedBy'
249243 data-qa = 'current-chats-header-servedBy'
250244 >
@@ -254,7 +248,7 @@ const CurrentChatsRoute = (): ReactElement => {
254248 key = 'ts'
255249 direction = { sortDirection }
256250 active = { sortBy === 'ts' }
257- onClick = { onHeaderClick }
251+ onClick = { setSort }
258252 sort = 'ts'
259253 data-qa = 'current-chats-header-startedAt'
260254 >
@@ -264,7 +258,7 @@ const CurrentChatsRoute = (): ReactElement => {
264258 key = 'lm'
265259 direction = { sortDirection }
266260 active = { sortBy === 'lm' }
267- onClick = { onHeaderClick }
261+ onClick = { setSort }
268262 sort = 'lm'
269263 data-qa = 'current-chats-header-lastMessage'
270264 >
@@ -274,7 +268,7 @@ const CurrentChatsRoute = (): ReactElement => {
274268 key = 'open'
275269 direction = { sortDirection }
276270 active = { sortBy === 'open' }
277- onClick = { onHeaderClick }
271+ onClick = { setSort }
278272 sort = 'open'
279273 w = 'x100'
280274 data-qa = 'current-chats-header-status'
0 commit comments