@medusajs/dashboard 2.22.3 → 2.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/dist/app.js +3142 -2648
- package/dist/app.mjs +1 -1
- package/dist/{chunk-GBUMG3AT.mjs → chunk-DUUYIEXV.mjs} +486 -23
- package/dist/{chunk-ZU7MUXFY.mjs → chunk-ODGLX5SI.mjs} +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/{invite-BEMJK2UX.mjs → invite-SOLUZ6PY.mjs} +33 -3
- package/dist/{order-detail-LCEVEUIR.mjs → order-detail-XZEJSMIZ.mjs} +1 -1
- package/dist/{product-attributes-44KC3O5H.mjs → product-attributes-HEJKFIWK.mjs} +1 -1
- package/dist/{product-create-7U2FFSX6.mjs → product-create-75A5WK7S.mjs} +1 -1
- package/dist/{product-detail-NDBVS3WK.mjs → product-detail-FI6SFWJD.mjs} +2 -2
- package/dist/{product-edit-MR7HPS4Y.mjs → product-edit-RFHTL3MQ.mjs} +1 -1
- package/dist/{product-options-manage-EFUX6E3S.mjs → product-options-manage-VHGM7NLR.mjs} +2 -2
- package/dist/{product-organization-5XNP3UM6.mjs → product-organization-KWPYEBPB.mjs} +1 -1
- package/package.json +12 -13
- package/src/components/layout/main-layout/__tests__/main-layout.spec.tsx +145 -0
- package/src/components/layout/main-layout/main-layout.tsx +1 -1
- package/src/components/layout/shell/__tests__/breadcrumbs.spec.tsx +81 -0
- package/src/components/layout/shell/shell.tsx +4 -2
- package/src/components/layout/shell/use-remembered-search.ts +22 -0
- package/src/i18n/translations/$schema.json +12 -0
- package/src/i18n/translations/ar.json +13 -0
- package/src/i18n/translations/bg.json +13 -0
- package/src/i18n/translations/bs.json +13 -0
- package/src/i18n/translations/cs.json +13 -0
- package/src/i18n/translations/de.json +13 -0
- package/src/i18n/translations/el.json +13 -0
- package/src/i18n/translations/en.json +3 -0
- package/src/i18n/translations/enGB.json +13 -0
- package/src/i18n/translations/es.json +13 -0
- package/src/i18n/translations/fa.json +13 -0
- package/src/i18n/translations/fi.json +13 -0
- package/src/i18n/translations/fr.json +13 -0
- package/src/i18n/translations/he.json +13 -0
- package/src/i18n/translations/hr.json +13 -0
- package/src/i18n/translations/hu.json +13 -0
- package/src/i18n/translations/id.json +13 -0
- package/src/i18n/translations/it.json +13 -0
- package/src/i18n/translations/ja.json +13 -0
- package/src/i18n/translations/ko.json +13 -0
- package/src/i18n/translations/lt.json +13 -0
- package/src/i18n/translations/mk.json +13 -0
- package/src/i18n/translations/mn.json +13 -0
- package/src/i18n/translations/nl.json +13 -0
- package/src/i18n/translations/pl.json +13 -0
- package/src/i18n/translations/ptBR.json +13 -0
- package/src/i18n/translations/ptPT.json +13 -0
- package/src/i18n/translations/ro.json +13 -0
- package/src/i18n/translations/ru.json +13 -0
- package/src/i18n/translations/sv.json +13 -0
- package/src/i18n/translations/th.json +13 -0
- package/src/i18n/translations/tr.json +13 -0
- package/src/i18n/translations/uk.json +13 -0
- package/src/i18n/translations/vi.json +13 -0
- package/src/i18n/translations/zhCN.json +13 -0
- package/src/i18n/translations/zhTW.json +13 -0
- package/src/routes/invite/invite.tsx +43 -2
- package/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.spec.tsx +175 -0
- package/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx +80 -83
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server"
|
|
3
|
+
import { MemoryRouter } from "react-router-dom"
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from "vitest"
|
|
5
|
+
import { HttpTypes } from "@medusajs/types"
|
|
6
|
+
|
|
7
|
+
import { OrderSummarySection } from "./order-summary-section"
|
|
8
|
+
|
|
9
|
+
const mocks = vi.hoisted(() => ({
|
|
10
|
+
requestedReturns: [] as unknown[],
|
|
11
|
+
reservations: [] as unknown[],
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
vi.mock("react-i18next", () => ({
|
|
15
|
+
useTranslation: () => ({
|
|
16
|
+
t: (key: string) => key,
|
|
17
|
+
}),
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
vi.mock("../../../../../hooks/use-resource-permissions", () => {
|
|
21
|
+
const allowed = () => ({ canCreate: true, canUpdate: true })
|
|
22
|
+
return {
|
|
23
|
+
useOrderChangePermissions: allowed,
|
|
24
|
+
useOrderClaimPermissions: allowed,
|
|
25
|
+
useOrderExchangePermissions: allowed,
|
|
26
|
+
useOrderPermissions: allowed,
|
|
27
|
+
usePaymentCollectionPermissions: allowed,
|
|
28
|
+
useRefundPermissions: allowed,
|
|
29
|
+
useReservationItemPermissions: allowed,
|
|
30
|
+
useReturnPermissions: allowed,
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
vi.mock("../../../../../components/common/action-menu", () => ({
|
|
35
|
+
ActionMenu: ({ children }: { children?: React.ReactNode }) => (
|
|
36
|
+
<>{children}</>
|
|
37
|
+
),
|
|
38
|
+
}))
|
|
39
|
+
|
|
40
|
+
vi.mock("../copy-payment-link/copy-payment-link", () => ({
|
|
41
|
+
CopyPaymentLink: () => null,
|
|
42
|
+
}))
|
|
43
|
+
|
|
44
|
+
vi.mock("../../../../../hooks/api/claims", () => ({
|
|
45
|
+
useClaims: () => ({ claims: [] }),
|
|
46
|
+
}))
|
|
47
|
+
|
|
48
|
+
vi.mock("../../../../../hooks/api/exchanges", () => ({
|
|
49
|
+
useExchanges: () => ({ exchanges: [] }),
|
|
50
|
+
}))
|
|
51
|
+
|
|
52
|
+
vi.mock("../../../../../hooks/api/orders", () => ({
|
|
53
|
+
useOrderPreview: () => ({ order: undefined }),
|
|
54
|
+
}))
|
|
55
|
+
|
|
56
|
+
vi.mock("../../../../../hooks/api/payment-collections", () => ({
|
|
57
|
+
useMarkPaymentCollectionAsPaid: () => ({ mutateAsync: vi.fn() }),
|
|
58
|
+
}))
|
|
59
|
+
|
|
60
|
+
vi.mock("../../../../../hooks/api/reservations", () => ({
|
|
61
|
+
useReservationItems: () => ({ reservations: mocks.reservations }),
|
|
62
|
+
}))
|
|
63
|
+
|
|
64
|
+
vi.mock("../../../../../hooks/api/returns", () => ({
|
|
65
|
+
useReturns: ({ status }: { status?: string }) => ({
|
|
66
|
+
returns: status === "requested" ? mocks.requestedReturns : [],
|
|
67
|
+
}),
|
|
68
|
+
}))
|
|
69
|
+
|
|
70
|
+
vi.mock("../../../../../hooks/use-date", () => ({
|
|
71
|
+
useDate: () => ({ getRelativeDate: () => "" }),
|
|
72
|
+
}))
|
|
73
|
+
|
|
74
|
+
const buildOrder = (
|
|
75
|
+
overrides: Partial<HttpTypes.AdminOrder> = {}
|
|
76
|
+
): HttpTypes.AdminOrder =>
|
|
77
|
+
({
|
|
78
|
+
id: "order_1",
|
|
79
|
+
status: "pending",
|
|
80
|
+
currency_code: "usd",
|
|
81
|
+
items: [],
|
|
82
|
+
shipping_methods: [],
|
|
83
|
+
payment_collections: [],
|
|
84
|
+
credit_lines: [],
|
|
85
|
+
summary: { pending_difference: 0 },
|
|
86
|
+
item_subtotal: 0,
|
|
87
|
+
shipping_subtotal: 0,
|
|
88
|
+
original_tax_total: 0,
|
|
89
|
+
original_total: 0,
|
|
90
|
+
discount_total: 0,
|
|
91
|
+
total: 0,
|
|
92
|
+
...overrides,
|
|
93
|
+
}) as unknown as HttpTypes.AdminOrder
|
|
94
|
+
|
|
95
|
+
const renderSection = (order: HttpTypes.AdminOrder) =>
|
|
96
|
+
renderToStaticMarkup(
|
|
97
|
+
<MemoryRouter>
|
|
98
|
+
<OrderSummarySection order={order} plugins={[]} />
|
|
99
|
+
</MemoryRouter>
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
describe("OrderSummarySection footer", () => {
|
|
103
|
+
beforeEach(() => {
|
|
104
|
+
mocks.requestedReturns = []
|
|
105
|
+
mocks.reservations = []
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it("should render the receive return button when a return is requested", () => {
|
|
109
|
+
mocks.requestedReturns = [{ id: "ret_1", canceled_at: null }]
|
|
110
|
+
|
|
111
|
+
const html = renderSection(buildOrder())
|
|
112
|
+
|
|
113
|
+
expect(html).toContain("orders.returns.receive.action")
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it("should render the allocate items button when an item has no reservation", () => {
|
|
117
|
+
const html = renderSection(
|
|
118
|
+
buildOrder({
|
|
119
|
+
items: [
|
|
120
|
+
{
|
|
121
|
+
id: "item_1",
|
|
122
|
+
title: "Item",
|
|
123
|
+
quantity: 1,
|
|
124
|
+
unit_price: 10,
|
|
125
|
+
subtotal: 10,
|
|
126
|
+
variant: { manage_inventory: true, options: [] },
|
|
127
|
+
detail: {
|
|
128
|
+
fulfilled_quantity: 0,
|
|
129
|
+
shipped_quantity: 0,
|
|
130
|
+
return_requested_quantity: 0,
|
|
131
|
+
return_received_quantity: 0,
|
|
132
|
+
return_dismissed_quantity: 0,
|
|
133
|
+
written_off_quantity: 0,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
] as unknown as HttpTypes.AdminOrder["items"],
|
|
137
|
+
})
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
expect(html).toContain("orders.allocateItems.action")
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it("should render the mark as paid button when a payment collection is not paid", () => {
|
|
144
|
+
const html = renderSection(
|
|
145
|
+
buildOrder({
|
|
146
|
+
payment_collections: [
|
|
147
|
+
{
|
|
148
|
+
id: "paycol_1",
|
|
149
|
+
status: "not_paid",
|
|
150
|
+
amount: 100,
|
|
151
|
+
captured_amount: 0,
|
|
152
|
+
refunded_amount: 0,
|
|
153
|
+
},
|
|
154
|
+
] as unknown as HttpTypes.AdminOrder["payment_collections"],
|
|
155
|
+
summary: {
|
|
156
|
+
pending_difference: 100,
|
|
157
|
+
} as unknown as HttpTypes.AdminOrder["summary"],
|
|
158
|
+
})
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
expect(html).toContain("orders.payment.markAsPaid")
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it("should render the refund button when the order has a negative pending difference", () => {
|
|
165
|
+
const html = renderSection(
|
|
166
|
+
buildOrder({
|
|
167
|
+
summary: {
|
|
168
|
+
pending_difference: -100,
|
|
169
|
+
} as unknown as HttpTypes.AdminOrder["summary"],
|
|
170
|
+
})
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
expect(html).toContain("orders.payment.refundAmount")
|
|
174
|
+
})
|
|
175
|
+
})
|
package/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx
CHANGED
|
@@ -226,95 +226,92 @@ export const OrderSummarySection = ({
|
|
|
226
226
|
<DiscountAndTotalBreakdown order={order} plugins={plugins} />
|
|
227
227
|
<Total order={order} />
|
|
228
228
|
|
|
229
|
-
{showReturns ||
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
<div className="flex items-center justify-end gap-x-2 rounded-b-xl bg-ui-bg-subtle px-4 py-4">
|
|
234
|
-
{showReturns &&
|
|
235
|
-
(receivableReturns.length === 1 ? (
|
|
236
|
-
<Button asChild variant="secondary" size="small">
|
|
237
|
-
<Link
|
|
238
|
-
to={`/orders/${order.id}/returns/${receivableReturns[0].id}/receive`}
|
|
239
|
-
>
|
|
240
|
-
{t("orders.returns.receive.action")}
|
|
241
|
-
</Link>
|
|
242
|
-
</Button>
|
|
243
|
-
) : (
|
|
244
|
-
<ActionMenu
|
|
245
|
-
groups={[
|
|
246
|
-
{
|
|
247
|
-
actions: receivableReturns.map((r) => {
|
|
248
|
-
let id = r.id
|
|
249
|
-
let returnType = "Return"
|
|
250
|
-
|
|
251
|
-
if (r.exchange_id) {
|
|
252
|
-
id = r.exchange_id
|
|
253
|
-
returnType = "Exchange"
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (r.claim_id) {
|
|
257
|
-
id = r.claim_id
|
|
258
|
-
returnType = "Claim"
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
label: t("orders.returns.receive.receiveItems", {
|
|
263
|
-
id: `#${id.slice(-7)}`,
|
|
264
|
-
returnType,
|
|
265
|
-
}),
|
|
266
|
-
icon: <ArrowLongRight />,
|
|
267
|
-
to: `/orders/${order.id}/returns/${r.id}/receive`,
|
|
268
|
-
}
|
|
269
|
-
}),
|
|
270
|
-
},
|
|
271
|
-
]}
|
|
272
|
-
>
|
|
273
|
-
<Button variant="secondary" size="small">
|
|
274
|
-
{t("orders.returns.receive.action")}
|
|
275
|
-
</Button>
|
|
276
|
-
</ActionMenu>
|
|
277
|
-
))}
|
|
278
|
-
|
|
279
|
-
{showAllocateButton && (
|
|
229
|
+
{(showReturns || showAllocateButton || showPayment || showRefund) && (
|
|
230
|
+
<div className="flex items-center justify-end gap-x-2 rounded-b-xl bg-ui-bg-subtle px-4 py-4">
|
|
231
|
+
{showReturns &&
|
|
232
|
+
(receivableReturns.length === 1 ? (
|
|
280
233
|
<Button asChild variant="secondary" size="small">
|
|
281
|
-
<Link
|
|
282
|
-
{
|
|
234
|
+
<Link
|
|
235
|
+
to={`/orders/${order.id}/returns/${receivableReturns[0].id}/receive`}
|
|
236
|
+
>
|
|
237
|
+
{t("orders.returns.receive.action")}
|
|
283
238
|
</Link>
|
|
284
239
|
</Button>
|
|
285
|
-
)
|
|
240
|
+
) : (
|
|
241
|
+
<ActionMenu
|
|
242
|
+
groups={[
|
|
243
|
+
{
|
|
244
|
+
actions: receivableReturns.map((r) => {
|
|
245
|
+
let id = r.id
|
|
246
|
+
let returnType = "Return"
|
|
247
|
+
|
|
248
|
+
if (r.exchange_id) {
|
|
249
|
+
id = r.exchange_id
|
|
250
|
+
returnType = "Exchange"
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (r.claim_id) {
|
|
254
|
+
id = r.claim_id
|
|
255
|
+
returnType = "Claim"
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
label: t("orders.returns.receive.receiveItems", {
|
|
260
|
+
id: `#${id.slice(-7)}`,
|
|
261
|
+
returnType,
|
|
262
|
+
}),
|
|
263
|
+
icon: <ArrowLongRight />,
|
|
264
|
+
to: `/orders/${order.id}/returns/${r.id}/receive`,
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
},
|
|
268
|
+
]}
|
|
269
|
+
>
|
|
270
|
+
<Button variant="secondary" size="small">
|
|
271
|
+
{t("orders.returns.receive.action")}
|
|
272
|
+
</Button>
|
|
273
|
+
</ActionMenu>
|
|
274
|
+
))}
|
|
275
|
+
|
|
276
|
+
{showAllocateButton && (
|
|
277
|
+
<Button asChild variant="secondary" size="small">
|
|
278
|
+
<Link to="allocate-items">
|
|
279
|
+
{t("orders.allocateItems.action")}
|
|
280
|
+
</Link>
|
|
281
|
+
</Button>
|
|
282
|
+
)}
|
|
286
283
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
284
|
+
{showPayment && (
|
|
285
|
+
<CopyPaymentLink
|
|
286
|
+
paymentCollection={unpaidPaymentCollection}
|
|
287
|
+
order={order}
|
|
288
|
+
/>
|
|
289
|
+
)}
|
|
293
290
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
291
|
+
{showPayment && (
|
|
292
|
+
<Button
|
|
293
|
+
size="small"
|
|
294
|
+
variant="secondary"
|
|
295
|
+
onClick={() => handleMarkAsPaid(unpaidPaymentCollection)}
|
|
296
|
+
>
|
|
297
|
+
{t("orders.payment.markAsPaid")}
|
|
298
|
+
</Button>
|
|
299
|
+
)}
|
|
303
300
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
301
|
+
{showRefund && (
|
|
302
|
+
<Button size="small" variant="secondary" asChild>
|
|
303
|
+
<Link to={`/orders/${order.id}/refund`}>
|
|
304
|
+
{t("orders.payment.refundAmount", {
|
|
305
|
+
amount: getStylizedAmount(
|
|
306
|
+
pendingDifference * -1,
|
|
307
|
+
order?.currency_code
|
|
308
|
+
),
|
|
309
|
+
})}
|
|
310
|
+
</Link>
|
|
311
|
+
</Button>
|
|
312
|
+
)}
|
|
313
|
+
</div>
|
|
314
|
+
)}
|
|
318
315
|
</Container>
|
|
319
316
|
)
|
|
320
317
|
}
|