From c10fed87d9e9095fa2d489c08a5717891f274dbd Mon Sep 17 00:00:00 2001 From: Burhan-Rashid Date: Thu, 16 Oct 2025 01:40:38 +0530 Subject: [PATCH] feat: added the count and total of the selected items to the footer of explore section --- src/pages/Search/SearchPage.tsx | 10 +++++----- src/pages/Search/SearchPageNarrow.tsx | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 79d283256bb0..20af704200d8 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -651,7 +651,7 @@ function SearchPage({route}: SearchPageProps) { const metadata = searchResults?.search; const shouldShowOfflineIndicator = !!searchResults?.data; - const shouldShowFooter = !!metadata?.count; + const shouldShowFooter = !!metadata?.count || selectedTransactionsKeys.length > 0; const offlineIndicatorStyle = useMemo(() => { if (shouldShowFooter) { @@ -699,11 +699,11 @@ function SearchPage({route}: SearchPageProps) { }, []); const footerData = useMemo(() => { - const shouldUseClientTotal = selectedTransactionsKeys.length > 0 && !areAllMatchingItemsSelected; - - const currency = metadata?.currency; + const shouldUseClientTotal = !metadata?.count || (selectedTransactionsKeys.length > 0 && !areAllMatchingItemsSelected); + const selectedTransactionItems = Object.values(selectedTransactions); + const currency = metadata?.currency ?? selectedTransactionItems.at(0)?.convertedCurrency; const count = shouldUseClientTotal ? selectedTransactionsKeys.length : metadata?.count; - const total = shouldUseClientTotal ? Object.values(selectedTransactions).reduce((acc, transaction) => acc - (transaction.convertedAmount ?? 0), 0) : metadata?.total; + const total = shouldUseClientTotal ? selectedTransactionItems.reduce((acc, transaction) => acc - (transaction.convertedAmount ?? 0), 0) : metadata?.total; return {count, total, currency}; }, [areAllMatchingItemsSelected, metadata?.count, metadata?.currency, metadata?.total, selectedTransactions, selectedTransactionsKeys.length]); diff --git a/src/pages/Search/SearchPageNarrow.tsx b/src/pages/Search/SearchPageNarrow.tsx index db6978ed5dee..fc0ecc66dd28 100644 --- a/src/pages/Search/SearchPageNarrow.tsx +++ b/src/pages/Search/SearchPageNarrow.tsx @@ -78,7 +78,7 @@ function SearchPageNarrow({ const {windowHeight} = useWindowDimensions(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const {clearSelectedTransactions} = useSearchContext(); + const {clearSelectedTransactions, selectedTransactions} = useSearchContext(); const [searchRouterListVisible, setSearchRouterListVisible] = useState(false); const {isOffline} = useNetwork(); const currentSearchResultsKey = queryJSON?.hash ?? CONST.DEFAULT_NUMBER_ID; @@ -166,7 +166,7 @@ function SearchPageNarrow({ ); } - const shouldShowFooter = !!metadata?.count; + const shouldShowFooter = !!metadata?.count || Object.keys(selectedTransactions).length > 0; const isDataLoaded = isSearchDataLoaded(searchResults, queryJSON); const shouldShowLoadingState = !isOffline && (!isDataLoaded || !!currentSearchResults?.search?.isLoading);