11import React , { useState } from 'react' ;
22import { Text , ListNext , TextInput , Button , ButtonCircle , TooltipNext } from '@momentum-ui/react-collaboration' ;
3- import { Icon , Checkbox } from '@momentum-design/components/dist/react' ;
3+ import { Icon , Checkbox , Spinner } from '@momentum-design/components/dist/react' ;
44import ConsultTransferListComponent from './consult-transfer-list-item' ;
55import { ConsultTransferPopoverComponentProps } from '../../task.types' ;
66import ConsultTransferEmptyState from './consult-transfer-empty-state' ;
@@ -16,9 +16,6 @@ import {
1616 SEARCH_PLACEHOLDER ,
1717 CLEAR_SEARCH ,
1818 SCROLL_TO_LOAD_MORE ,
19- LOADING_MORE_QUEUES ,
20- LOADING_MORE_DIAL_NUMBERS ,
21- LOADING_MORE_ENTRY_POINTS ,
2219 NO_DATA_AVAILABLE_CONSULT_TRANSFER ,
2320} from '../../constants' ;
2421import { CATEGORY_AGENTS , CATEGORY_DIAL_NUMBER , CATEGORY_ENTRY_POINT , CATEGORY_QUEUES } from '../../task.types' ;
@@ -27,6 +24,8 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
2724 heading,
2825 buttonIcon,
2926 buddyAgents,
27+ loadingBuddyAgents,
28+ loadBuddyAgents,
3029 getAddressBookEntries,
3130 getEntryPoints,
3231 getQueues,
@@ -59,6 +58,7 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
5958 handleQueuesClick,
6059 handleDialNumberClick,
6160 handleEntryPointClick,
61+ handleReload,
6262 } = useConsultTransferPopover ( {
6363 showDialNumberTab,
6464 showEntryPointTab : isEntryPointTabVisible ,
@@ -122,6 +122,37 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
122122 aria-labelledby = "consult-search-label"
123123 className = "consult-search-input"
124124 />
125+ < div className = "consult-action-buttons" >
126+ < TooltipNext
127+ key = { `reload-button-${ selectedCategory } ` }
128+ triggerComponent = {
129+ < ButtonCircle
130+ className = "consult-reload-button call-control-button"
131+ aria-label = { `Reload ${ selectedCategory } ` }
132+ size = { 32 }
133+ data-testid = "consult-reload-button"
134+ onPress = { ( ) => {
135+ if ( selectedCategory === CATEGORY_AGENTS && loadBuddyAgents ) {
136+ loadBuddyAgents ( ) ;
137+ } else {
138+ handleReload ( ) ;
139+ }
140+ } }
141+ disabled = { loadingBuddyAgents || loadingDialNumbers || loadingEntryPoints || loadingQueues }
142+ >
143+ < Icon name = "refresh-bold" />
144+ </ ButtonCircle >
145+ }
146+ color = "secondary"
147+ delay = { [ 0 , 0 ] }
148+ placement = "bottom-start"
149+ type = "description"
150+ variant = "small"
151+ className = "tooltip"
152+ >
153+ < Text tagName = "p" > { `Reload ${ selectedCategory } ` } </ Text >
154+ </ TooltipNext >
155+ </ div >
125156 { consultTransferManualAction . visible && (
126157 < TooltipNext
127158 triggerComponent = {
@@ -199,7 +230,11 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
199230
200231 < div className = "consult-list-container" >
201232 { selectedCategory === 'Agents' &&
202- ( getAgentsForDisplay ( selectedCategory , buddyAgents , searchQuery ) . length === 0 ? (
233+ ( loadingBuddyAgents ? (
234+ < div className = "consult-loading-spinner" >
235+ < Spinner />
236+ </ div >
237+ ) : getAgentsForDisplay ( selectedCategory , buddyAgents , searchQuery ) . length === 0 ? (
203238 < ConsultTransferEmptyState message = { NO_DATA_AVAILABLE_CONSULT_TRANSFER } />
204239 ) : (
205240 renderList (
@@ -212,7 +247,11 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
212247 ) ) }
213248
214249 { selectedCategory === 'Queues' &&
215- ( noQueues ? (
250+ ( loadingQueues && queuesData . length === 0 ? (
251+ < div className = "consult-loading-spinner" >
252+ < Spinner />
253+ </ div >
254+ ) : noQueues ? (
216255 < ConsultTransferEmptyState message = { NO_DATA_AVAILABLE_CONSULT_TRANSFER } />
217256 ) : (
218257 < div >
@@ -223,9 +262,9 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
223262 { hasMoreQueues && (
224263 < div ref = { loadMoreRef } className = "consult-load-more" >
225264 { loadingQueues ? (
226- < Text tagName = "small" type = "body-secondary ">
227- { LOADING_MORE_QUEUES }
228- </ Text >
265+ < div className = "consult-loading-spinner ">
266+ < Spinner />
267+ </ div >
229268 ) : (
230269 < Text tagName = "small" type = "body-secondary" >
231270 { SCROLL_TO_LOAD_MORE }
@@ -238,7 +277,11 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
238277
239278 { showDialNumberTab &&
240279 selectedCategory === CATEGORY_DIAL_NUMBER &&
241- ( noDialNumbers ? (
280+ ( loadingDialNumbers && dialNumbers . length === 0 ? (
281+ < div className = "consult-loading-spinner" >
282+ < Spinner />
283+ </ div >
284+ ) : noDialNumbers ? (
242285 < ConsultTransferEmptyState message = { NO_DATA_AVAILABLE_CONSULT_TRANSFER } />
243286 ) : (
244287 < div >
@@ -253,9 +296,9 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
253296 { hasMoreDialNumbers && (
254297 < div ref = { loadMoreRef } className = "consult-load-more" >
255298 { loadingDialNumbers ? (
256- < Text tagName = "small" type = "body-secondary ">
257- { LOADING_MORE_DIAL_NUMBERS }
258- </ Text >
299+ < div className = "consult-loading-spinner ">
300+ < Spinner />
301+ </ div >
259302 ) : (
260303 < Text tagName = "small" type = "body-secondary" >
261304 { SCROLL_TO_LOAD_MORE }
@@ -268,7 +311,11 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
268311
269312 { isEntryPointTabVisible &&
270313 selectedCategory === CATEGORY_ENTRY_POINT &&
271- ( noEntryPoints ? (
314+ ( loadingEntryPoints && entryPoints . length === 0 ? (
315+ < div className = "consult-loading-spinner" >
316+ < Spinner />
317+ </ div >
318+ ) : noEntryPoints ? (
272319 < ConsultTransferEmptyState message = { NO_DATA_AVAILABLE_CONSULT_TRANSFER } />
273320 ) : (
274321 < div >
@@ -281,9 +328,9 @@ const ConsultTransferPopoverComponent: React.FC<ConsultTransferPopoverComponentP
281328 { hasMoreEntryPoints && (
282329 < div ref = { loadMoreRef } className = "consult-load-more" >
283330 { loadingEntryPoints ? (
284- < Text tagName = "small" type = "body-secondary ">
285- { LOADING_MORE_ENTRY_POINTS }
286- </ Text >
331+ < div className = "consult-loading-spinner ">
332+ < Spinner />
333+ </ div >
287334 ) : (
288335 < Text tagName = "small" type = "body-secondary" >
289336 { SCROLL_TO_LOAD_MORE }
0 commit comments