Skip to content

Commit cd902f6

Browse files
authored
Merge pull request Expensify#75906 from software-mansion-labs/@OlGierd03/migrate-NetSuiteCustomListSelectorModal
Make NetSuiteCustomListSelectorModal use new SelectionList
2 parents e3c764d + 7feacee commit cd902f6

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteCustomListSelectorModal.tsx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React, {useMemo} from 'react';
33
import HeaderWithBackButton from '@components/HeaderWithBackButton';
44
import Modal from '@components/Modal';
55
import 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';
88
import useDebouncedState from '@hooks/useDebouncedState';
99
import useLocalize from '@hooks/useLocalize';
1010
import 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

Comments
 (0)