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

feat: update trips empty state view #48060

Merged
merged 27 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fix: lint checks
  • Loading branch information
daledah committed Aug 27, 2024
commit 4e012ab8b9375f83149dfde6f75f8cab4d7999e3
3 changes: 1 addition & 2 deletions src/components/EmptyStateComponent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {VideoReadyForDisplayEvent} from 'expo-av';
import {isString} from 'lodash';
import React, {useMemo, useState} from 'react';
import {View} from 'react-native';
import Button from '@components/Button';
Expand Down Expand Up @@ -91,7 +90,7 @@ function EmptyStateComponent({
<View style={[styles.emptyStateHeader(headerMediaType === CONST.EMPTY_STATE_MEDIA.ILLUSTRATION), headerStyles]}>{HeaderComponent}</View>
<View style={styles.p8}>
<Text style={[styles.textAlignCenter, styles.textHeadlineH1, styles.mb2, titleStyles]}>{title}</Text>
{isString(subtitle) ? <Text style={[styles.textAlignCenter, styles.textSupporting, styles.textNormal]}>{subtitle}</Text> : subtitle}
{typeof subtitle === 'string' ? <Text style={[styles.textAlignCenter, styles.textSupporting, styles.textNormal]}>{subtitle}</Text> : subtitle}
{!!buttonText && !!buttonAction && (
<Button
success
Expand Down
4 changes: 2 additions & 2 deletions src/components/EmptyStateComponent/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {ImageStyle} from 'expo-image';
import type {JSX} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import type {ValueOf} from 'type-fest';
import type DotLottieAnimation from '@components/LottieAnimations/types';
import type SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton';
Expand All @@ -14,7 +14,7 @@ type MediaTypes = ValueOf<typeof CONST.EMPTY_STATE_MEDIA>;
type SharedProps<T> = {
SkeletonComponent: ValidSkeletons;
title: string;
titleStyles?: StyleProp<ViewStyle>;
titleStyles?: StyleProp<TextStyle>;
subtitle: string | JSX.Element;
buttonText?: string;
buttonAction?: () => void;
Expand Down
33 changes: 16 additions & 17 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ function EmptySearchView({type}: EmptySearchViewProps) {

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);

const tripsFeatures: FeatureListItem[] = [
{
icon: Illustrations.PiggyBank,
translationKey: 'travel.features.saveMoney',
},
{
icon: Illustrations.Alert,
translationKey: 'travel.features.alerts',
},
];
const subtitleComponent = useMemo(() => {
const tripsFeatures: FeatureListItem[] = [
{
icon: Illustrations.PiggyBank,
translationKey: 'travel.features.saveMoney',
},
{
icon: Illustrations.Alert,
translationKey: 'travel.features.alerts',
},
];

const SubtitleComponent = useMemo(
() => (
return (
<>
<Text style={[styles.textSupporting, styles.textNormal]}>
{translate('travel.subtitle')}
Expand Down Expand Up @@ -77,9 +77,8 @@ function EmptySearchView({type}: EmptySearchViewProps) {
))}
</View>
</>
),
[styles, translate, tripsFeatures],
);
);
}, [styles, translate]);

const content = useMemo(() => {
switch (type) {
Expand All @@ -90,7 +89,7 @@ function EmptySearchView({type}: EmptySearchViewProps) {
headerContentStyles: StyleUtils.getWidthAndHeightStyle(variables.w191, variables.h172),
title: translate('travel.title'),
titleStyles: {...styles.textAlignLeft},
subtitle: SubtitleComponent,
subtitle: subtitleComponent,
buttonText: translate('search.searchResults.emptyTripResults.buttonText'),
buttonAction: () => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID ?? '-1')),
daledah marked this conversation as resolved.
Show resolved Hide resolved
};
Expand All @@ -107,7 +106,7 @@ function EmptySearchView({type}: EmptySearchViewProps) {
buttonAction: undefined,
};
}
}, [type, StyleUtils, translate, theme, styles, SubtitleComponent]);
}, [type, StyleUtils, translate, theme, styles, subtitleComponent, activePolicyID]);

return (
<EmptyStateComponent
Expand Down
Loading