-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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] Implement OpenCardDetailsPage api call #47333
Changes from all commits
e4194a1
f79957c
cf90991
684cfeb
d692b67
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,6 @@ | ||
type OpenCardDetailsPageParams = { | ||
authToken: string; | ||
cardID: number; | ||
}; | ||
|
||
export default OpenCardDetailsPageParams; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React, {useState} from 'react'; | ||
import React, {useCallback, useEffect, useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import ExpensifyCardImage from '@assets/images/expensify-card.svg'; | ||
|
@@ -14,6 +14,7 @@ import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | |
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import ScrollView from '@components/ScrollView'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useNetwork from '@hooks/useNetwork'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as CardUtils from '@libs/CardUtils'; | ||
|
@@ -24,6 +25,7 @@ import * as PolicyUtils from '@libs/PolicyUtils'; | |
import Navigation from '@navigation/Navigation'; | ||
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import variables from '@styles/variables'; | ||
import * as Card from '@userActions/Card'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
@@ -43,7 +45,6 @@ function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetail | |
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); | ||
const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); | ||
|
||
// TODO: add an API call to load the card details data: https://github.com/Expensify/App/issues/47231 | ||
const card = cardsList?.[cardID]; | ||
const cardholder = personalDetails?.[card?.accountID ?? -1]; | ||
const isVirtual = !!card?.nameValuePairs?.isVirtual; | ||
|
@@ -52,6 +53,14 @@ function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetail | |
const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(cardholder); | ||
const translationForLimitType = CardUtils.getTranslationKeyForLimitType(card?.nameValuePairs?.limitType); | ||
|
||
const fetchCardDetails = useCallback(() => { | ||
Card.openCardDetailsPage(Number(cardID)); | ||
}, [cardID]); | ||
|
||
const {isOffline} = useNetwork({onReconnect: fetchCardDetails}); | ||
|
||
useEffect(() => fetchCardDetails(), [fetchCardDetails]); | ||
|
||
const deactivateCard = () => { | ||
setIsDeactivateModalVisible(false); | ||
|
||
|
@@ -111,6 +120,7 @@ function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetail | |
title={formattedAvailableSpendAmount} | ||
interactive={false} | ||
titleStyle={styles.newKansasLarge} | ||
containerStyle={isOffline ? styles.buttonOpacityDisabled : null} | ||
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. @mountiny @VickyStash We always greyed out the remaining limit field when offline (even though there are no pending action), right? 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 Correct because we cant know if the data is correct / up to date |
||
/> | ||
<MenuItemWithTopDescription | ||
description={translate('workspace.expensifyCard.cardLimit')} | ||
|
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.
Add my reviewing