Skip to content

Commit 9ef6ebf

Browse files
authored
Merge pull request Expensify#70628 from nkdengineer/fix/69616
fix: empty state for Expensify Cards
2 parents 7bce0f3 + b3dad3d commit 9ef6ebf

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/pages/workspace/expensifyCard/EmptyCardView.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {View} from 'react-native';
33
import EmptyStateComponent from '@components/EmptyStateComponent';
4+
import type {EmptyStateButton} from '@components/EmptyStateComponent/types';
45
import * as Illustrations from '@components/Icon/Illustrations';
56
import ScrollView from '@components/ScrollView';
67
import CardRowSkeleton from '@components/Skeletons/CardRowSkeleton';
@@ -19,9 +20,12 @@ type EmptyCardViewProps = {
1920
isBankAccountVerified: boolean;
2021
/** ID of the current policy */
2122
policyID?: string;
23+
24+
/** Buttons to display */
25+
buttons: EmptyStateButton[] | undefined;
2226
};
2327

24-
function EmptyCardView({isBankAccountVerified, policyID}: EmptyCardViewProps) {
28+
function EmptyCardView({isBankAccountVerified, policyID, buttons}: EmptyCardViewProps) {
2529
const {translate} = useLocalize();
2630
const styles = useThemeStyles();
2731
const {windowHeight} = useWindowDimensions();
@@ -35,7 +39,7 @@ function EmptyCardView({isBankAccountVerified, policyID}: EmptyCardViewProps) {
3539
contentContainerStyle={[styles.flexGrow1, styles.flexShrink0]}
3640
addBottomSafeAreaPadding
3741
>
38-
<View style={[{height: windowHeight - headerHeight}, styles.pt5]}>
42+
<View style={[{minHeight: windowHeight - headerHeight}, styles.pt5]}>
3943
<EmptyStateComponent
4044
SkeletonComponent={CardRowSkeleton}
4145
headerMediaType={CONST.EMPTY_STATE_MEDIA.ILLUSTRATION}
@@ -47,14 +51,15 @@ function EmptyCardView({isBankAccountVerified, policyID}: EmptyCardViewProps) {
4751
overflow: 'hidden',
4852
backgroundColor: colors.green700,
4953
},
50-
shouldUseNarrowLayout && {maxHeight: 250},
54+
shouldUseNarrowLayout && {maxHeight: 280},
5155
]
5256
: [styles.emptyStateCardIllustrationContainer, {backgroundColor: colors.ice800}]
5357
}
5458
title={translate(`workspace.expensifyCard.${isBankAccountVerified ? 'issueAndManageCards' : 'verificationInProgress'}`)}
5559
subtitle={translate(`workspace.expensifyCard.${isBankAccountVerified ? 'getStartedIssuing' : 'verifyingTheDetails'}`)}
5660
headerContentStyles={isBankAccountVerified ? null : styles.pendingStateCardIllustration}
5761
minModalHeight={isBankAccountVerified ? 500 : 400}
62+
buttons={buttons}
5863
/>
5964
</View>
6065
<Text style={[styles.textMicroSupporting, styles.m5]}>

src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,23 @@ function WorkspaceExpensifyCardListPage({route, cardsList, fundID}: WorkspaceExp
125125

126126
const getHeaderButtons = () => (
127127
<View style={[styles.flexRow, styles.gap2, !shouldShowSelector && shouldUseNarrowLayout && styles.mb3, shouldShowSelector && shouldChangeLayout && styles.mt3]}>
128-
<Button
129-
success
130-
onPress={handleIssueCardPress}
131-
icon={Plus}
132-
text={translate('workspace.expensifyCard.issueCard')}
133-
style={shouldChangeLayout && styles.flex1}
134-
/>
128+
{!isEmptyObject(cardsList) && (
129+
<Button
130+
success
131+
onPress={handleIssueCardPress}
132+
icon={Plus}
133+
text={translate('workspace.expensifyCard.issueCard')}
134+
style={shouldChangeLayout && styles.flex1}
135+
/>
136+
)}
135137
<ButtonWithDropdownMenu
136138
success={false}
137139
onPress={() => {}}
138140
shouldAlwaysShowDropdownMenu
139141
customText={translate('common.more')}
140142
options={secondaryActions}
141143
isSplitButton={false}
142-
wrapperStyle={styles.flexGrow0}
144+
wrapperStyle={isEmptyObject(cardsList) ? styles.flexGrow1 : styles.flexGrow0}
143145
/>
144146
</View>
145147
);
@@ -237,6 +239,13 @@ function WorkspaceExpensifyCardListPage({route, cardsList, fundID}: WorkspaceExp
237239
<EmptyCardView
238240
isBankAccountVerified={isBankAccountVerified}
239241
policyID={policyID}
242+
buttons={[
243+
{
244+
buttonText: translate('workspace.expensifyCard.issueCard'),
245+
buttonAction: handleIssueCardPress,
246+
success: true,
247+
},
248+
]}
240249
/>
241250
) : (
242251
<ScrollView

0 commit comments

Comments
 (0)