@@ -3,8 +3,8 @@ import React, {useMemo} from 'react';
33import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
44import Modal from '@components/Modal' ;
55import ScreenWrapper from '@components/ScreenWrapper' ;
6- import SelectionList from '@components/SelectionListWithSections ' ;
7- import RadioListItem from '@components/SelectionListWithSections /RadioListItem' ;
6+ import SelectionList from '@components/SelectionList ' ;
7+ import RadioListItem from '@components/SelectionList/ListItem /RadioListItem' ;
88import useDebouncedState from '@hooks/useDebouncedState' ;
99import useLocalize from '@hooks/useLocalize' ;
1010import type { CustomListSelectorType } from '@pages/workspace/accounting/netsuite/types' ;
@@ -37,8 +37,10 @@ function NetSuiteCustomListSelectorModal({isVisible, currentCustomListValue, onC
3737 const { translate} = useLocalize ( ) ;
3838 const [ searchValue , debouncedSearchValue , setSearchValue ] = useDebouncedState ( '' ) ;
3939
40- const { sections, headerMessage, showTextInput} = useMemo ( ( ) => {
41- const customLists = policy ?. connections ?. netsuite ?. options ?. data ?. customLists ?? [ ] ;
40+ const rawCustomLists = policy ?. connections ?. netsuite ?. options ?. data ?. customLists ;
41+
42+ const { options, showTextInput} = useMemo ( ( ) => {
43+ const customLists = rawCustomLists ?? [ ] ;
4244 const customListData = customLists . map ( ( customListRecord ) => ( {
4345 text : customListRecord . name ,
4446 value : customListRecord . name ,
@@ -52,17 +54,20 @@ function NetSuiteCustomListSelectorModal({isVisible, currentCustomListValue, onC
5254 const isEmpty = debouncedSearchValue . trim ( ) && ! filteredCustomLists . length ;
5355
5456 return {
55- sections : isEmpty
56- ? [ ]
57- : [
58- {
59- data : filteredCustomLists ,
60- } ,
61- ] ,
62- headerMessage : isEmpty ? translate ( 'common.noResultsFound' ) : '' ,
57+ options : isEmpty ? [ ] : filteredCustomLists ,
6358 showTextInput : customListData . length > CONST . STANDARD_LIST_ITEM_LIMIT ,
6459 } ;
65- } , [ debouncedSearchValue , policy ?. connections ?. netsuite ?. options ?. data ?. customLists , translate , currentCustomListValue ] ) ;
60+ } , [ debouncedSearchValue , rawCustomLists , currentCustomListValue ] ) ;
61+
62+ const textInputOptions = useMemo (
63+ ( ) => ( {
64+ value : searchValue ,
65+ label : showTextInput ? translate ( 'common.search' ) : undefined ,
66+ onChangeText : setSearchValue ,
67+ headerMessage : debouncedSearchValue . trim ( ) && options . length === 0 ? translate ( 'common.noResultsFound' ) : '' ,
68+ } ) ,
69+ [ searchValue , showTextInput , translate , setSearchValue , debouncedSearchValue , options . length ] ,
70+ ) ;
6671
6772 return (
6873 < Modal
@@ -84,17 +89,13 @@ function NetSuiteCustomListSelectorModal({isVisible, currentCustomListValue, onC
8489 onBackButtonPress = { onClose }
8590 />
8691 < SelectionList
87- sections = { sections }
88- textInputValue = { searchValue }
89- textInputLabel = { showTextInput ? translate ( 'common.search' ) : undefined }
90- onChangeText = { setSearchValue }
92+ data = { options }
93+ textInputOptions = { textInputOptions }
9194 onSelectRow = { onCustomListSelected }
92- headerMessage = { headerMessage }
9395 ListItem = { RadioListItem }
94- initiallyFocusedOptionKey = { currentCustomListValue }
96+ initiallyFocusedItemKey = { currentCustomListValue }
9597 shouldSingleExecuteRowSelect
9698 shouldStopPropagation
97- shouldUseDynamicMaxToRenderPerBatch
9899 addBottomSafeAreaPadding
99100 />
100101 </ ScreenWrapper >
0 commit comments