Skip to content

Commit 91be46d

Browse files
authored
Merge branch 'main' into lkostrowski/ts-strict-scan
2 parents c2f0147 + 75b85d9 commit 91be46d

6 files changed

Lines changed: 40 additions & 3 deletions

File tree

.changeset/warm-ducks-lead.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"saleor-dashboard": minor
3+
---
4+
5+
Support REFUNDED_IN_ORDER event in gift card history

locale/defaultMessages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8519,6 +8519,10 @@
85198519
"context": "product export to csv file, header",
85208520
"string": "Export Settings"
85218521
},
8522+
"kkFOHD": {
8523+
"context": "gift card history message",
8524+
"string": "Gift card was refunded in an order"
8525+
},
85228526
"kn7jjd": {
85238527
"context": "section header",
85248528
"string": "General settings"
@@ -9485,6 +9489,10 @@
94859489
"context": "User registration",
94869490
"string": "User registration"
94879491
},
9492+
"qOXgxv": {
9493+
"context": "gift card history message",
9494+
"string": "Gift card was refunded in order {orderLink}"
9495+
},
94889496
"qPSWmL": {
94899497
"string": "Enter usage"
94909498
},

schema-staging.graphql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11425,7 +11425,7 @@ type GiftCard implements Node & ObjectWithMetadata @doc(category: "Gift cards")
1142511425
product: Product
1142611426

1142711427
"""
11428-
List of events associated with the gift card. Requires MANAGE_GIFT_CARD permission to access all events. Users with MANAGE_ORDERS permission can access only USED_IN_ORDER events.
11428+
List of events associated with the gift card. Requires MANAGE_GIFT_CARD permission to access all events. Users with MANAGE_ORDERS permission can access only USED_IN_ORDER and REFUNDED_IN_ORDER events.
1142911429

1143011430
Requires one of the following permissions: MANAGE_GIFT_CARD, MANAGE_ORDERS.
1143111431
"""
@@ -11519,6 +11519,7 @@ enum GiftCardEventsEnum @doc(category: "Gift cards") {
1151911519
RESENT
1152011520
NOTE_ADDED
1152111521
USED_IN_ORDER
11522+
REFUNDED_IN_ORDER
1152211523
}
1152311524

1152411525
type GiftCardEventBalance @doc(category: "Gift cards") {

src/giftCards/GiftCardUpdate/GiftCardHistory/GiftCardTimelineEvent.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import Link from "@dashboard/components/Link";
33
import { TimelineEvent } from "@dashboard/components/Timeline/TimelineEvent";
44
import { customerPath } from "@dashboard/customers/urls";
55
import { ExtensionsPaths, ExtensionsUrls } from "@dashboard/extensions/urls";
6-
import { type GiftCardDetailsQuery, GiftCardEventsEnum } from "@dashboard/graphql";
6+
import { type GiftCardDetailsQuery } from "@dashboard/graphql";
7+
import { GiftCardEventsEnum } from "@dashboard/graphql/staging";
78
import { orderUrl } from "@dashboard/orders/urls";
89
import { staffMemberDetailsUrl } from "@dashboard/staff/urls";
910
import { type IntlShape, useIntl } from "react-intl";
@@ -44,7 +45,12 @@ const getEventMessage = (event: GiftCardEventType, intl: IntlShape) => {
4445
const user = getUserOrApp(event);
4546
const userUrl = getUserOrAppUrl(event);
4647

47-
switch (event.type) {
48+
// We cast to the staging GiftCardEventsEnum because the new enum (from 3.23 schema)
49+
// extends the stable one (3.22) with additional values. In 3.22, event.type will never contain
50+
// the new values, so this cast is safe. In 3.23, the staging enum will match the stable schema
51+
// and the cast becomes a no-op.
52+
// TODO: Remove this cast when 3.23 is released and the stable schema includes the new enum values.
53+
switch (event.type as GiftCardEventsEnum) {
4854
case GiftCardEventsEnum.ACTIVATED:
4955
return user
5056
? intl.formatMessage(timelineMessages.activated, {
@@ -79,6 +85,12 @@ const getEventMessage = (event: GiftCardEventType, intl: IntlShape) => {
7985
issuedBy: <Link href={userUrl}>{user}</Link>,
8086
})
8187
: intl.formatMessage(timelineMessages.issuedAnonymous);
88+
case GiftCardEventsEnum.REFUNDED_IN_ORDER:
89+
return event.orderId && event.orderNumber
90+
? intl.formatMessage(timelineMessages.refundedInOrder, {
91+
orderLink: <Link href={orderUrl(event.orderId)}>#{event.orderNumber}</Link>,
92+
})
93+
: intl.formatMessage(timelineMessages.refundedInOrderNoLink);
8294
case GiftCardEventsEnum.RESENT:
8395
return intl.formatMessage(timelineMessages.resent);
8496
case GiftCardEventsEnum.SENT_TO_CUSTOMER:

src/giftCards/GiftCardUpdate/GiftCardHistory/messages.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ const giftCardHistoryTimelineMessages = defineMessages({
8888
defaultMessage: "Gift card tags were updated",
8989
description: "gift card history message",
9090
},
91+
refundedInOrder: {
92+
id: "qOXgxv",
93+
defaultMessage: "Gift card was refunded in order {orderLink}",
94+
description: "gift card history message",
95+
},
96+
refundedInOrderNoLink: {
97+
id: "kkFOHD",
98+
defaultMessage: "Gift card was refunded in an order",
99+
description: "gift card history message",
100+
},
91101
usedInOrder: {
92102
id: "Uu2B2G",
93103
defaultMessage: "Gift card was used as a payment method on order {orderLink} <buyer>by</buyer>",

src/graphql/typesStaging.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,7 @@ export enum GiftCardEventsEnum {
29772977
EXPIRY_DATE_UPDATED = 'EXPIRY_DATE_UPDATED',
29782978
ISSUED = 'ISSUED',
29792979
NOTE_ADDED = 'NOTE_ADDED',
2980+
REFUNDED_IN_ORDER = 'REFUNDED_IN_ORDER',
29802981
RESENT = 'RESENT',
29812982
SENT_TO_CUSTOMER = 'SENT_TO_CUSTOMER',
29822983
TAGS_UPDATED = 'TAGS_UPDATED',

0 commit comments

Comments
 (0)