order-management 0.0.60 → 0.0.62
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/.medusa/server/src/admin/index.js +534 -47
- package/.medusa/server/src/admin/index.mjs +535 -48
- package/.medusa/server/src/api/admin/orders/[order_id]/refund-context/route.js +69 -52
- package/.medusa/server/src/api/admin/return-payment-detail-mapping/[return_id]/route.js +33 -0
- package/.medusa/server/src/api/store/payment-details/validators.js +9 -5
- package/.medusa/server/src/api/store/return-payment-detail-mapping/[return_id]/route.js +116 -0
- package/.medusa/server/src/modules/payment-detail/validation.js +21 -3
- package/.medusa/server/src/modules/return-payment-detail-mapping/index.js +14 -0
- package/.medusa/server/src/modules/return-payment-detail-mapping/migrations/Migration20260309000000.js +33 -0
- package/.medusa/server/src/modules/return-payment-detail-mapping/models/return-payment-detail-mapping.js +10 -0
- package/.medusa/server/src/modules/return-payment-detail-mapping/service.js +68 -0
- package/.medusa/server/src/modules/return-payment-detail-mapping/types.js +3 -0
- package/package.json +1 -1
|
@@ -1,17 +1,497 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const react = require("react");
|
|
4
3
|
const adminSdk = require("@medusajs/admin-sdk");
|
|
4
|
+
const react = require("react");
|
|
5
5
|
const ui = require("@medusajs/ui");
|
|
6
6
|
const icons = require("@medusajs/icons");
|
|
7
7
|
const reactRouterDom = require("react-router-dom");
|
|
8
|
+
function roundRectPath(ctx, x, y, w, h, r) {
|
|
9
|
+
ctx.beginPath();
|
|
10
|
+
ctx.moveTo(x + r, y);
|
|
11
|
+
ctx.lineTo(x + w - r, y);
|
|
12
|
+
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
|
|
13
|
+
ctx.lineTo(x + w, y + h - r);
|
|
14
|
+
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
|
|
15
|
+
ctx.lineTo(x + r, y + h);
|
|
16
|
+
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
|
|
17
|
+
ctx.lineTo(x, y + r);
|
|
18
|
+
ctx.quadraticCurveTo(x, y, x + r, y);
|
|
19
|
+
ctx.closePath();
|
|
20
|
+
}
|
|
21
|
+
function wrapText(ctx, text, maxWidth) {
|
|
22
|
+
const words = text.split(" ");
|
|
23
|
+
const lines = [];
|
|
24
|
+
let cur = "";
|
|
25
|
+
for (const word of words) {
|
|
26
|
+
const test = cur ? `${cur} ${word}` : word;
|
|
27
|
+
if (ctx.measureText(test).width > maxWidth && cur) {
|
|
28
|
+
lines.push(cur);
|
|
29
|
+
cur = word;
|
|
30
|
+
} else {
|
|
31
|
+
cur = test;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (cur) lines.push(cur);
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
37
|
+
function drawBow(ctx, cx, cy) {
|
|
38
|
+
ctx.save();
|
|
39
|
+
ctx.translate(cx, cy);
|
|
40
|
+
ctx.fillStyle = "#9f1239";
|
|
41
|
+
ctx.beginPath();
|
|
42
|
+
ctx.moveTo(0, -1);
|
|
43
|
+
ctx.bezierCurveTo(-6, -20, -38, -24, -34, -5);
|
|
44
|
+
ctx.bezierCurveTo(-30, 10, -6, 5, 0, 1);
|
|
45
|
+
ctx.fill();
|
|
46
|
+
ctx.beginPath();
|
|
47
|
+
ctx.moveTo(0, -1);
|
|
48
|
+
ctx.bezierCurveTo(6, -20, 38, -24, 34, -5);
|
|
49
|
+
ctx.bezierCurveTo(30, 10, 6, 5, 0, 1);
|
|
50
|
+
ctx.fill();
|
|
51
|
+
ctx.beginPath();
|
|
52
|
+
ctx.moveTo(-5, 5);
|
|
53
|
+
ctx.lineTo(-16, 26);
|
|
54
|
+
ctx.lineTo(-10, 26);
|
|
55
|
+
ctx.lineTo(0, 6);
|
|
56
|
+
ctx.fill();
|
|
57
|
+
ctx.beginPath();
|
|
58
|
+
ctx.moveTo(5, 5);
|
|
59
|
+
ctx.lineTo(16, 26);
|
|
60
|
+
ctx.lineTo(10, 26);
|
|
61
|
+
ctx.lineTo(0, 6);
|
|
62
|
+
ctx.fill();
|
|
63
|
+
const kg = ctx.createRadialGradient(0, -1, 0, 0, -1, 9);
|
|
64
|
+
kg.addColorStop(0, "#fb7185");
|
|
65
|
+
kg.addColorStop(1, "#9f1239");
|
|
66
|
+
ctx.fillStyle = kg;
|
|
67
|
+
ctx.beginPath();
|
|
68
|
+
ctx.ellipse(0, -1, 8, 7, 0, 0, Math.PI * 2);
|
|
69
|
+
ctx.fill();
|
|
70
|
+
ctx.restore();
|
|
71
|
+
}
|
|
72
|
+
function generateGiftCardCanvas(productName, variantTitle, from, to, message) {
|
|
73
|
+
const W = 600;
|
|
74
|
+
const H = 420;
|
|
75
|
+
const S = 2;
|
|
76
|
+
const canvas = document.createElement("canvas");
|
|
77
|
+
canvas.width = W * S;
|
|
78
|
+
canvas.height = H * S;
|
|
79
|
+
const ctx = canvas.getContext("2d");
|
|
80
|
+
ctx.scale(S, S);
|
|
81
|
+
const bg = ctx.createLinearGradient(0, 0, W, H);
|
|
82
|
+
bg.addColorStop(0, "#fff9f5");
|
|
83
|
+
bg.addColorStop(1, "#fff4f7");
|
|
84
|
+
ctx.fillStyle = bg;
|
|
85
|
+
roundRectPath(ctx, 0, 0, W, H, 16);
|
|
86
|
+
ctx.fill();
|
|
87
|
+
ctx.strokeStyle = "#fda4af";
|
|
88
|
+
ctx.lineWidth = 2.5;
|
|
89
|
+
roundRectPath(ctx, 3, 3, W - 6, H - 6, 14);
|
|
90
|
+
ctx.stroke();
|
|
91
|
+
ctx.strokeStyle = "#fee2e2";
|
|
92
|
+
ctx.lineWidth = 1;
|
|
93
|
+
ctx.setLineDash([7, 5]);
|
|
94
|
+
roundRectPath(ctx, 12, 12, W - 24, H - 24, 10);
|
|
95
|
+
ctx.stroke();
|
|
96
|
+
ctx.setLineDash([]);
|
|
97
|
+
ctx.fillStyle = "#fca5a5";
|
|
98
|
+
ctx.font = "14px serif";
|
|
99
|
+
ctx.textAlign = "center";
|
|
100
|
+
ctx.textBaseline = "middle";
|
|
101
|
+
[[27, 27], [W - 27, 27], [27, H - 27], [W - 27, H - 27]].forEach(
|
|
102
|
+
([x, y]) => ctx.fillText("✦", x, y)
|
|
103
|
+
);
|
|
104
|
+
const RY = 78;
|
|
105
|
+
ctx.shadowColor = "rgba(0,0,0,0.10)";
|
|
106
|
+
ctx.shadowBlur = 6;
|
|
107
|
+
ctx.shadowOffsetY = 2;
|
|
108
|
+
const rg = ctx.createLinearGradient(0, RY - 18, 0, RY + 18);
|
|
109
|
+
rg.addColorStop(0, "#fb7185");
|
|
110
|
+
rg.addColorStop(0.45, "#e11d48");
|
|
111
|
+
rg.addColorStop(1, "#be123c");
|
|
112
|
+
ctx.fillStyle = rg;
|
|
113
|
+
ctx.fillRect(0, RY - 18, W, 36);
|
|
114
|
+
ctx.shadowColor = "transparent";
|
|
115
|
+
ctx.shadowBlur = 0;
|
|
116
|
+
ctx.shadowOffsetY = 0;
|
|
117
|
+
ctx.fillStyle = "rgba(255,255,255,0.14)";
|
|
118
|
+
ctx.fillRect(0, RY - 18, W, 11);
|
|
119
|
+
drawBow(ctx, W / 2, RY);
|
|
120
|
+
const label = productName + (variantTitle ? ` · ${variantTitle}` : "");
|
|
121
|
+
ctx.fillStyle = "#fce7f3";
|
|
122
|
+
ctx.font = "500 11px system-ui, -apple-system, sans-serif";
|
|
123
|
+
ctx.textAlign = "center";
|
|
124
|
+
ctx.textBaseline = "middle";
|
|
125
|
+
ctx.fillText(
|
|
126
|
+
label.length > 55 ? label.slice(0, 55) + "…" : label,
|
|
127
|
+
W / 2,
|
|
128
|
+
40
|
|
129
|
+
);
|
|
130
|
+
const BT = RY + 36;
|
|
131
|
+
ctx.textBaseline = "top";
|
|
132
|
+
ctx.fillStyle = "#be123c";
|
|
133
|
+
ctx.font = "700 10px system-ui, sans-serif";
|
|
134
|
+
ctx.textAlign = "left";
|
|
135
|
+
ctx.fillText("TO", 44, BT + 8);
|
|
136
|
+
ctx.fillStyle = "#111827";
|
|
137
|
+
ctx.font = `bold 28px Georgia, "Times New Roman", serif`;
|
|
138
|
+
const toStr = (to || "—").slice(0, 22);
|
|
139
|
+
ctx.fillText(toStr + (to && to.length > 22 ? "…" : ""), 44, BT + 22);
|
|
140
|
+
ctx.fillStyle = "#be123c";
|
|
141
|
+
ctx.font = "700 10px system-ui, sans-serif";
|
|
142
|
+
ctx.textAlign = "right";
|
|
143
|
+
ctx.fillText("FROM", W - 44, BT + 8);
|
|
144
|
+
ctx.fillStyle = "#374151";
|
|
145
|
+
ctx.font = `600 20px Georgia, "Times New Roman", serif`;
|
|
146
|
+
const fromStr = (from || "—").slice(0, 26);
|
|
147
|
+
ctx.fillText(fromStr + (from && from.length > 26 ? "…" : ""), W - 44, BT + 26);
|
|
148
|
+
const DY = BT + 68;
|
|
149
|
+
ctx.strokeStyle = "#fca5a5";
|
|
150
|
+
ctx.lineWidth = 1;
|
|
151
|
+
ctx.setLineDash([5, 5]);
|
|
152
|
+
ctx.beginPath();
|
|
153
|
+
ctx.moveTo(44, DY);
|
|
154
|
+
ctx.lineTo(W - 44, DY);
|
|
155
|
+
ctx.stroke();
|
|
156
|
+
ctx.setLineDash([]);
|
|
157
|
+
const ML = 44;
|
|
158
|
+
const MT = DY + 14;
|
|
159
|
+
const MW = W - 88;
|
|
160
|
+
const MH = H - MT - 42;
|
|
161
|
+
ctx.shadowColor = "rgba(0,0,0,0.07)";
|
|
162
|
+
ctx.shadowBlur = 8;
|
|
163
|
+
ctx.shadowOffsetY = 3;
|
|
164
|
+
ctx.fillStyle = "#ffffff";
|
|
165
|
+
roundRectPath(ctx, ML, MT, MW, MH, 7);
|
|
166
|
+
ctx.fill();
|
|
167
|
+
ctx.shadowColor = "transparent";
|
|
168
|
+
ctx.shadowBlur = 0;
|
|
169
|
+
ctx.shadowOffsetY = 0;
|
|
170
|
+
ctx.strokeStyle = "#fed7aa";
|
|
171
|
+
ctx.lineWidth = 1;
|
|
172
|
+
roundRectPath(ctx, ML, MT, MW, MH, 7);
|
|
173
|
+
ctx.stroke();
|
|
174
|
+
ctx.strokeStyle = "#fef9c3";
|
|
175
|
+
ctx.lineWidth = 0.7;
|
|
176
|
+
for (let ly = MT + 26; ly < MT + MH - 8; ly += 21) {
|
|
177
|
+
ctx.beginPath();
|
|
178
|
+
ctx.moveTo(ML + 12, ly);
|
|
179
|
+
ctx.lineTo(ML + MW - 12, ly);
|
|
180
|
+
ctx.stroke();
|
|
181
|
+
}
|
|
182
|
+
if (message) {
|
|
183
|
+
ctx.fillStyle = "#1f2937";
|
|
184
|
+
ctx.font = `italic 13.5px Georgia, "Times New Roman", serif`;
|
|
185
|
+
ctx.textAlign = "left";
|
|
186
|
+
ctx.textBaseline = "top";
|
|
187
|
+
const lines = wrapText(ctx, `"${message}"`, MW - 32);
|
|
188
|
+
const maxLines = Math.floor((MH - 18) / 21);
|
|
189
|
+
lines.slice(0, maxLines).forEach((line, i) => {
|
|
190
|
+
ctx.fillText(line, ML + 16, MT + 13 + i * 21);
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
ctx.fillStyle = "#9ca3af";
|
|
194
|
+
ctx.font = `italic 12px Georgia, serif`;
|
|
195
|
+
ctx.textAlign = "center";
|
|
196
|
+
ctx.textBaseline = "middle";
|
|
197
|
+
ctx.fillText("No message included", W / 2, MT + MH / 2);
|
|
198
|
+
}
|
|
199
|
+
ctx.fillStyle = "#fca5a5";
|
|
200
|
+
ctx.font = "12px serif";
|
|
201
|
+
ctx.textAlign = "center";
|
|
202
|
+
ctx.textBaseline = "middle";
|
|
203
|
+
ctx.fillText("♥ · ♥ · ♥", W / 2, H - 21);
|
|
204
|
+
return canvas;
|
|
205
|
+
}
|
|
206
|
+
function downloadGiftCard(productName, variantTitle, from, to, message) {
|
|
207
|
+
const canvas = generateGiftCardCanvas(productName, variantTitle, from, to, message);
|
|
208
|
+
const a = document.createElement("a");
|
|
209
|
+
a.download = `gift-card-${productName.replace(/\s+/g, "-").toLowerCase()}.png`;
|
|
210
|
+
a.href = canvas.toDataURL("image/png");
|
|
211
|
+
a.click();
|
|
212
|
+
}
|
|
213
|
+
const s = {
|
|
214
|
+
widget: {
|
|
215
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
216
|
+
marginTop: "10px"
|
|
217
|
+
},
|
|
218
|
+
header: {
|
|
219
|
+
display: "flex",
|
|
220
|
+
alignItems: "center",
|
|
221
|
+
gap: "10px",
|
|
222
|
+
marginBottom: "14px"
|
|
223
|
+
},
|
|
224
|
+
iconBox: {
|
|
225
|
+
display: "flex",
|
|
226
|
+
alignItems: "center",
|
|
227
|
+
justifyContent: "center",
|
|
228
|
+
width: "30px",
|
|
229
|
+
height: "30px",
|
|
230
|
+
borderRadius: "8px",
|
|
231
|
+
background: "#fce7f3",
|
|
232
|
+
color: "#be123c",
|
|
233
|
+
fontSize: "16px",
|
|
234
|
+
flexShrink: 0
|
|
235
|
+
},
|
|
236
|
+
badge: {
|
|
237
|
+
marginLeft: "auto",
|
|
238
|
+
fontSize: "11px",
|
|
239
|
+
fontWeight: 600,
|
|
240
|
+
background: "#eef2ff",
|
|
241
|
+
color: "#4338ca",
|
|
242
|
+
borderRadius: "999px",
|
|
243
|
+
padding: "3px 10px"
|
|
244
|
+
},
|
|
245
|
+
card: {
|
|
246
|
+
position: "relative",
|
|
247
|
+
borderRadius: "12px",
|
|
248
|
+
overflow: "hidden",
|
|
249
|
+
border: "1px solid #f3f4f6",
|
|
250
|
+
background: "#ffffff",
|
|
251
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.06)",
|
|
252
|
+
marginBottom: "14px"
|
|
253
|
+
},
|
|
254
|
+
ribbon: {
|
|
255
|
+
background: "linear-gradient(90deg,#fb7185,#e11d48)",
|
|
256
|
+
padding: "14px 18px",
|
|
257
|
+
display: "flex",
|
|
258
|
+
alignItems: "center",
|
|
259
|
+
justifyContent: "center",
|
|
260
|
+
position: "relative"
|
|
261
|
+
},
|
|
262
|
+
bowCenter: {
|
|
263
|
+
position: "absolute",
|
|
264
|
+
top: "50%",
|
|
265
|
+
left: "50%",
|
|
266
|
+
transform: "translate(-50%, -50%)",
|
|
267
|
+
fontSize: "20px",
|
|
268
|
+
userSelect: "none"
|
|
269
|
+
},
|
|
270
|
+
productLabel: {
|
|
271
|
+
fontSize: "11px",
|
|
272
|
+
fontWeight: 500,
|
|
273
|
+
color: "rgba(255,255,255,0.9)",
|
|
274
|
+
position: "absolute",
|
|
275
|
+
bottom: "6px",
|
|
276
|
+
left: 0,
|
|
277
|
+
right: 0,
|
|
278
|
+
textAlign: "center",
|
|
279
|
+
whiteSpace: "nowrap",
|
|
280
|
+
overflow: "hidden",
|
|
281
|
+
textOverflow: "ellipsis",
|
|
282
|
+
padding: "0 90px"
|
|
283
|
+
},
|
|
284
|
+
downloadBtn: {
|
|
285
|
+
position: "absolute",
|
|
286
|
+
top: "10px",
|
|
287
|
+
right: "12px",
|
|
288
|
+
display: "flex",
|
|
289
|
+
alignItems: "center",
|
|
290
|
+
gap: "6px",
|
|
291
|
+
fontSize: "11px",
|
|
292
|
+
fontWeight: 600,
|
|
293
|
+
color: "#ffffff",
|
|
294
|
+
background: "linear-gradient(180deg,#fb7185,#e11d48)",
|
|
295
|
+
border: "none",
|
|
296
|
+
borderRadius: "6px",
|
|
297
|
+
padding: "6px 10px",
|
|
298
|
+
cursor: "pointer",
|
|
299
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.15)"
|
|
300
|
+
},
|
|
301
|
+
body: {
|
|
302
|
+
padding: "14px 18px"
|
|
303
|
+
},
|
|
304
|
+
toFromRow: {
|
|
305
|
+
display: "flex",
|
|
306
|
+
justifyContent: "space-between",
|
|
307
|
+
alignItems: "flex-start",
|
|
308
|
+
marginBottom: "12px"
|
|
309
|
+
},
|
|
310
|
+
toBlock: {
|
|
311
|
+
display: "flex",
|
|
312
|
+
flexDirection: "column",
|
|
313
|
+
gap: "2px"
|
|
314
|
+
},
|
|
315
|
+
fromBlock: {
|
|
316
|
+
display: "flex",
|
|
317
|
+
flexDirection: "column",
|
|
318
|
+
alignItems: "flex-end",
|
|
319
|
+
gap: "2px"
|
|
320
|
+
},
|
|
321
|
+
fieldLabel: {
|
|
322
|
+
fontSize: "9px",
|
|
323
|
+
fontWeight: 700,
|
|
324
|
+
color: "#be123c",
|
|
325
|
+
letterSpacing: "0.08em",
|
|
326
|
+
textTransform: "uppercase"
|
|
327
|
+
},
|
|
328
|
+
toValue: {
|
|
329
|
+
fontSize: "22px",
|
|
330
|
+
fontWeight: 700,
|
|
331
|
+
fontFamily: `Georgia, "Times New Roman", serif`,
|
|
332
|
+
color: "#111827",
|
|
333
|
+
lineHeight: 1.15,
|
|
334
|
+
maxWidth: "160px",
|
|
335
|
+
overflow: "hidden",
|
|
336
|
+
textOverflow: "ellipsis",
|
|
337
|
+
whiteSpace: "nowrap"
|
|
338
|
+
},
|
|
339
|
+
fromValue: {
|
|
340
|
+
fontSize: "16px",
|
|
341
|
+
fontWeight: 600,
|
|
342
|
+
fontFamily: `Georgia, "Times New Roman", serif`,
|
|
343
|
+
color: "#374151",
|
|
344
|
+
maxWidth: "140px",
|
|
345
|
+
overflow: "hidden",
|
|
346
|
+
textOverflow: "ellipsis",
|
|
347
|
+
whiteSpace: "nowrap",
|
|
348
|
+
textAlign: "right"
|
|
349
|
+
},
|
|
350
|
+
divider: {
|
|
351
|
+
borderTop: "1px solid #e5e7eb",
|
|
352
|
+
margin: "10px 0 14px"
|
|
353
|
+
},
|
|
354
|
+
noteBox: {
|
|
355
|
+
background: "#f9fafb",
|
|
356
|
+
border: "1px solid #e5e7eb",
|
|
357
|
+
borderRadius: "8px",
|
|
358
|
+
padding: "14px 16px",
|
|
359
|
+
minHeight: "70px"
|
|
360
|
+
},
|
|
361
|
+
messageText: {
|
|
362
|
+
fontSize: "13px",
|
|
363
|
+
fontStyle: "italic",
|
|
364
|
+
fontFamily: `Georgia, "Times New Roman", serif`,
|
|
365
|
+
color: "#1f2937",
|
|
366
|
+
lineHeight: 1.6,
|
|
367
|
+
margin: 0
|
|
368
|
+
},
|
|
369
|
+
noMessage: {
|
|
370
|
+
fontSize: "11px",
|
|
371
|
+
color: "#9ca3af",
|
|
372
|
+
fontStyle: "italic"
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
const OrderGiftItemsWidget = ({ data }) => {
|
|
376
|
+
const [fetchedItems, setFetchedItems] = react.useState(null);
|
|
377
|
+
react.useEffect(() => {
|
|
378
|
+
if (!(data == null ? void 0 : data.id)) return;
|
|
379
|
+
fetch(
|
|
380
|
+
`/admin/orders/${data.id}?fields=*items,items.metadata`
|
|
381
|
+
).then((r) => r.json()).then(({ order }) => setFetchedItems((order == null ? void 0 : order.items) ?? [])).catch(() => setFetchedItems((data == null ? void 0 : data.items) ?? []));
|
|
382
|
+
}, [data == null ? void 0 : data.id]);
|
|
383
|
+
const items = fetchedItems ?? (data == null ? void 0 : data.items) ?? [];
|
|
384
|
+
const giftedItems = items.filter((i) => {
|
|
385
|
+
var _a;
|
|
386
|
+
const flag = (_a = i.metadata) == null ? void 0 : _a.is_gift;
|
|
387
|
+
return flag === "true" || flag === true;
|
|
388
|
+
});
|
|
389
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.widget, children: [
|
|
390
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.header, children: [
|
|
391
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: s.iconBox, children: "🎁" }),
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
393
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "13px", fontWeight: 600, color: "#111827" }, children: "Gift Items" }),
|
|
394
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "11px", color: "#6b7280" }, children: "Items marked as gifts in this order" })
|
|
395
|
+
] }),
|
|
396
|
+
giftedItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: s.badge, children: giftedItems.length })
|
|
397
|
+
] }),
|
|
398
|
+
giftedItems.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
399
|
+
"div",
|
|
400
|
+
{
|
|
401
|
+
style: {
|
|
402
|
+
padding: "14px 16px",
|
|
403
|
+
background: "#f9fafb",
|
|
404
|
+
border: "1px solid #f3f4f6",
|
|
405
|
+
borderRadius: "8px",
|
|
406
|
+
fontSize: "12px",
|
|
407
|
+
color: "#9ca3af",
|
|
408
|
+
textAlign: "center"
|
|
409
|
+
},
|
|
410
|
+
children: "No gift items in this order"
|
|
411
|
+
}
|
|
412
|
+
),
|
|
413
|
+
giftedItems.map((item) => {
|
|
414
|
+
const meta = item.metadata;
|
|
415
|
+
const from = meta == null ? void 0 : meta.gift_from;
|
|
416
|
+
const to = meta == null ? void 0 : meta.gift_to;
|
|
417
|
+
const message = meta == null ? void 0 : meta.gift_message;
|
|
418
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.card, children: [
|
|
419
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.ribbon, children: [
|
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.bowCenter, children: "🎀" }),
|
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.productLabel, children: [
|
|
422
|
+
item.product_title,
|
|
423
|
+
item.variant_title ? ` · ${item.variant_title}` : ""
|
|
424
|
+
] }),
|
|
425
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
426
|
+
"button",
|
|
427
|
+
{
|
|
428
|
+
style: s.downloadBtn,
|
|
429
|
+
onClick: () => downloadGiftCard(
|
|
430
|
+
item.product_title ?? "Gift",
|
|
431
|
+
item.variant_title ?? void 0,
|
|
432
|
+
from,
|
|
433
|
+
to,
|
|
434
|
+
message
|
|
435
|
+
),
|
|
436
|
+
title: "Download gift card as image",
|
|
437
|
+
children: [
|
|
438
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
439
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
440
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "7 10 12 15 17 10" }),
|
|
441
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
442
|
+
] }),
|
|
443
|
+
"Download"
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
)
|
|
447
|
+
] }),
|
|
448
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.body, children: [
|
|
449
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.toFromRow, children: [
|
|
450
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.toBlock, children: [
|
|
451
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.fieldLabel, children: "To" }),
|
|
452
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.toValue, children: to || "—" })
|
|
453
|
+
] }),
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.fromBlock, children: [
|
|
455
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.fieldLabel, children: "From" }),
|
|
456
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.fromValue, children: from || "—" })
|
|
457
|
+
] })
|
|
458
|
+
] }),
|
|
459
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: s.divider }),
|
|
460
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: s.noteBox, children: message ? /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.messageText, children: [
|
|
461
|
+
"“",
|
|
462
|
+
message,
|
|
463
|
+
"”"
|
|
464
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.noMessage, children: "No message included" }) })
|
|
465
|
+
] })
|
|
466
|
+
] }, item.id);
|
|
467
|
+
})
|
|
468
|
+
] });
|
|
469
|
+
};
|
|
470
|
+
adminSdk.defineWidgetConfig({
|
|
471
|
+
zone: "order.details.side.after"
|
|
472
|
+
});
|
|
473
|
+
const FIELD_LABELS = {
|
|
474
|
+
// UPI
|
|
475
|
+
upi_id: "UPI ID",
|
|
476
|
+
// Bank
|
|
477
|
+
account_holder_name: "Account Holder",
|
|
478
|
+
bank_name: "Bank Name",
|
|
479
|
+
account_number: "Account Number",
|
|
480
|
+
ifsc: "IFSC Code",
|
|
481
|
+
branch_name: "Branch Name",
|
|
482
|
+
// Card
|
|
483
|
+
card_holder_name: "Card Holder",
|
|
484
|
+
card_number: "Card Number",
|
|
485
|
+
expiry_date: "Expiry Date",
|
|
486
|
+
cvv: "CVV"
|
|
487
|
+
};
|
|
8
488
|
function getOrderIdFromPath() {
|
|
9
489
|
if (typeof window === "undefined") return void 0;
|
|
10
490
|
const m = window.location.pathname.match(/\/orders\/([^/]+)/);
|
|
11
491
|
return m ? m[1] : void 0;
|
|
12
492
|
}
|
|
13
493
|
const OrderRefundContextWidget = (props) => {
|
|
14
|
-
var _a, _b, _c, _d, _e
|
|
494
|
+
var _a, _b, _c, _d, _e;
|
|
15
495
|
const orderId = ((_a = props.order) == null ? void 0 : _a.id) ?? ((_c = (_b = props.data) == null ? void 0 : _b.order) == null ? void 0 : _c.id) ?? getOrderIdFromPath();
|
|
16
496
|
const [context, setContext] = react.useState(null);
|
|
17
497
|
const [loading, setLoading] = react.useState(!!orderId);
|
|
@@ -178,19 +658,22 @@ const OrderRefundContextWidget = (props) => {
|
|
|
178
658
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: context.return_id }),
|
|
179
659
|
((_d = context.refund_mapping) == null ? void 0 : _d.is_refunded) ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "green", children: "Refunded" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "Not refunded" })
|
|
180
660
|
] }),
|
|
181
|
-
paymentDetail && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-
|
|
182
|
-
/* @__PURE__ */ jsxRuntime.
|
|
661
|
+
paymentDetail && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-2 border-t border-ui-border-base pt-3", children: [
|
|
662
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
663
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Payment method (refund destination)" }),
|
|
664
|
+
paymentDetail.source === "specified" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "green", children: "Customer specified" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "Customer default" })
|
|
665
|
+
] }),
|
|
666
|
+
paymentDetail.source === "default" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "The customer did not specify a payment method for this return. Showing their default payment method." }) }),
|
|
183
667
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
184
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: paymentDetail.type }),
|
|
668
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: paymentDetail.type.toUpperCase() }),
|
|
185
669
|
paymentDetail.is_default && /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "blue", children: "Default" })
|
|
186
670
|
] }),
|
|
187
|
-
Object.keys(paymentDetail.detail_json).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2
|
|
188
|
-
k,
|
|
189
|
-
": ",
|
|
190
|
-
String(v)
|
|
671
|
+
Object.keys(paymentDetail.detail_json).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 grid grid-cols-2 gap-x-6 gap-y-2", children: Object.entries(paymentDetail.detail_json).map(([k, v]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: FIELD_LABELS[k] ?? k }),
|
|
673
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "block", children: String(v) })
|
|
191
674
|
] }, k)) })
|
|
192
675
|
] }),
|
|
193
|
-
!paymentDetail &&
|
|
676
|
+
!paymentDetail && context.return_id && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "No payment method found for this customer." }) }),
|
|
194
677
|
(context == null ? void 0 : context.refund_mapping) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-3 border-t border-ui-border-base pt-3", children: [
|
|
195
678
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
196
679
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Refund mode, details & images" }),
|
|
@@ -333,7 +816,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
333
816
|
] }),
|
|
334
817
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
335
818
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: "Images" }),
|
|
336
|
-
((
|
|
819
|
+
((_e = context.refund_mapping.images) == null ? void 0 : _e.length) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 flex flex-wrap gap-2", children: context.refund_mapping.images.map((url, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
337
820
|
"a",
|
|
338
821
|
{
|
|
339
822
|
href: url,
|
|
@@ -379,11 +862,11 @@ const useDebounce$3 = (value, delay) => {
|
|
|
379
862
|
return debouncedValue;
|
|
380
863
|
};
|
|
381
864
|
const getStatusBadgeClass$7 = (status) => {
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
384
|
-
if (
|
|
385
|
-
if (
|
|
386
|
-
if (
|
|
865
|
+
const s2 = status.toLowerCase();
|
|
866
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
867
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
868
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
869
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
387
870
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
388
871
|
};
|
|
389
872
|
const PaymentsPage = () => {
|
|
@@ -436,8 +919,8 @@ const PaymentsPage = () => {
|
|
|
436
919
|
}, [loadTransactions]);
|
|
437
920
|
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
438
921
|
const displayStatus = (t) => {
|
|
439
|
-
const
|
|
440
|
-
return
|
|
922
|
+
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
923
|
+
return s2 !== "" ? s2 : "—";
|
|
441
924
|
};
|
|
442
925
|
const displayAmount = (t) => {
|
|
443
926
|
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
@@ -579,11 +1062,11 @@ const useDebounce$2 = (value, delay) => {
|
|
|
579
1062
|
return debouncedValue;
|
|
580
1063
|
};
|
|
581
1064
|
const getStatusBadgeClass$6 = (status) => {
|
|
582
|
-
const
|
|
583
|
-
if (
|
|
584
|
-
if (
|
|
585
|
-
if (
|
|
586
|
-
if (
|
|
1065
|
+
const s2 = status.toLowerCase();
|
|
1066
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1067
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1068
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1069
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
587
1070
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
588
1071
|
};
|
|
589
1072
|
const RefundsPage = () => {
|
|
@@ -664,8 +1147,8 @@ const RefundsPage = () => {
|
|
|
664
1147
|
return `${code} ${Number(r.amount)}`;
|
|
665
1148
|
};
|
|
666
1149
|
const displayStatus = (r) => {
|
|
667
|
-
const
|
|
668
|
-
return
|
|
1150
|
+
const s2 = r.payment_status ?? "";
|
|
1151
|
+
return s2 !== "" ? s2 : "—";
|
|
669
1152
|
};
|
|
670
1153
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
671
1154
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
@@ -1328,11 +1811,11 @@ const config$4 = adminSdk.defineRouteConfig({
|
|
|
1328
1811
|
icon: icons.ArrowPath
|
|
1329
1812
|
});
|
|
1330
1813
|
const getStatusBadgeClass$3 = (status) => {
|
|
1331
|
-
const
|
|
1332
|
-
if (
|
|
1333
|
-
if (
|
|
1334
|
-
if (
|
|
1335
|
-
if (
|
|
1814
|
+
const s2 = status.toLowerCase();
|
|
1815
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1816
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1817
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1818
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1336
1819
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1337
1820
|
};
|
|
1338
1821
|
const PaymentDetailPage = () => {
|
|
@@ -1447,11 +1930,11 @@ const config$3 = adminSdk.defineRouteConfig({
|
|
|
1447
1930
|
icon: icons.CreditCard
|
|
1448
1931
|
});
|
|
1449
1932
|
const getStatusBadgeClass$2 = (status) => {
|
|
1450
|
-
const
|
|
1451
|
-
if (
|
|
1452
|
-
if (
|
|
1453
|
-
if (
|
|
1454
|
-
if (
|
|
1933
|
+
const s2 = status.toLowerCase();
|
|
1934
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1935
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1936
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1937
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1455
1938
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1456
1939
|
};
|
|
1457
1940
|
const formatAmount = (value) => {
|
|
@@ -2197,6 +2680,10 @@ const config = adminSdk.defineRouteConfig({
|
|
|
2197
2680
|
});
|
|
2198
2681
|
const i18nTranslations0 = {};
|
|
2199
2682
|
const widgetModule = { widgets: [
|
|
2683
|
+
{
|
|
2684
|
+
Component: OrderGiftItemsWidget,
|
|
2685
|
+
zone: ["order.details.side.after"]
|
|
2686
|
+
},
|
|
2200
2687
|
{
|
|
2201
2688
|
Component: OrderRefundContextWidget,
|
|
2202
2689
|
zone: ["order.details.after"]
|
|
@@ -2240,18 +2727,18 @@ const routeModule = {
|
|
|
2240
2727
|
};
|
|
2241
2728
|
const menuItemModule = {
|
|
2242
2729
|
menuItems: [
|
|
2243
|
-
{
|
|
2244
|
-
label: config$7.label,
|
|
2245
|
-
icon: config$7.icon,
|
|
2246
|
-
path: "/payments",
|
|
2247
|
-
nested: void 0
|
|
2248
|
-
},
|
|
2249
2730
|
{
|
|
2250
2731
|
label: config$6.label,
|
|
2251
2732
|
icon: config$6.icon,
|
|
2252
2733
|
path: "/refunds",
|
|
2253
2734
|
nested: void 0
|
|
2254
2735
|
},
|
|
2736
|
+
{
|
|
2737
|
+
label: config$7.label,
|
|
2738
|
+
icon: config$7.icon,
|
|
2739
|
+
path: "/payments",
|
|
2740
|
+
nested: void 0
|
|
2741
|
+
},
|
|
2255
2742
|
{
|
|
2256
2743
|
label: config$5.label,
|
|
2257
2744
|
icon: config$5.icon,
|
|
@@ -2264,18 +2751,18 @@ const menuItemModule = {
|
|
|
2264
2751
|
path: "/swaps",
|
|
2265
2752
|
nested: void 0
|
|
2266
2753
|
},
|
|
2267
|
-
{
|
|
2268
|
-
label: config$3.label,
|
|
2269
|
-
icon: config$3.icon,
|
|
2270
|
-
path: "/payments/:id",
|
|
2271
|
-
nested: void 0
|
|
2272
|
-
},
|
|
2273
2754
|
{
|
|
2274
2755
|
label: config$2.label,
|
|
2275
2756
|
icon: config$2.icon,
|
|
2276
2757
|
path: "/refunds/:id",
|
|
2277
2758
|
nested: void 0
|
|
2278
2759
|
},
|
|
2760
|
+
{
|
|
2761
|
+
label: config$3.label,
|
|
2762
|
+
icon: config$3.icon,
|
|
2763
|
+
path: "/payments/:id",
|
|
2764
|
+
nested: void 0
|
|
2765
|
+
},
|
|
2279
2766
|
{
|
|
2280
2767
|
label: config$1.label,
|
|
2281
2768
|
icon: config$1.icon,
|