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 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
5 changes: 4 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentCo
if (shouldShowEmptyState) {
return (
<View style={[shouldUseNarrowLayout ? styles.searchListContentContainerStyles : styles.mt3, styles.flex1]}>
<EmptySearchView type={type} />
<EmptySearchView
type={type}
hasResults={searchResults.search.hasResults}
/>
</View>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4536,6 +4536,10 @@ const translations = {
title: "You haven't created any expenses yet",
subtitle: 'Use the green button below to create an expense or take a tour of Expensify to learn more.',
},
emptyInvoiceResults: {
title: "You haven't created any \ninvoices yet",
subtitle: 'Use the green button below to send an invoice or take a tour of Expensify to learn more.',
},
emptyTripResults: {
title: 'No trips to display',
subtitle: 'Get started by booking your first trip below.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4585,6 +4585,10 @@ const translations = {
title: 'Aún no has creado ningún gasto',
subtitle: 'Usa el botón verde de abajo para crear un gasto o haz un tour por Expensify para aprender más.',
},
emptyInvoiceResults: {
title: 'Aún no has creado \nninguna factura',
subtitle: 'Usa el botón verde de abajo para crear una factura o haz un tour por Expensify para aprender más.',
},
emptyTripResults: {
title: 'No tienes viajes',
subtitle: 'Reserva tu primer viaje a continuación.',
Expand Down
112 changes: 77 additions & 35 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type {SearchDataTypes} from '@src/types/onyx/SearchResults';

type EmptySearchViewProps = {
type: SearchDataTypes;
hasResults: boolean;
};

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

function EmptySearchView({type}: EmptySearchViewProps) {
function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
const theme = useTheme();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
Expand Down Expand Up @@ -135,41 +136,81 @@ function EmptySearchView({type}: EmptySearchViewProps) {
lottieWebViewStyles: {backgroundColor: theme.travelBG, ...styles.emptyStateFolderWebStyles},
};
case CONST.SEARCH.DATA_TYPES.EXPENSE:
return {
headerMedia: LottieAnimations.GenericEmptyState,
title: translate('search.searchResults.emptyExpenseResults.title'),
subtitle: translate('search.searchResults.emptyExpenseResults.subtitle'),
buttons: [
...(!hasSeenTour
? [
{
buttonText: translate('emptySearchView.takeATour'),
buttonAction: () => {
Link.openExternalLink(navatticURL);
Welcome.setSelfTourViewed();
Task.completeTask(viewTourTaskReport);
if (!hasResults) {
return {
headerMedia: LottieAnimations.GenericEmptyState,
title: translate('search.searchResults.emptyExpenseResults.title'),
subtitle: translate('search.searchResults.emptyExpenseResults.subtitle'),
buttons: [
...(!hasSeenTour
? [
{
buttonText: translate('emptySearchView.takeATour'),
buttonAction: () => {
Link.openExternalLink(navatticURL);
Welcome.setSelfTourViewed();
Task.completeTask(viewTourTaskReport);
},
},
},
]
: []),
{
buttonText: translate('iou.createExpense'),
buttonAction: () =>
interceptAnonymousUser(() => {
if (shouldRedirectToExpensifyClassic) {
setModalVisible(true);
return;
}
IOU.startMoneyRequest(CONST.IOU.TYPE.CREATE, ReportUtils.generateReportID());
}),
success: true,
},
],
headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
lottieWebViewStyles: {backgroundColor: theme.emptyFolderBG, ...styles.emptyStateFolderWebStyles},
};
case CONST.SEARCH.DATA_TYPES.CHAT:
]
: []),
{
buttonText: translate('iou.createExpense'),
buttonAction: () =>
interceptAnonymousUser(() => {
if (shouldRedirectToExpensifyClassic) {
setModalVisible(true);
return;
}
IOU.startMoneyRequest(CONST.IOU.TYPE.CREATE, ReportUtils.generateReportID());
}),
success: true,
},
],
headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
lottieWebViewStyles: {backgroundColor: theme.emptyFolderBG, ...styles.emptyStateFolderWebStyles},
};
}
// We want to display the default nothing to show message if there is any filter applied.
// eslint-disable-next-line no-fallthrough
case CONST.SEARCH.DATA_TYPES.INVOICE:
if (!hasResults) {
return {
headerMedia: LottieAnimations.GenericEmptyState,
title: translate('search.searchResults.emptyInvoiceResults.title'),
subtitle: translate('search.searchResults.emptyInvoiceResults.subtitle'),
buttons: [
...(!hasSeenTour
? [
{
buttonText: translate('emptySearchView.takeATour'),
buttonAction: () => {
Link.openExternalLink(navatticURL);
Welcome.setSelfTourViewed();
Task.completeTask(viewTourTaskReport);
},
},
]
: []),
{
buttonText: translate('workspace.invoices.sendInvoice'),
buttonAction: () =>
interceptAnonymousUser(() => {
if (shouldRedirectToExpensifyClassic) {
setModalVisible(true);
return;
}
IOU.startMoneyRequest(CONST.IOU.TYPE.INVOICE, ReportUtils.generateReportID());
}),
success: true,
},
],
headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
lottieWebViewStyles: {backgroundColor: theme.emptyFolderBG, ...styles.emptyStateFolderWebStyles},
};
}
// eslint-disable-next-line no-fallthrough
case CONST.SEARCH.DATA_TYPES.CHAT:
default:
return {
headerMedia: LottieAnimations.GenericEmptyState,
Expand All @@ -191,8 +232,9 @@ function EmptySearchView({type}: EmptySearchViewProps) {
hasSeenTour,
ctaErrorMessage,
navatticURL,
viewTourTaskReport,
shouldRedirectToExpensifyClassic,
hasResults,
viewTourTaskReport,
]);

return (
Expand Down
4 changes: 4 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ type SearchResultsInfo = {
/** Whether the user can fetch more search results */
hasMoreResults: boolean;

/** Whether the user has any valid data on the current search type, for instance,
* whether they have created any invoice yet when the search type is invoice */
hasResults: boolean;

/** Whether the search results are currently loading */
isLoading: boolean;

Expand Down
Loading