-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[No QA] Empty state modal #45690
[No QA] Empty state modal #45690
Changes from 11 commits
ca2b8a7
7f994b7
969da50
9e2d46d
f643792
6de8bcc
121dd3f
237ff7f
78a2880
c93ac5f
c09a679
7f372bd
8c91902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react'; | ||
import {Circle, Rect} from 'react-native-svg'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import variables from '@styles/variables'; | ||
import ItemListSkeletonView from './ItemListSkeletonView'; | ||
|
||
type CardRowSkeletonProps = { | ||
shouldAnimate?: boolean; | ||
fixedNumItems?: number; | ||
gradientOpacityEnabled?: boolean; | ||
}; | ||
|
||
const barHeight = 7; | ||
const longBarWidth = 120; | ||
const shortBarWidth = 60; | ||
const leftPaneWidth = variables.sideBarWidth; | ||
const gapWidth = 12; | ||
const rightSideElementWidth = 50; | ||
const centralPanePadding = 50; | ||
const rightButtonWidth = 20; | ||
|
||
function CardRowSkeleton({shouldAnimate = true, fixedNumItems, gradientOpacityEnabled = false}: CardRowSkeletonProps) { | ||
const styles = useThemeStyles(); | ||
const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
return ( | ||
<ItemListSkeletonView | ||
shouldAnimate={shouldAnimate} | ||
fixedNumItems={fixedNumItems} | ||
gradientOpacityEnabled={gradientOpacityEnabled} | ||
itemViewStyle={[styles.highlightBG, styles.mb3, styles.br3, styles.mr3, styles.ml3]} | ||
renderSkeletonItem={() => ( | ||
<> | ||
<Circle | ||
cx={36} | ||
cy={32} | ||
r={20} | ||
/> | ||
<Rect | ||
x={66} | ||
y={22} | ||
width={longBarWidth} | ||
height={barHeight} | ||
/> | ||
|
||
<Rect | ||
x={66} | ||
y={36} | ||
width={shortBarWidth} | ||
height={barHeight} | ||
/> | ||
|
||
{!isSmallScreenWidth && ( | ||
<> | ||
<Rect | ||
// We have to calculate this value to make sure the element is aligned to the button on the right side. | ||
x={windowWidth - leftPaneWidth - rightButtonWidth - gapWidth - centralPanePadding - gapWidth - rightSideElementWidth} | ||
y={28} | ||
width={20} | ||
height={barHeight} | ||
/> | ||
|
||
<Rect | ||
// We have to calculate this value to make sure the element is aligned to the right border. | ||
x={windowWidth - leftPaneWidth - rightSideElementWidth - gapWidth - centralPanePadding} | ||
y={28} | ||
width={50} | ||
height={barHeight} | ||
/> | ||
</> | ||
)} | ||
</> | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
CardRowSkeleton.displayName = 'CardRowSkeleton'; | ||
|
||
export default CardRowSkeleton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,7 +256,7 @@ | |
// API.write(WRITE_COMMANDS.UPDATE_CARD_SETTLEMENT_FREQUENCY, parameters, {optimisticData, successData, failureData}); | ||
} | ||
|
||
function updateSettlementAccount(policyID: string, accountID: number) { | ||
// TODO: remove this code when the API is ready | ||
Onyx.merge(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`, { | ||
paymentBankAccountID: accountID, | ||
|
@@ -372,6 +372,14 @@ | |
API.write(WRITE_COMMANDS.UPDATE_EXPENSIFY_CARD_LIMIT, parameters, {optimisticData, successData, failureData}); | ||
} | ||
|
||
// TODO: remove this function, a proper implementation will be added in https://github.com/Expensify/App/pull/45415 | ||
function updateSettlementAccount(policyID: string, accountID: number) { | ||
Check failure on line 376 in src/libs/actions/Card.ts
|
||
Onyx.merge(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`, { | ||
// @ts-expect-error this error should no longer occur after is merged | ||
Check failure on line 378 in src/libs/actions/Card.ts
|
||
paymentBankAccountID: accountID, | ||
}); | ||
} | ||
|
||
export { | ||
requestReplacementExpensifyCard, | ||
activatePhysicalExpensifyCard, | ||
|
@@ -379,9 +387,10 @@ | |
reportVirtualExpensifyCardFraud, | ||
revealVirtualCardDetails, | ||
updateSettlementFrequency, | ||
updateSettlementAccount, | ||
Check failure on line 390 in src/libs/actions/Card.ts
|
||
setIssueNewCardStepAndData, | ||
clearIssueNewCardFlow, | ||
updateExpensifyCardLimit, | ||
updateSettlementAccount, | ||
Check failure on line 394 in src/libs/actions/Card.ts
|
||
}; | ||
export type {ReplacementReason}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import EmptyStateComponent from '@components/EmptyStateComponent'; | ||
import * as Illustrations from '@components/Icon/Illustrations'; | ||
import ScrollView from '@components/ScrollView'; | ||
import CardRowSkeleton from '@components/Skeletons/CardRowSkeleton'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import CONST from '@src/CONST'; | ||
|
||
const HEADER_HEIGHT = 80; | ||
const BUTTON_HEIGHT = 40; | ||
const BUTTON_MARGIN = 12; | ||
|
||
function EmptyCardView() { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const {windowHeight, isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
const headerHeight = isSmallScreenWidth ? HEADER_HEIGHT + BUTTON_HEIGHT + BUTTON_MARGIN : HEADER_HEIGHT; | ||
|
||
return ( | ||
<ScrollView> | ||
<View style={{height: windowHeight - headerHeight}}> | ||
<EmptyStateComponent | ||
SkeletonComponent={CardRowSkeleton} | ||
headerMediaType={CONST.EMPTY_STATE_MEDIA.ILLUSTRATION} | ||
headerMedia={Illustrations.EmptyCardState} | ||
headerStyles={[{overflow: 'hidden'}, isSmallScreenWidth && {maxHeight: 300}]} | ||
title={translate('workspace.expensifyCard.issueAndManageCards')} | ||
subtitle={translate('workspace.expensifyCard.getStartedIssuing')} | ||
emptyStateContentStyles={isSmallScreenWidth ? {top: -BUTTON_HEIGHT} : undefined} | ||
/> | ||
</View> | ||
<Text style={[styles.textMicroSupporting, styles.m5]}>{translate('workspace.expensifyCard.disclaimer')}</Text> | ||
</ScrollView> | ||
); | ||
} | ||
|
||
EmptyCardView.displayName = 'EmptyCardView'; | ||
|
||
export default EmptyCardView; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ import ONYXKEYS from '@src/ONYXKEYS'; | |
import ROUTES from '@src/ROUTES'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import type {Card, WorkspaceCardsList} from '@src/types/onyx'; | ||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
import EmptyCardView from './EmptyCardView'; | ||
import WorkspaceCardListHeader from './WorkspaceCardListHeader'; | ||
import WorkspaceCardListRow from './WorkspaceCardListRow'; | ||
|
||
|
@@ -160,14 +162,16 @@ function WorkspaceExpensifyCardListPage({route}: WorkspaceExpensifyCardListPageP | |
> | ||
{!shouldUseNarrowLayout && getHeaderButtons()} | ||
</HeaderWithBackButton> | ||
|
||
{shouldUseNarrowLayout && <View style={[styles.pl5, styles.pr5]}>{getHeaderButtons()}</View>} | ||
|
||
<FlatList | ||
data={sortedCards} | ||
renderItem={renderItem} | ||
ListHeaderComponent={WorkspaceCardListHeader} | ||
/> | ||
{!isEmptyObject(cardsList) ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @koko57 Please help to explain this line As I understand, we display EmptyCardView if cardList í empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DylanDylann yes, I did it probably bc I didn't want to remove mockedCard list in this PR. I'll tell Vicky (she's integrating BE with the cardList), to correct this condition There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, she did it in her PR https://github.com/Expensify/App/pull/47064/files |
||
<EmptyCardView /> | ||
) : ( | ||
<FlatList | ||
data={sortedCards} | ||
renderItem={renderItem} | ||
ListHeaderComponent={WorkspaceCardListHeader} | ||
/> | ||
)} | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React from 'react'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; | ||
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import type {WorkspaceCardsList} from '@src/types/onyx'; | ||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
import WorkspaceExpensifyCardListPage from './WorkspaceExpensifyCardListPage'; | ||
import WorkspaceExpensifyCardPageEmptyState from './WorkspaceExpensifyCardPageEmptyState'; | ||
|
||
type WorkspaceExpensifyCardPageProps = StackScreenProps<FullScreenNavigatorParamList, typeof SCREENS.WORKSPACE.EXPENSIFY_CARD>; | ||
|
||
// TODO: remove when Onyx data is available, and pass the data to 'WorkspaceExpensifyCardListPage' so that we will not make the same 'Onyx' call twice | ||
const cardsList: OnyxEntry<WorkspaceCardsList> = {}; | ||
|
||
function WorkspaceExpensifyCardPage({route}: WorkspaceExpensifyCardPageProps) { | ||
// const policyID = route.params.policyID ?? '-1'; | ||
// const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${policyID}_${CONST.EXPENSIFY_CARD.BANK}`); | ||
const policyID = route.params.policyID ?? '-1'; | ||
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`); | ||
|
||
// @ts-expect-error this error should no longer occur after is merged | ||
Check failure on line 18 in src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx
|
||
const paymentBankAccountID = cardSettings?.paymentBankAccountID as number; | ||
|
||
return ( | ||
<AccessOrNotFoundWrapper | ||
|
@@ -26,8 +25,7 @@ | |
featureName={CONST.POLICY.MORE_FEATURES.ARE_EXPENSIFY_CARDS_ENABLED} | ||
> | ||
{/* After BE will be implemented we will probably want to have ActivityIndicator during fetch for cardsList */} | ||
{isEmptyObject(cardsList) && <WorkspaceExpensifyCardPageEmptyState route={route} />} | ||
{!isEmptyObject(cardsList) && <WorkspaceExpensifyCardListPage route={route} />} | ||
{paymentBankAccountID ? <WorkspaceExpensifyCardListPage route={route} /> : <WorkspaceExpensifyCardPageEmptyState route={route} />} | ||
</AccessOrNotFoundWrapper> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment to add reviewer