11import React , { useCallback , useEffect , useMemo , useState } from 'react' ;
2- import type { SectionListData } from 'react-native' ;
32import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton' ;
43import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
54import ScreenWrapper from '@components/ScreenWrapper' ;
6- // eslint-disable-next-line no-restricted-imports
7- import SelectionList from '@components/SelectionListWithSections' ;
8- import InviteMemberListItem from '@components/SelectionListWithSections/InviteMemberListItem' ;
9- import type { Section } from '@components/SelectionListWithSections/types' ;
5+ import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMemberListItem' ;
6+ import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections' ;
7+ import type { Section } from '@components/SelectionList/SelectionListWithSections/types' ;
108import withNavigationTransitionEnd from '@components/withNavigationTransitionEnd' ;
119import type { WithNavigationTransitionEndProps } from '@components/withNavigationTransitionEnd' ;
1210import useLocalize from '@hooks/useLocalize' ;
@@ -39,8 +37,6 @@ import AccessOrNotFoundWrapper from './AccessOrNotFoundWrapper';
3937import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading' ;
4038import type { WithPolicyAndFullscreenLoadingProps } from './withPolicyAndFullscreenLoading' ;
4139
42- type Sections = SectionListData < OptionData , Section < OptionData > > ;
43-
4440type WorkspaceInvitePageProps = WithPolicyAndFullscreenLoadingProps &
4541 WithNavigationTransitionEndProps &
4642 PlatformStackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . INVITE > ;
@@ -123,8 +119,8 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
123119 initialSelected : initiallySelectedOptions ,
124120 } ) ;
125121
126- const sections : Sections [ ] = useMemo ( ( ) => {
127- const sectionsArr : Sections [ ] = [ ] ;
122+ const sections : Array < Section < OptionData > > = useMemo ( ( ) => {
123+ const sectionsArr = [ ] ;
128124
129125 if ( ! areOptionsInitialized ) {
130126 return [ ] ;
@@ -135,6 +131,7 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
135131 sectionsArr . push ( {
136132 title : undefined ,
137133 data : selectedOptionsForDisplay ,
134+ sectionIndex : 0 ,
138135 } ) ;
139136 }
140137
@@ -143,6 +140,7 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
143140 sectionsArr . push ( {
144141 title : translate ( 'common.contacts' ) ,
145142 data : availableOptions . personalDetails ,
143+ sectionIndex : 1 ,
146144 } ) ;
147145 }
148146
@@ -151,6 +149,7 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
151149 sectionsArr . push ( {
152150 title : undefined ,
153151 data : [ availableOptions . userToInvite ] ,
152+ sectionIndex : 2 ,
154153 } ) ;
155154 }
156155
@@ -239,6 +238,16 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
239238 searchInServer ( debouncedSearchTerm ) ;
240239 } , [ debouncedSearchTerm ] ) ;
241240
241+ const textInputOptions = useMemo (
242+ ( ) => ( {
243+ label : translate ( 'selectionList.nameEmailOrPhoneNumber' ) ,
244+ value : searchTerm ,
245+ onChangeText : setSearchTerm ,
246+ headerMessage,
247+ } ) ,
248+ [ searchTerm , setSearchTerm , headerMessage , translate ] ,
249+ ) ;
250+
242251 return (
243252 < AccessOrNotFoundWrapper
244253 policyID = { route . params . policyID }
@@ -260,25 +269,23 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
260269 Navigation . goBack ( route . params . backTo ) ;
261270 } }
262271 />
263- < SelectionList
272+ < SelectionListWithSections
264273 canSelectMultiple
265274 sections = { sections }
266275 ListItem = { InviteMemberListItem }
267- textInputLabel = { translate ( 'selectionList.nameEmailOrPhoneNumber' ) }
268- textInputValue = { searchTerm }
269- onChangeText = { ( value ) => {
270- setSearchTerm ( value ) ;
271- } }
272- headerMessage = { headerMessage }
273276 onSelectRow = { handleToggleSelection }
274- onConfirm = { inviteUser }
275- showScrollIndicator
277+ shouldShowTextInput
278+ textInputOptions = { textInputOptions }
279+ confirmButtonOptions = { {
280+ onConfirm : inviteUser ,
281+ } }
276282 showLoadingPlaceholder = { ! areOptionsInitialized || ! didScreenTransitionEnd }
277283 shouldPreventDefaultFocusOnSelectRow = { ! canUseTouchScreen ( ) }
278284 footerContent = { footerContent }
279285 isLoadingNewOptions = { ! ! isSearchingForReports }
280286 addBottomSafeAreaPadding
281287 onEndReached = { onListEndReached }
288+ disableMaintainingScrollPosition
282289 />
283290 </ ScreenWrapper >
284291 </ AccessOrNotFoundWrapper >
0 commit comments