11import React , { useCallback , useMemo , useState } from 'react' ;
22import FormHelpMessage from '@components/FormHelpMessage' ;
3- import SelectionList from '@components/SelectionListWithSections ' ;
4- import SingleSelectListItem from '@components/SelectionListWithSections /SingleSelectListItem' ;
5- import type { ListItem } from '@components/SelectionListWithSections /types' ;
3+ import SelectionList from '@components/SelectionList ' ;
4+ import SingleSelectListItem from '@components/SelectionList/ListItem /SingleSelectListItem' ;
5+ import type { ListItem } from '@components/SelectionList /types' ;
66import useDebouncedState from '@hooks/useDebouncedState' ;
77import useLocalize from '@hooks/useLocalize' ;
88import useThemeStyles from '@hooks/useThemeStyles' ;
@@ -25,8 +25,8 @@ function CustomCloseDateSelectionList({initiallySelectedDay, onConfirmSelectedDa
2525 const [ searchValue , debouncedSearchValue , setSearchValue ] = useDebouncedState ( '' ) ;
2626 const [ error , setError ] = useState < string | undefined > ( undefined ) ;
2727
28- const { sections , headerMessage } = useMemo ( ( ) => {
29- const data = CONST . DATE . MONTH_DAYS . reduce < CustomCloseDateListItem [ ] > ( ( days , dayValue ) => {
28+ const data = useMemo ( ( ) => {
29+ return CONST . DATE . MONTH_DAYS . reduce < CustomCloseDateListItem [ ] > ( ( days , dayValue ) => {
3030 const day = {
3131 value : dayValue ,
3232 text : dayValue . toString ( ) ,
@@ -44,12 +44,7 @@ function CustomCloseDateSelectionList({initiallySelectedDay, onConfirmSelectedDa
4444
4545 return days ;
4646 } , [ ] ) ;
47-
48- return {
49- sections : [ { data, indexOffset : 0 } ] ,
50- headerMessage : data . length === 0 ? translate ( 'common.noResultsFound' ) : undefined ,
51- } ;
52- } , [ selectedDay , debouncedSearchValue , translate ] ) ;
47+ } , [ selectedDay , debouncedSearchValue ] ) ;
5348
5449 const selectDayAndClearError = useCallback ( ( item : CustomCloseDateListItem ) => {
5550 setSelectedDay ( item . value ) ;
@@ -65,25 +60,39 @@ function CustomCloseDateSelectionList({initiallySelectedDay, onConfirmSelectedDa
6560 onConfirmSelectedDay ( selectedDay ) ;
6661 } , [ selectedDay , onConfirmSelectedDay , translate ] ) ;
6762
63+ const textInputOptions = useMemo (
64+ ( ) => ( {
65+ label : translate ( 'common.search' ) ,
66+ value : searchValue ,
67+ onChangeText : setSearchValue ,
68+ headerMessage : data . length === 0 ? translate ( 'common.noResultsFound' ) : undefined ,
69+ } ) ,
70+ [ translate , searchValue , data . length , setSearchValue ] ,
71+ ) ;
72+
73+ const confirmButtonOptions = useMemo (
74+ ( ) => ( {
75+ showButton : true ,
76+ text : translate ( 'common.save' ) ,
77+ onConfirm : confirmSelectedDay ,
78+ style : styles . mt3 ,
79+ } ) ,
80+ [ translate , confirmSelectedDay , styles . mt3 ] ,
81+ ) ;
82+
6883 return (
6984 < SelectionList
85+ data = { data }
7086 ListItem = { SingleSelectListItem }
7187 onSelectRow = { selectDayAndClearError }
72- shouldShowListEmptyContent = { false }
73- sections = { sections }
88+ initiallyFocusedItemKey = { initiallySelectedDay ?. toString ( ) }
89+ confirmButtonOptions = { confirmButtonOptions }
90+ textInputOptions = { textInputOptions }
91+ showListEmptyContent = { false }
92+ disableMaintainingScrollPosition
7493 shouldSingleExecuteRowSelect
75- initiallyFocusedOptionKey = { initiallySelectedDay ?. toString ( ) }
7694 shouldUpdateFocusedIndex
77- showConfirmButton
78- confirmButtonText = { translate ( 'common.save' ) }
79- onConfirm = { confirmSelectedDay }
80- confirmButtonStyles = { styles . mt3 }
8195 addBottomSafeAreaPadding
82- shouldShowTextInput
83- textInputLabel = { translate ( 'common.search' ) }
84- textInputValue = { searchValue }
85- onChangeText = { setSearchValue }
86- headerMessage = { headerMessage }
8796 >
8897 { ! ! error && (
8998 < FormHelpMessage
0 commit comments