-
Notifications
You must be signed in to change notification settings - Fork 4k
Update the Assigned Cards Section of the Wallet Page #38998
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
Merged
grgia
merged 26 commits into
Expensify:main
from
software-mansion-labs:@szymczak/update-cards-section
Apr 29, 2024
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
0515ffb
make wallet page cards grouped by domain
SzymczakJ ecdcf48
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ 804005a
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ 71c86a2
fix navigation on lost/fraud/actvate card flows
SzymczakJ 13674cd
fix navigation on get physical card flow
SzymczakJ e5d8cc5
fix PR comments
SzymczakJ a26532f
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ ecd7c73
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ 6bf60e9
make card row title depend on cardTitle when card is admin assigned
SzymczakJ a10788e
adjust expensifyCardPage title
SzymczakJ bc9ce69
fix PR comments
SzymczakJ c19eb59
fix PR comments
SzymczakJ ae6f359
fix types
SzymczakJ 24321a9
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ 70d02e4
fix nameValuePairs bugs
SzymczakJ 55bed2d
fix PR comments
SzymczakJ 5b9ad8c
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ a8454dc
fix button margins
SzymczakJ 4f6ee19
add spanish translations
SzymczakJ 0486463
merge main
SzymczakJ f989cea
fix PR comments
SzymczakJ f114894
fix navigation bugs
SzymczakJ d542600
remove redundant types
SzymczakJ c7a0f12
fix ExpensifyCardPage bug
SzymczakJ 0458752
fix pr comments
SzymczakJ f915905
fix lint errors
SzymczakJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,10 @@ import useNetwork from '@hooks/useNetwork'; | |
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
| import * as CardUtils from '@libs/CardUtils'; | ||
| import * as DeviceCapabilities from '@libs/DeviceCapabilities'; | ||
| import * as ErrorUtils from '@libs/ErrorUtils'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import type {PublicScreensParamList} from '@libs/Navigation/types'; | ||
| import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||
| import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; | ||
| import * as CardSettings from '@userActions/Card'; | ||
| import CONST from '@src/CONST'; | ||
|
|
@@ -34,15 +33,15 @@ type ActivatePhysicalCardPageOnyxProps = { | |
| cardList: OnyxEntry<Record<string, Card>>; | ||
| }; | ||
|
|
||
| type ActivatePhysicalCardPageProps = ActivatePhysicalCardPageOnyxProps & StackScreenProps<PublicScreensParamList, typeof SCREENS.TRANSITION_BETWEEN_APPS>; | ||
| type ActivatePhysicalCardPageProps = ActivatePhysicalCardPageOnyxProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.WALLET.CARD_ACTIVATE>; | ||
|
grgia marked this conversation as resolved.
|
||
|
|
||
| const LAST_FOUR_DIGITS_LENGTH = 4; | ||
| const MAGIC_INPUT_MIN_HEIGHT = 86; | ||
|
|
||
| function ActivatePhysicalCardPage({ | ||
| cardList, | ||
| route: { | ||
| params: {domain = ''}, | ||
| params: {cardID = ''}, | ||
| }, | ||
| }: ActivatePhysicalCardPageProps) { | ||
| const theme = useTheme(); | ||
|
|
@@ -55,30 +54,30 @@ function ActivatePhysicalCardPage({ | |
| const [lastFourDigits, setLastFourDigits] = useState(''); | ||
| const [lastPressedDigit, setLastPressedDigit] = useState(''); | ||
|
|
||
| const domainCards = CardUtils.getDomainCards(cardList)[domain] ?? []; | ||
| const physicalCard = domainCards.find((card) => !card.nameValuePairs?.isVirtual); | ||
| const cardID = physicalCard?.cardID ?? 0; | ||
| const cardError = ErrorUtils.getLatestErrorMessage(physicalCard ?? {}); | ||
| const inactiveCard = cardList?.[cardID]; | ||
| const cardError = ErrorUtils.getLatestErrorMessage(inactiveCard ?? {}); | ||
|
|
||
| const activateCardCodeInputRef = useRef<MagicCodeInputHandle>(null); | ||
|
|
||
| /** | ||
| * If state of the card is CONST.EXPENSIFY_CARD.STATE.OPEN, navigate to card details screen. | ||
| */ | ||
| useEffect(() => { | ||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
| if (physicalCard?.isLoading || cardList?.[cardID]?.state !== CONST.EXPENSIFY_CARD.STATE.OPEN) { | ||
| if (inactiveCard?.state !== CONST.EXPENSIFY_CARD.STATE.OPEN || inactiveCard?.isLoading) { | ||
| return; | ||
| } | ||
|
|
||
| Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain)); | ||
| }, [cardID, cardList, domain, physicalCard?.isLoading]); | ||
| Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(cardID)); | ||
| }, [cardID, cardList, inactiveCard?.isLoading, inactiveCard?.state]); | ||
|
|
||
| useEffect( | ||
| () => () => { | ||
| CardSettings.clearCardListErrors(cardID); | ||
| if (!inactiveCard?.cardID) { | ||
| return; | ||
| } | ||
| CardSettings.clearCardListErrors(inactiveCard?.cardID); | ||
|
Contributor
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. Error is not cleared when page is reloaded, #51396 |
||
| }, | ||
| [cardID], | ||
| [inactiveCard?.cardID], | ||
| ); | ||
|
|
||
| /** | ||
|
|
@@ -95,8 +94,8 @@ function ActivatePhysicalCardPage({ | |
| const onCodeInput = (text: string) => { | ||
| setFormError(''); | ||
|
|
||
| if (cardError) { | ||
| CardSettings.clearCardListErrors(cardID); | ||
| if (cardError && inactiveCard?.cardID) { | ||
| CardSettings.clearCardListErrors(inactiveCard?.cardID); | ||
| } | ||
|
|
||
| setLastFourDigits(text); | ||
|
|
@@ -109,18 +108,21 @@ function ActivatePhysicalCardPage({ | |
| setFormError('activateCardPage.error.thatDidntMatch'); | ||
| return; | ||
| } | ||
| if (inactiveCard?.cardID === undefined) { | ||
| return; | ||
| } | ||
|
|
||
| CardSettings.activatePhysicalExpensifyCard(lastFourDigits, cardID); | ||
| }, [lastFourDigits, cardID]); | ||
| CardSettings.activatePhysicalExpensifyCard(lastFourDigits, inactiveCard?.cardID); | ||
| }, [lastFourDigits, inactiveCard?.cardID]); | ||
|
|
||
| if (isEmptyObject(physicalCard)) { | ||
| if (isEmptyObject(inactiveCard)) { | ||
| return <NotFoundPage />; | ||
| } | ||
|
|
||
| return ( | ||
| <IllustratedHeaderPageLayout | ||
| title={translate('activateCardPage.activateCard')} | ||
| onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain))} | ||
| onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(cardID))} | ||
| backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.PREFERENCES.ROOT].backgroundColor} | ||
| illustration={LottieAnimations.Magician} | ||
| scrollViewContainerStyles={[styles.mnh100]} | ||
|
|
@@ -148,7 +150,7 @@ function ActivatePhysicalCardPage({ | |
| <Button | ||
| success | ||
| isDisabled={isOffline} | ||
| isLoading={physicalCard?.isLoading} | ||
| isLoading={inactiveCard?.isLoading} | ||
| medium={isExtraSmallScreenHeight} | ||
| large={!isExtraSmallScreenHeight} | ||
| style={[styles.w100, styles.p5, styles.mtAuto]} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should have added this screen to
src/libs/Navigation/linkingConfig/RELATIONS/SETTINGS_TO_RHP.tsas well. Not doing so caused #61399