Repository navigation
[Single-use and Expire-by virtual cards]: update edit card flow #81783
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
Changes from all commits
8de095e
d0e7089
17f6660
e69110a
dcdf3a0
dc768f6
aa31c47
4f05dc8
5d1e4f0
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 |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| type UpdateExpensifyCardLimitTypeParams = { | ||
| cardID: number; | ||
| limitType: string; | ||
| validFrom?: string; | ||
| validThru?: string; | ||
| clearValidityDates?: boolean; | ||
| }; | ||
|
|
||
| export default UpdateExpensifyCardLimitTypeParams; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -912,7 +912,16 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne | |
| API.write(WRITE_COMMANDS.UPDATE_EXPENSIFY_CARD_TITLE, parameters, {optimisticData, successData, failureData}); | ||
| } | ||
|
|
||
| function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number, newLimitType: CardLimitType, oldLimitType?: CardLimitType) { | ||
| function updateExpensifyCardLimitType( | ||
| workspaceAccountID: number, | ||
| cardID: number, | ||
| newLimitType: CardLimitType, | ||
| timeZone: SelectedTimezone | undefined, | ||
| oldCardNameValuePairs?: Card['nameValuePairs'], | ||
| validFrom?: string, | ||
| validThru?: string, | ||
| shouldClearValidityDates?: boolean, | ||
| ) { | ||
| const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST>> = [ | ||
| { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
|
|
@@ -921,7 +930,13 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number | |
| [cardID]: { | ||
| nameValuePairs: { | ||
| limitType: newLimitType, | ||
| pendingFields: {limitType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, | ||
| pendingFields: { | ||
| limitType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
| validFrom: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
| validThru: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
| }, | ||
| validFrom: shouldClearValidityDates ? null : validFrom, | ||
| validThru: shouldClearValidityDates ? null : validThru, | ||
|
Comment on lines
+938
to
+939
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. During the optimistic update for issue, raw date strings (yyyy-MM-dd) are written directly to the card's validity properties. Because the detail page reads these fields expecting UTC datetimes, it reinterprets the bare date string as midnight UTC. For users located in timezones behind UTC, this causes the displayed date to shift backward by one calendar day until the backend response returns the correctly normalized data, resulting in a temporary visual flicker (#99336) |
||
| }, | ||
| pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
| pendingFields: {availableSpend: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, | ||
|
|
@@ -940,7 +955,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number | |
| [cardID]: { | ||
| isLoading: false, | ||
| nameValuePairs: { | ||
| pendingFields: {limitType: null}, | ||
| pendingFields: {limitType: null, validFrom: null, validThru: null}, | ||
| }, | ||
| pendingAction: null, | ||
| pendingFields: {availableSpend: null}, | ||
|
|
@@ -956,8 +971,10 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number | |
| value: { | ||
| [cardID]: { | ||
| nameValuePairs: { | ||
| limitType: oldLimitType, | ||
| pendingFields: {limitType: null}, | ||
| limitType: oldCardNameValuePairs?.limitType, | ||
| validFrom: oldCardNameValuePairs?.validFrom, | ||
| validThru: oldCardNameValuePairs?.validThru, | ||
| pendingFields: {limitType: null, validFrom: null, validThru: null}, | ||
| }, | ||
| pendingFields: {availableSpend: null}, | ||
| pendingAction: null, | ||
|
|
@@ -971,6 +988,9 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number | |
| const parameters: UpdateExpensifyCardLimitTypeParams = { | ||
| cardID, | ||
| limitType: newLimitType, | ||
| validFrom: validFrom ? DateUtils.normalizeDateToStartOfDay(validFrom, timeZone) : undefined, | ||
|
nkdengineer marked this conversation as resolved.
Resolved
|
||
| validThru: validThru ? DateUtils.normalizeDateToEndOfDay(validThru, timeZone) : undefined, | ||
| clearValidityDates: shouldClearValidityDates, | ||
| }; | ||
|
|
||
| API.write(WRITE_COMMANDS.UPDATE_EXPENSIFY_CARD_LIMIT_TYPE, parameters, {optimisticData, successData, failureData}); | ||
|
|
@@ -1174,7 +1194,14 @@ function configureExpensifyCardsForPolicy(policyID: string, workspaceAccountID: | |
| }); | ||
| } | ||
|
|
||
| function issueExpensifyCard(domainAccountID: number, policyID: string | undefined, feedCountry: string, validateCode: string, timeZone: SelectedTimezone, data?: IssueNewCardData) { | ||
| function issueExpensifyCard( | ||
| domainAccountID: number, | ||
| policyID: string | undefined, | ||
| feedCountry: string, | ||
| validateCode: string, | ||
| timeZone: SelectedTimezone | undefined, | ||
| data?: IssueNewCardData, | ||
| ) { | ||
| if (!data) { | ||
| return; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,12 @@ import useLocalize from '@hooks/useLocalize'; | |
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getTranslationKeyForLimitType} from '@libs/CardUtils'; | ||
| import {convertToShortDisplayString} from '@libs/CurrencyUtils'; | ||
| import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import type {PersonalDetails} from '@src/types/onyx'; | ||
| import type {CardLimitType} from '@src/types/onyx/Card'; | ||
|
|
||
| type WorkspacesListRowProps = { | ||
| /** The last four digits of the card */ | ||
|
|
@@ -34,9 +36,12 @@ type WorkspacesListRowProps = { | |
|
|
||
| /** Whether the list item is hovered */ | ||
| isHovered?: boolean; | ||
|
|
||
| /** Card limit type */ | ||
| limitType: CardLimitType | undefined; | ||
| }; | ||
|
|
||
| function WorkspaceCardListRow({limit, cardholder, lastFourPAN, name, currency, isVirtual, isHovered}: WorkspacesListRowProps) { | ||
| function WorkspaceCardListRow({limit, cardholder, lastFourPAN, name, currency, isVirtual, isHovered, limitType}: WorkspacesListRowProps) { | ||
| const icons = useMemoizedLazyExpensifyIcons(['ArrowRight', 'FallbackAvatar']); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const styles = useThemeStyles(); | ||
|
|
@@ -69,7 +74,7 @@ function WorkspaceCardListRow({limit, cardholder, lastFourPAN, name, currency, i | |
| </View> | ||
| </View> | ||
| {!shouldUseNarrowLayout && ( | ||
| <View style={[styles.flexRow, styles.gap2, styles.flex1, styles.alignItemsCenter, styles.justifyContentStart]}> | ||
| <View style={[styles.flexRow, styles.gap2, styles.flex2, styles.alignItemsCenter, styles.justifyContentStart]}> | ||
|
nkdengineer marked this conversation as resolved.
Resolved
|
||
| <Text | ||
| numberOfLines={1} | ||
| style={[styles.textNormalThemeText, styles.lh16]} | ||
|
|
@@ -78,6 +83,16 @@ function WorkspaceCardListRow({limit, cardholder, lastFourPAN, name, currency, i | |
| </Text> | ||
| </View> | ||
| )} | ||
| {!shouldUseNarrowLayout && ( | ||
| <View style={[styles.flexRow, styles.gap2, styles.flex2, styles.alignItemsCenter, styles.justifyContentStart]}> | ||
| <Text | ||
| numberOfLines={1} | ||
| style={[styles.textNormalThemeText, styles.lh16]} | ||
|
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. NAB but setting line height of 16 px caused |
||
| > | ||
| {translate(getTranslationKeyForLimitType(limitType))} | ||
| </Text> | ||
| </View> | ||
| )} | ||
| <View | ||
| style={[ | ||
| styles.flexRow, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.