Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions src/components/Search/SearchBulkActionsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React from 'react';
import {View} from 'react-native';
import DecisionModal from '@components/DecisionModal';
import HoldOrRejectEducationalModal from '@components/HoldOrRejectEducationalModal';
import HoldSubmitterEducationalModal from '@components/HoldSubmitterEducationalModal';
import {useSearchContext} from '@components/Search/SearchContext';

Check failure on line 6 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'useSearchContext' is defined but never used

Check failure on line 6 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'useSearchContext' is defined but never used

Check warning on line 6 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected subpath import via alias '@components/Search/SearchContext'. Use './SearchContext' instead

Check failure on line 6 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'useSearchContext' is defined but never used

Check failure on line 6 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'useSearchContext' is defined but never used

Check warning on line 6 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unexpected subpath import via alias '@components/Search/SearchContext'. Use './SearchContext' instead
import type {SearchQueryJSON} from '@components/Search/types';

Check warning on line 7 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected subpath import via alias '@components/Search/types'. Use './types' instead

Check warning on line 7 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unexpected subpath import via alias '@components/Search/types'. Use './types' instead
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchBulkActions from '@hooks/useSearchBulkActions';
import useThemeStyles from '@hooks/useThemeStyles';
import type {SearchResults} from '@src/types/onyx';
import SearchPageFooter from './SearchPageFooter';

Check failure on line 13 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'SearchPageFooter' is defined but never used

Check failure on line 13 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'SearchPageFooter' is defined but never used

Check failure on line 13 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'SearchPageFooter' is defined but never used

Check failure on line 13 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'SearchPageFooter' is defined but never used
import SearchFiltersBar from './SearchPageHeader/SearchFiltersBar';
import SearchPageHeader from './SearchPageHeader/SearchPageHeader';

type SearchBulkActionsButtonProps = {
queryJSON: SearchQueryJSON;
searchResults: SearchResults | undefined;
isMobileSelectionModeEnabled: boolean;
};

function SearchBulkActionsButton({queryJSON, searchResults, isMobileSelectionModeEnabled}: SearchBulkActionsButtonProps) {
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for the decision modal type
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const {translate} = useLocalize();
const styles = useThemeStyles();

Check failure on line 28 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'styles' is assigned a value but never used

Check failure on line 28 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'styles' is assigned a value but never used

Check failure on line 28 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'styles' is assigned a value but never used

Check failure on line 28 in src/components/Search/SearchBulkActionsButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'styles' is assigned a value but never used

const {
headerButtonsOptions,
selectedPolicyIDs,
selectedTransactionReportIDs,
selectedReportIDs,
latestBankItems,
stableOnBulkPaySelected,
isOfflineModalVisible,
setIsOfflineModalVisible,
isDownloadErrorModalVisible,
setIsDownloadErrorModalVisible,
emptyReportsCount,
isHoldEducationalModalVisible,
rejectModalAction,
dismissModalAndUpdateUseHold,
dismissRejectModalBasedOnAction,
} = useSearchBulkActions({queryJSON, searchResults});

return (
<>
{shouldUseNarrowLayout && isMobileSelectionModeEnabled && (
<SearchPageHeader
queryJSON={queryJSON}
headerButtonsOptions={headerButtonsOptions}
handleSearch={() => {}}
isMobileSelectionModeEnabled={isMobileSelectionModeEnabled}
currentSelectedPolicyID={selectedPolicyIDs?.at(0)}
currentSelectedReportID={selectedTransactionReportIDs?.at(0) ?? selectedReportIDs?.at(0)}
confirmPayment={stableOnBulkPaySelected}
latestBankItems={latestBankItems}
/>
)}
{!shouldUseNarrowLayout && (
<SearchFiltersBar
queryJSON={queryJSON}
headerButtonsOptions={headerButtonsOptions}
isMobileSelectionModeEnabled={isMobileSelectionModeEnabled}
currentSelectedPolicyID={selectedPolicyIDs?.at(0)}
currentSelectedReportID={selectedTransactionReportIDs?.at(0) ?? selectedReportIDs?.at(0)}
confirmPayment={stableOnBulkPaySelected}
latestBankItems={latestBankItems}
/>
)}
{(!shouldUseNarrowLayout || isMobileSelectionModeEnabled) && (
<View>
<DecisionModal
title={translate('common.youAppearToBeOffline')}
prompt={translate('common.offlinePrompt')}
isSmallScreenWidth={isSmallScreenWidth}
onSecondOptionSubmit={() => setIsOfflineModalVisible(false)}
secondOptionText={translate('common.buttonConfirm')}
isVisible={isOfflineModalVisible}
onClose={() => setIsOfflineModalVisible(false)}
/>
{!!rejectModalAction && (
<HoldOrRejectEducationalModal
onClose={dismissRejectModalBasedOnAction}
onConfirm={dismissRejectModalBasedOnAction}
/>
)}
{!!isHoldEducationalModalVisible && (
<HoldSubmitterEducationalModal
onClose={dismissModalAndUpdateUseHold}
onConfirm={dismissModalAndUpdateUseHold}
/>
)}
</View>
)}
<DecisionModal
title={translate('common.downloadFailedTitle')}
prompt={emptyReportsCount ? translate('common.downloadFailedEmptyReportDescription', {count: emptyReportsCount}) : translate('common.downloadFailedDescription')}
isSmallScreenWidth={isSmallScreenWidth}
onSecondOptionSubmit={() => setIsDownloadErrorModalVisible(false)}
secondOptionText={translate('common.buttonConfirm')}
isVisible={isDownloadErrorModalVisible}
onClose={() => setIsDownloadErrorModalVisible(false)}
/>
</>
);
}

SearchBulkActionsButton.displayName = 'SearchBulkActionsButton';

export default SearchBulkActionsButton;
Loading
Loading