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

[Self-guided tours v1] Add self-guided tours in Search Page Empty State #50931

Merged
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: 5 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,11 @@ const CONST = {
DELAYED_SUBMISSION_HELP_URL: 'https://help.expensify.com/articles/expensify-classic/reports/Automatically-submit-employee-reports',
// Use Environment.getEnvironmentURL to get the complete URL with port number
DEV_NEW_EXPENSIFY_URL: 'https://dev.new.expensify.com:',
NAVATTIC: {
ADMIN_TOUR: 'https://expensify.navattic.com/kh204a7',
EMPLOYEE_TOUR: 'https://expensify.navattic.com/35609gb',
},

OLDDOT_URLS: {
ADMIN_POLICIES_URL: 'admin_policies',
ADMIN_DOMAINS_URL: 'admin_domains',
Expand Down
28 changes: 17 additions & 11 deletions src/components/EmptyStateComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ function EmptyStateComponent({
SkeletonComponent,
headerMediaType,
headerMedia,
buttonText,
buttonAction,
buttons,
containerStyles,
title,
titleStyles,
Expand Down Expand Up @@ -99,15 +98,22 @@ function EmptyStateComponent({
<View style={shouldUseNarrowLayout ? styles.p5 : styles.p8}>
<Text style={[styles.textAlignCenter, styles.textHeadlineH1, styles.mb2, titleStyles]}>{title}</Text>
{typeof subtitle === 'string' ? <Text style={[styles.textAlignCenter, styles.textSupporting, styles.textNormal]}>{subtitle}</Text> : subtitle}
{!!buttonText && !!buttonAction && (
<Button
success
onPress={buttonAction}
text={buttonText}
style={[styles.mt5]}
large
/>
)}
<View style={[styles.gap2, styles.mt5, !shouldUseNarrowLayout ? styles.flexRow : undefined]}>
{buttons?.map(({buttonText, buttonAction, success}, index) => (
<View
// eslint-disable-next-line react/no-array-index-key
key={index}
style={styles.flex1}
>
<Button
success={success}
onPress={buttonAction}
text={buttonText}
large
/>
</View>
))}
</View>
</View>
</View>
</View>
Expand Down
4 changes: 2 additions & 2 deletions src/components/EmptyStateComponent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type IconAsset from '@src/types/utils/IconAsset';

type ValidSkeletons = typeof SearchRowSkeleton | typeof TableRowSkeleton;
type MediaTypes = ValueOf<typeof CONST.EMPTY_STATE_MEDIA>;
type Button = {buttonText?: string; buttonAction?: () => void; success?: boolean};

type SharedProps<T> = {
SkeletonComponent: ValidSkeletons;
title: string;
titleStyles?: StyleProp<TextStyle>;
subtitle: string | React.ReactNode;
buttonText?: string;
buttonAction?: () => void;
buttons?: Button[];
containerStyles?: StyleProp<ViewStyle>;
headerStyles?: StyleProp<ViewStyle>;
headerMediaType: T;
Expand Down
7 changes: 7 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4244,6 +4244,10 @@ const translations = {
title: 'Nothing to show',
subtitle: 'Try creating something using the green + button.',
},
emptyExpenseResults: {
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.',
},
emptyTripResults: {
title: 'No trips to display',
subtitle: 'Get started by booking your first trip below.',
Expand Down Expand Up @@ -5078,6 +5082,9 @@ const translations = {
hasMissingInvoiceBankAccount: 'Has missing invoice bank account',
},
},
emptySearchView: {
takeATour: 'Take a tour',
},
};

export default translations satisfies TranslationDeepObject<typeof translations>;
7 changes: 7 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4291,6 +4291,10 @@ const translations = {
title: 'No hay nada que ver aquí',
subtitle: 'Por favor intenta crear algo usando el botón verde.',
},
emptyExpenseResults: {
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.',
},
emptyTripResults: {
title: 'No tienes viajes',
subtitle: 'Reserva tu primer viaje a continuación.',
Expand Down Expand Up @@ -5593,6 +5597,9 @@ const translations = {
hasMissingInvoiceBankAccount: 'Falta la cuenta bancaria de la factura',
},
},
emptySearchView: {
takeATour: 'Haz un tour',
},
};

export default translations satisfies TranslationDeepObject<typeof en>;
42 changes: 34 additions & 8 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useMemo, useState} from 'react';
import {Linking, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import DotIndicatorMessage from '@components/DotIndicatorMessage';
import EmptyStateComponent from '@components/EmptyStateComponent';
import type {FeatureListItem} from '@components/FeatureList';
Expand All @@ -13,9 +14,14 @@ import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import * as ReportUtils from '@libs/ReportUtils';
import * as TripsResevationUtils from '@libs/TripReservationUtils';
import variables from '@styles/variables';
import * as IOU from '@userActions/IOU';
import * as Link from '@userActions/Link';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {SearchDataTypes} from '@src/types/onyx/SearchResults';

type EmptySearchViewProps = {
Expand Down Expand Up @@ -86,6 +92,9 @@ function EmptySearchView({type}: EmptySearchViewProps) {
);
}, [styles, translate, ctaErrorMessage]);

const [onboardingPurpose] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: (introSelected) => introSelected?.choice});
const navatticLink = onboardingPurpose === CONST.SELECTABLE_ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.NAVATTIC.ADMIN_TOUR : CONST.NAVATTIC.EMPLOYEE_TOUR;

const content = useMemo(() => {
switch (type) {
case CONST.SEARCH.DATA_TYPES.TRIP:
Expand All @@ -96,24 +105,42 @@ function EmptySearchView({type}: EmptySearchViewProps) {
title: translate('travel.title'),
titleStyles: {...styles.textAlignLeft},
subtitle: subtitleComponent,
buttonText: translate('search.searchResults.emptyTripResults.buttonText'),
buttonAction: () => TripsResevationUtils.bookATrip(translate, setCtaErrorMessage, ctaErrorMessage),
buttons: [
{
buttonText: translate('search.searchResults.emptyTripResults.buttonText'),
buttonAction: () => TripsResevationUtils.bookATrip(translate, setCtaErrorMessage, ctaErrorMessage),
success: true,
},
],
};
case CONST.SEARCH.DATA_TYPES.CHAT:
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,
};
case CONST.SEARCH.DATA_TYPES.CHAT:
case CONST.SEARCH.DATA_TYPES.INVOICE:
default:
return {
headerMedia: LottieAnimations.GenericEmptyState,
headerStyles: [StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
title: translate('search.searchResults.emptyResults.title'),
subtitle: translate('search.searchResults.emptyResults.subtitle'),
buttonText: undefined,
buttonAction: undefined,
headerContentStyles: styles.emptyStateFolderWebStyles,
};
}
}, [type, StyleUtils, translate, theme, styles, subtitleComponent, ctaErrorMessage]);
}, [type, StyleUtils, translate, theme, styles, subtitleComponent, ctaErrorMessage, navatticLink]);

return (
<EmptyStateComponent
Expand All @@ -124,8 +151,7 @@ function EmptySearchView({type}: EmptySearchViewProps) {
title={content.title}
titleStyles={content.titleStyles}
subtitle={content.subtitle}
buttonText={content.buttonText}
buttonAction={content.buttonAction}
buttons={content.buttons}
headerContentStyles={[styles.h100, styles.w100, content.headerContentStyles]}
lottieWebViewStyles={styles.emptyStateFolderWebStyles}
/>
Expand Down
Loading