@@ -240,6 +240,23 @@ const TestSearch = () => {
240240 }
241241 } , [ testTypeQuery . error , activityIdQuery . error ] ) ;
242242
243+ const testTypeItems = React . useMemo (
244+ ( ) => (
245+ testTypeQuery . data
246+ ? testTypeQuery . data . map ( ( type : string ) => ( {
247+ id : type ,
248+ text : type
249+ } ) )
250+ : [ ]
251+ ) ,
252+ [ testTypeQuery . data ]
253+ ) ;
254+
255+ const activityIdItems = React . useMemo (
256+ ( ) => ( activityIdQuery . data ? activityIdQuery . data . map ( ( id ) => ( { id, text : id } ) ) : [ ] ) ,
257+ [ activityIdQuery . data ]
258+ ) ;
259+
243260 const handlePageChange = ( pageIndex : number , pageSize : number ) => {
244261 const sort = sorting [ 0 ] ;
245262 searchMutation . mutate (
@@ -506,14 +523,7 @@ const TestSearch = () => {
506523 id = "test-type-input"
507524 className = "test-type-input"
508525 titleText = "Test type"
509- items = {
510- testTypeQuery . data
511- ? testTypeQuery . data . map ( ( type : string ) => ( {
512- id : type ,
513- text : type
514- } ) )
515- : [ ]
516- }
526+ items = { testTypeItems }
517527 itemToString = { ( item : { id : string ; text : string } | null ) => ( item ? item . text : '' ) }
518528 onChange = { ( event : { selectedItems : Array < { id : string } > } ) => {
519529 handleMultiSelectChanges ( 'testTypes' , event . selectedItems . map ( ( it : { id : string } ) => it . id ) ) ;
@@ -524,11 +534,7 @@ const TestSearch = () => {
524534 id = "activity-type-input"
525535 className = "activity-type-input"
526536 titleText = "Choose activity"
527- items = {
528- activityIdQuery . data
529- ? activityIdQuery . data . map ( ( id ) => ( { id, text : id } ) )
530- : [ ]
531- }
537+ items = { activityIdItems }
532538 itemToString = { ( item : { id : string ; text : string } | null ) => ( item ? item . text : '' ) }
533539 onChange = { ( event : { selectedItems : Array < { id : string } > } ) => {
534540 handleMultiSelectChanges ( 'activityIds' , event . selectedItems . map ( ( it : { id : string } ) => it . id ) ) ;
0 commit comments