Skip to content
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

Fix - Search - When plenty of expenses are created already, haven't created expenses message shown #52059

Merged
merged 16 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SearchResults from '@src/types/onyx/SearchResults';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import {useSearchContext} from './SearchContext';
import type {SearchColumnType, SearchQueryJSON, SearchStatus, SelectedTransactionInfo, SelectedTransactions, SortOrder} from './types';

Expand Down Expand Up @@ -307,7 +308,10 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
if (shouldShowEmptyState) {
return (
<View style={[shouldUseNarrowLayout ? styles.searchListContentContainerStyles : styles.mt3, styles.flex1]}>
<EmptySearchView type={type} />
<EmptySearchView
type={type}
noExpensesCreatedYet={isEmptyObject(transactions)}
/>
</View>
);
}
Expand Down
40 changes: 23 additions & 17 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {SearchDataTypes} from '@src/types/onyx/SearchResults';

type EmptySearchViewProps = {
type: SearchDataTypes;
noExpensesCreatedYet?: boolean;
};

const tripsFeatures: FeatureListItem[] = [
Expand All @@ -39,7 +40,7 @@ const tripsFeatures: FeatureListItem[] = [
},
];

function EmptySearchView({type}: EmptySearchViewProps) {
function EmptySearchView({type, noExpensesCreatedYet = false}: EmptySearchViewProps) {
const theme = useTheme();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
Expand Down Expand Up @@ -114,21 +115,26 @@ function EmptySearchView({type}: EmptySearchViewProps) {
],
};
case CONST.SEARCH.DATA_TYPES.EXPENSE:
return {
headerMedia: LottieAnimations.GenericEmptyState,
headerStyles: [StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
title: translate('search.searchResults.emptyExpenseResults.title'),
subtitle: translate('search.searchResults.emptyExpenseResults.subtitle'),
buttons: [
{buttonText: translate('emptySearchView.takeATour'), buttonAction: () => Link.openExternalLink(navatticLink)},
{
buttonText: translate('iou.createExpense'),
buttonAction: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.TYPE.CREATE, ReportUtils.generateReportID())),
success: true,
},
],
headerContentStyles: styles.emptyStateFolderWebStyles,
};
if (noExpensesCreatedYet) {
return {
headerMedia: LottieAnimations.GenericEmptyState,
headerStyles: [StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
title: translate('search.searchResults.emptyExpenseResults.title'),
subtitle: translate('search.searchResults.emptyExpenseResults.subtitle'),
buttons: [
{buttonText: translate('emptySearchView.takeATour'), buttonAction: () => Link.openExternalLink(navatticLink)},
{
buttonText: translate('iou.createExpense'),
buttonAction: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.TYPE.CREATE, ReportUtils.generateReportID())),
success: true,
},
],
headerContentStyles: styles.emptyStateFolderWebStyles,
};
}
// We want to display the default nothing to show message if the user has expenses created
// but the current search filter result is empty.
// eslint-disable-next-line no-fallthrough
case CONST.SEARCH.DATA_TYPES.CHAT:
case CONST.SEARCH.DATA_TYPES.INVOICE:
default:
Expand All @@ -140,7 +146,7 @@ function EmptySearchView({type}: EmptySearchViewProps) {
headerContentStyles: styles.emptyStateFolderWebStyles,
};
}
}, [type, StyleUtils, translate, theme, styles, subtitleComponent, ctaErrorMessage, navatticLink]);
}, [type, StyleUtils, translate, theme, styles, subtitleComponent, ctaErrorMessage, navatticLink, noExpensesCreatedYet]);

return (
<EmptyStateComponent
Expand Down