Skip to content

Commit a8e8cc0

Browse files
committed
Wire up new EdgeTxActionGiftCard fields from edge-core-js
Populate quoteId, productId, and orderId correctly in the saved action now that the core type has explicit fields. Update GiftCardDetailsCard with backward-compat detection: if quoteId is absent, treat orderId as the quoteId per legacy behavior.
1 parent f8e4f6f commit a8e8cc0

4 files changed

Lines changed: 42 additions & 6 deletions

File tree

src/components/cards/GiftCardDetailsCard.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ export const GiftCardDetailsCard: React.FC<Props> = ({ action }) => {
3333
const theme = useTheme()
3434
const styles = getStyles(theme)
3535

36-
// Backward compat: Prior versions stored the quoteId in the `orderId` field
37-
// of EdgeTxActionGiftCard. Once edge-core-js adds an explicit `quoteId`
38-
// field, prefer that and fall back to `orderId` for older transactions.
39-
const quoteId = action.orderId
36+
// Backward compat: Prior versions stored the quoteId in the orderId field.
37+
// Detect legacy transactions by checking whether the explicit quoteId field
38+
// is populated. If missing, fall back to orderId which held the quoteId.
39+
const quoteId = action.quoteId ?? action.orderId
40+
const productId = action.productId
41+
// orderId is only meaningful when quoteId is separately populated (new format)
42+
const orderId = action.quoteId != null ? action.orderId : undefined
4043

4144
const handleRedeemPress = useHandler(() => {
4245
if (redemption?.url != null) {
@@ -67,11 +70,17 @@ export const GiftCardDetailsCard: React.FC<Props> = ({ action }) => {
6770
`${lstrings.string_amount}: ${amountDisplay}`,
6871
`${lstrings.gift_card_quote_id_label}: ${quoteId}`
6972
]
73+
if (productId != null) {
74+
lines.push(`${lstrings.gift_card_product_id_label}: ${productId}`)
75+
}
76+
if (orderId != null) {
77+
lines.push(`${lstrings.gift_card_order_id_label}: ${orderId}`)
78+
}
7079
if (redemption?.code != null) {
7180
lines.push(`${lstrings.gift_card_security_code}: ${redemption.code}`)
7281
}
7382
return lines.join('\n')
74-
}, [card.name, amountDisplay, quoteId, redemption?.code])
83+
}, [card.name, amountDisplay, quoteId, productId, orderId, redemption?.code])
7584

7685
const handleCopyAll = useHandler(() => {
7786
triggerHaptic('impactLight')
@@ -96,6 +105,26 @@ export const GiftCardDetailsCard: React.FC<Props> = ({ action }) => {
96105

97106
<EdgeRow title={lstrings.gift_card_quote_id_label} body={quoteId} />
98107

108+
{productId != null ? (
109+
<>
110+
<DividerLineUi4 />
111+
<EdgeRow
112+
title={lstrings.gift_card_product_id_label}
113+
body={productId}
114+
/>
115+
</>
116+
) : null}
117+
118+
{orderId != null ? (
119+
<>
120+
<DividerLineUi4 />
121+
<EdgeRow
122+
title={lstrings.gift_card_order_id_label}
123+
body={orderId}
124+
/>
125+
</>
126+
) : null}
127+
99128
{redemption?.code != null ? (
100129
<>
101130
<DividerLineUi4 />

src/components/scenes/GiftCardPurchaseScene.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,12 @@ export const GiftCardPurchaseScene: React.FC<Props> = props => {
572572
const order = pendingOrderRef.current
573573

574574
// Save the gift card action to the transaction (synced via edge-core)
575+
const cartItem = order.cart[0]
575576
const savedAction: EdgeTxActionGiftCard = {
576577
actionType: 'giftCard',
577-
orderId: order.quoteId,
578+
orderId: cartItem.orderId,
579+
quoteId: order.quoteId,
580+
productId: cartItem.productId,
578581
provider: {
579582
providerId: 'phaze',
580583
displayName: 'Phaze'

src/locales/en_US.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,8 @@ const strings = {
19691969
gift_card_pending: 'Pending Delivery, Please Wait...',
19701970
gift_card_pending_toast:
19711971
'Your gift card is being delivered. Please wait for a few minutes for it to arrive.',
1972+
gift_card_order_id_label: 'Order ID',
1973+
gift_card_product_id_label: 'Product ID',
19721974
gift_card_quote_id_label: 'Quote ID',
19731975
gift_card_quote_id_label_1s: 'QuoteID: %1$s',
19741976
gift_card_quote_expired_toast: 'Your quote has expired. Please try again.',

src/locales/strings/enUS.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,8 @@
15301530
"gift_card_account_info_user_id": "Phaze User ID",
15311531
"gift_card_pending": "Pending Delivery, Please Wait...",
15321532
"gift_card_pending_toast": "Your gift card is being delivered. Please wait for a few minutes for it to arrive.",
1533+
"gift_card_order_id_label": "Order ID",
1534+
"gift_card_product_id_label": "Product ID",
15331535
"gift_card_quote_id_label": "Quote ID",
15341536
"gift_card_quote_id_label_1s": "QuoteID: %1$s",
15351537
"gift_card_quote_expired_toast": "Your quote has expired. Please try again.",

0 commit comments

Comments
 (0)