-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Make ReportChangeWorkspacePage use new SelectionList
#75378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e3b2837
f8bcf20
933290c
606a12d
f4150ac
7d7f03e
d931f6c
4a152a9
8ca6428
09a301c
b7d87f8
0e0808b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| import React, {useCallback} from 'react'; | ||
| import React, {useCallback, useMemo} from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import {useSession} from '@components/OnyxListItemProvider'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import SelectionList from '@components/SelectionListWithSections'; | ||
| import UserListItem from '@components/SelectionListWithSections/UserListItem'; | ||
| import SelectionList from '@components/SelectionList'; | ||
| import type {WorkspaceListItemType} from '@components/SelectionList/ListItem/types'; | ||
| import UserListItem from '@components/SelectionList/ListItem/UserListItem'; | ||
| import useDebouncedState from '@hooks/useDebouncedState'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useNetwork from '@hooks/useNetwork'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import usePermissions from '@hooks/usePermissions'; | ||
| import useReportIsArchived from '@hooks/useReportIsArchived'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import type {WorkspaceListItem} from '@hooks/useWorkspaceList'; | ||
| import useWorkspaceList from '@hooks/useWorkspaceList'; | ||
| import {changeReportPolicy, changeReportPolicyAndInviteSubmitter, moveIOUReportToPolicy, moveIOUReportToPolicyAndInviteSubmitter} from '@libs/actions/Report'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
@@ -125,7 +125,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro | |
| ], | ||
| ); | ||
|
|
||
| const {sections, shouldShowNoResultsFoundMessage, shouldShowSearchInput} = useWorkspaceList({ | ||
| const {data, shouldShowNoResultsFoundMessage, shouldShowSearchInput} = useWorkspaceList({ | ||
| policies, | ||
| currentUserLogin: session?.email, | ||
| shouldShowPendingDeletePolicy: false, | ||
|
|
@@ -135,6 +135,16 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro | |
| additionalFilter: (newPolicy) => isWorkspaceEligibleForReportChange(submitterEmail, newPolicy), | ||
| }); | ||
|
|
||
| const textInputOptions = useMemo( | ||
| () => ({ | ||
| label: shouldShowSearchInput ? translate('common.search') : undefined, | ||
| value: searchTerm, | ||
| onChangeText: setSearchTerm, | ||
| headerMessage: shouldShowNoResultsFoundMessage ? translate('common.noResultsFound') : '', | ||
| }), | ||
| [searchTerm, setSearchTerm, shouldShowNoResultsFoundMessage, shouldShowSearchInput, translate], | ||
| ); | ||
|
|
||
| if (!isMoneyRequestReport(report) || isMoneyRequestReportPendingDeletion(report)) { | ||
| return <NotFoundPage />; | ||
| } | ||
|
|
@@ -157,16 +167,14 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro | |
| {shouldShowLoadingIndicator ? ( | ||
| <FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} /> | ||
| ) : ( | ||
| <SelectionList<WorkspaceListItem> | ||
| <SelectionList<WorkspaceListItemType> | ||
| ListItem={UserListItem} | ||
| sections={sections} | ||
| data={data} | ||
| onSelectRow={(option) => selectPolicy(option.policyID)} | ||
| textInputLabel={shouldShowSearchInput ? translate('common.search') : undefined} | ||
| textInputValue={searchTerm} | ||
| onChangeText={setSearchTerm} | ||
| headerMessage={shouldShowNoResultsFoundMessage ? translate('common.noResultsFound') : ''} | ||
| initiallyFocusedOptionKey={report.policyID} | ||
| textInputOptions={textInputOptions} | ||
| initiallyFocusedItemKey={report.policyID} | ||
| showLoadingPlaceholder={fetchStatus.status === 'loading' || !didScreenTransitionEnd} | ||
| disableMaintainingScrollPosition | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an enabled by default option in |
||
| /> | ||
| )} | ||
| </> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.