@reeboot/strapi-payment-plugin 0.0.6 → 0.0.8
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/README.md +21 -0
- package/dist/_chunks/{Analytics-CQmAVKsq.mjs → Analytics-CncK5kn-.mjs} +6 -7
- package/dist/_chunks/{Analytics-CLjtRWYA.js → Analytics-c8KBuG3k.js} +6 -7
- package/dist/_chunks/{App-DXN62SV6.mjs → App-B5AB8Omu.mjs} +7 -7
- package/dist/_chunks/{App-Dk7XtjNA.js → App-Cih9sWu1.js} +7 -7
- package/dist/_chunks/{Customers-BQzVBQDT.mjs → Customers-BVk2gx7w.mjs} +51 -118
- package/dist/_chunks/{Customers-BNDi4QBH.js → Customers-CZWOnN26.js} +50 -117
- package/dist/_chunks/{Dashboard-UUwohHZa.js → Dashboard-CEif4jQn.js} +60 -84
- package/dist/_chunks/{Dashboard-CuHC-dit.mjs → Dashboard-DAjD8Q_6.mjs} +60 -84
- package/dist/_chunks/{Orders-CitNCdWE.js → Orders-DZXb54VO.js} +73 -146
- package/dist/_chunks/{Orders-65mNfu2i.mjs → Orders-DdJqI1HB.mjs} +74 -147
- package/dist/_chunks/{PaymentList-B0CAzInT.mjs → PaymentList-3HWK7PMz.mjs} +14 -39
- package/dist/_chunks/{PaymentList-Dy1BAFoD.js → PaymentList-APfyYD1h.js} +14 -39
- package/dist/_chunks/{Payments-FnhoV_2B.mjs → Payments-DFL-Cwgy.mjs} +97 -103
- package/dist/_chunks/{Payments-TOnygGIW.js → Payments-VzDGbK4W.js} +96 -102
- package/dist/_chunks/{Settings-BJtDagUs.js → Settings-B1tR3WOm.js} +157 -161
- package/dist/_chunks/{Settings-EoLSuZLe.mjs → Settings-SALxClBu.mjs} +157 -161
- package/dist/_chunks/{index-2Zd_T7bD.mjs → index-CB6TMitx.mjs} +1 -1
- package/dist/_chunks/{index-CHEgJ7e5.js → index-D-fFikb8.js} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +7 -34
- package/dist/server/index.mjs +7 -34
- package/package.json +5 -4
- /package/dist/server/src/{types → services/types}/api.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/customer.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/index.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/order.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/payment.d.ts +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
|
-
import { Box, Typography, Table, Thead, Tr, Th, Tbody, Td, Flex, Badge, Loader, EmptyStateLayout, Button, Card, Grid, TextInput, SingleSelect, SingleSelectOption, Pagination } from "@strapi/design-system";
|
|
3
|
+
import { Box, Typography, Table, Thead, Tr, Th, Tbody, Td, Flex, Badge, Loader, EmptyStateLayout, Button, Card, Grid, TextInput, SingleSelect, SingleSelectOption, Pagination, PreviousLink, PageLink, NextLink } from "@strapi/design-system";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
import { useFetchClient } from "@strapi/strapi/admin";
|
|
6
|
-
import { P as PLUGIN_ID } from "./index-
|
|
6
|
+
import { P as PLUGIN_ID } from "./index-CB6TMitx.mjs";
|
|
7
7
|
const OrderList = ({ orders, onOrderClick, compact = false }) => {
|
|
8
8
|
const { formatMessage } = useIntl();
|
|
9
|
-
console.log("Orders:", orders);
|
|
10
9
|
const formatCurrency = (amount, currency = "usd") => {
|
|
11
10
|
return new Intl.NumberFormat("en-US", {
|
|
12
11
|
style: "currency",
|
|
@@ -14,29 +13,24 @@ const OrderList = ({ orders, onOrderClick, compact = false }) => {
|
|
|
14
13
|
}).format(amount);
|
|
15
14
|
};
|
|
16
15
|
const getStatusBadge = (status, type) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
payment: {
|
|
27
|
-
unpaid: { color: "danger", label: "Unpaid" },
|
|
28
|
-
paid: { color: "success", label: "Paid" },
|
|
29
|
-
partially_paid: { color: "warning", label: "Partially Paid" },
|
|
30
|
-
refunded: { color: "neutral", label: "Refunded" }
|
|
31
|
-
}
|
|
16
|
+
const orderVariants = {
|
|
17
|
+
pending: { variant: "warning", label: "Pending" },
|
|
18
|
+
processing: { variant: "secondary", label: "Processing" },
|
|
19
|
+
shipped: { variant: "secondary", label: "Shipped" },
|
|
20
|
+
delivered: { variant: "success", label: "Delivered" },
|
|
21
|
+
completed: { variant: "success", label: "Completed" },
|
|
22
|
+
cancelled: { variant: "danger", label: "Cancelled" },
|
|
23
|
+
failed: { variant: "danger", label: "Failed" },
|
|
24
|
+
refunded: { variant: "neutral", label: "Refunded" }
|
|
32
25
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
26
|
+
const paymentVariants = {
|
|
27
|
+
unpaid: { variant: "danger", label: "Unpaid" },
|
|
28
|
+
paid: { variant: "success", label: "Paid" },
|
|
29
|
+
partially_paid: { variant: "warning", label: "Partially Paid" },
|
|
30
|
+
refunded: { variant: "neutral", label: "Refunded" }
|
|
31
|
+
};
|
|
32
|
+
const config = type === "order" ? orderVariants[status] || orderVariants.pending : paymentVariants[status] || paymentVariants.unpaid;
|
|
33
|
+
return /* @__PURE__ */ jsx(Badge, { size: compact ? "S" : "M", variant: config.variant, children: config.label });
|
|
40
34
|
};
|
|
41
35
|
const handleOrderClick = (order) => {
|
|
42
36
|
if (onOrderClick) {
|
|
@@ -61,49 +55,17 @@ const OrderList = ({ orders, onOrderClick, compact = false }) => {
|
|
|
61
55
|
onClick: () => handleOrderClick(order),
|
|
62
56
|
style: { cursor: onOrderClick ? "pointer" : "default" },
|
|
63
57
|
children: [
|
|
64
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
65
|
-
Typography,
|
|
66
|
-
{
|
|
67
|
-
textColor: "neutral800",
|
|
68
|
-
fontWeight: "bold",
|
|
69
|
-
fontFamily: "monospace",
|
|
70
|
-
fontSize: compact ? "0.875rem" : "1rem",
|
|
71
|
-
children: order.order_number
|
|
72
|
-
}
|
|
73
|
-
) }),
|
|
58
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", fontFamily: "monospace", children: order.order_number }) }),
|
|
74
59
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, children: [
|
|
75
|
-
/* @__PURE__ */ jsx(
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
textColor: "neutral800",
|
|
79
|
-
fontWeight: compact ? "normal" : "bold",
|
|
80
|
-
fontSize: compact ? "0.875rem" : "1rem",
|
|
81
|
-
children: order.customerName || "Unknown"
|
|
82
|
-
}
|
|
83
|
-
),
|
|
84
|
-
compact && /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", variant: "epsilon", fontSize: "0.75rem", children: order.customerEmail })
|
|
60
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: compact ? "normal" : "bold", children: order.customerName || "Unknown" }),
|
|
61
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral600", variant: "epsilon", children: order.customerEmail })
|
|
85
62
|
] }) }),
|
|
86
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
order.items ? order.items.length : 0,
|
|
93
|
-
" ",
|
|
94
|
-
order.items && order.items.length === 1 ? "item" : "items"
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
) }),
|
|
98
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
99
|
-
Typography,
|
|
100
|
-
{
|
|
101
|
-
textColor: "neutral800",
|
|
102
|
-
fontWeight: "bold",
|
|
103
|
-
fontSize: compact ? "0.875rem" : "1rem",
|
|
104
|
-
children: formatCurrency(order.total_amount, order.currency)
|
|
105
|
-
}
|
|
106
|
-
) }),
|
|
63
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", children: [
|
|
64
|
+
order.items ? order.items.length : 0,
|
|
65
|
+
" ",
|
|
66
|
+
order.items && order.items.length === 1 ? "item" : "items"
|
|
67
|
+
] }) }),
|
|
68
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: formatCurrency(order.total_amount, order.currency) }) }),
|
|
107
69
|
/* @__PURE__ */ jsx(Td, { children: getStatusBadge(order.order_status, "order") }),
|
|
108
70
|
/* @__PURE__ */ jsx(Td, { children: getStatusBadge(order.paymentStatus, "payment") })
|
|
109
71
|
]
|
|
@@ -116,32 +78,29 @@ const Orders = () => {
|
|
|
116
78
|
const { formatMessage } = useIntl();
|
|
117
79
|
const { get } = useFetchClient();
|
|
118
80
|
const [orders, setOrders] = useState([]);
|
|
119
|
-
const [filteredOrders, setFilteredOrders] = useState([]);
|
|
120
81
|
const [loading, setLoading] = useState(true);
|
|
121
82
|
const [error, setError] = useState(null);
|
|
122
83
|
const [currentPage, setCurrentPage] = useState(1);
|
|
123
|
-
const
|
|
84
|
+
const pageSize = 25;
|
|
124
85
|
const [totalCount, setTotalCount] = useState(0);
|
|
125
86
|
const [filters, setFilters] = useState({
|
|
126
87
|
order_status: "",
|
|
127
88
|
paymentStatus: "",
|
|
128
|
-
dateRange: { from: null, to: null },
|
|
129
89
|
search: "",
|
|
130
90
|
currency: ""
|
|
131
91
|
});
|
|
132
92
|
useEffect(() => {
|
|
133
93
|
fetchOrders();
|
|
134
|
-
}, [currentPage,
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
applyFilters();
|
|
137
|
-
}, [orders, filters]);
|
|
94
|
+
}, [currentPage, filters]);
|
|
138
95
|
const fetchOrders = async () => {
|
|
139
96
|
try {
|
|
140
97
|
setLoading(true);
|
|
141
98
|
const queryParams = new URLSearchParams({
|
|
142
99
|
page: currentPage.toString(),
|
|
143
100
|
pageSize: pageSize.toString(),
|
|
144
|
-
...filters.order_status && { order_status: filters.order_status }
|
|
101
|
+
...filters.order_status && { order_status: filters.order_status },
|
|
102
|
+
...filters.search && { search: filters.search },
|
|
103
|
+
...filters.currency && { currency: filters.currency }
|
|
145
104
|
});
|
|
146
105
|
const { data } = await get(`/${PLUGIN_ID}/admin/orders?${queryParams}`);
|
|
147
106
|
if (data.success && data.data) {
|
|
@@ -154,7 +113,7 @@ const Orders = () => {
|
|
|
154
113
|
items: Array.isArray(o.items) ? o.items : []
|
|
155
114
|
}));
|
|
156
115
|
setOrders(formattedOrders);
|
|
157
|
-
setTotalCount(data.meta
|
|
116
|
+
setTotalCount(data.meta?.pagination?.total || 0);
|
|
158
117
|
}
|
|
159
118
|
setLoading(false);
|
|
160
119
|
} catch (err) {
|
|
@@ -162,38 +121,7 @@ const Orders = () => {
|
|
|
162
121
|
setLoading(false);
|
|
163
122
|
}
|
|
164
123
|
};
|
|
165
|
-
const
|
|
166
|
-
let filtered = [...orders];
|
|
167
|
-
if (filters.search) {
|
|
168
|
-
const searchLower = filters.search.toLowerCase();
|
|
169
|
-
filtered = filtered.filter(
|
|
170
|
-
(order) => order.order_number && order.order_number.toLowerCase().includes(searchLower) || order.customerEmail && order.customerEmail.toLowerCase().includes(searchLower) || order.customerName && order.customerName.toLowerCase().includes(searchLower)
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
if (filters.order_status) {
|
|
174
|
-
filtered = filtered.filter((order) => order.order_status === filters.order_status);
|
|
175
|
-
}
|
|
176
|
-
if (filters.paymentStatus) {
|
|
177
|
-
filtered = filtered.filter((order) => order.paymentStatus === filters.paymentStatus);
|
|
178
|
-
}
|
|
179
|
-
if (filters.currency) {
|
|
180
|
-
filtered = filtered.filter((order) => order.currency === filters.currency);
|
|
181
|
-
}
|
|
182
|
-
if (filters.dateRange.from) {
|
|
183
|
-
filtered = filtered.filter(
|
|
184
|
-
(order) => new Date(order.createdAt) >= filters.dateRange.from
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
if (filters.dateRange.to) {
|
|
188
|
-
filtered = filtered.filter(
|
|
189
|
-
(order) => new Date(order.createdAt) <= filters.dateRange.to
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
setFilteredOrders(filtered);
|
|
193
|
-
};
|
|
194
|
-
const handleOrderClick = (order) => {
|
|
195
|
-
console.log("Clicked order:", order);
|
|
196
|
-
};
|
|
124
|
+
const totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
|
|
197
125
|
const formatDate = (dateString) => {
|
|
198
126
|
return new Date(dateString).toLocaleDateString("en-US", {
|
|
199
127
|
year: "numeric",
|
|
@@ -208,19 +136,13 @@ const Orders = () => {
|
|
|
208
136
|
setCurrentPage(1);
|
|
209
137
|
};
|
|
210
138
|
const clearFilters = () => {
|
|
211
|
-
setFilters({
|
|
212
|
-
order_status: "",
|
|
213
|
-
paymentStatus: "",
|
|
214
|
-
dateRange: { from: null, to: null },
|
|
215
|
-
search: "",
|
|
216
|
-
currency: ""
|
|
217
|
-
});
|
|
139
|
+
setFilters({ order_status: "", paymentStatus: "", search: "", currency: "" });
|
|
218
140
|
setCurrentPage(1);
|
|
219
141
|
};
|
|
220
142
|
const exportOrders = () => {
|
|
221
143
|
const csvContent = [
|
|
222
144
|
["Order Number", "Customer Email", "Customer Name", "Status", "Payment Status", "Total Amount", "Currency", "Date"],
|
|
223
|
-
...
|
|
145
|
+
...orders.map((order) => [
|
|
224
146
|
order.order_number || "",
|
|
225
147
|
order.customerEmail || "",
|
|
226
148
|
order.customerName || "",
|
|
@@ -239,10 +161,6 @@ const Orders = () => {
|
|
|
239
161
|
a.click();
|
|
240
162
|
window.URL.revokeObjectURL(url);
|
|
241
163
|
};
|
|
242
|
-
const startIndex = (currentPage - 1) * pageSize;
|
|
243
|
-
const endIndex = startIndex + pageSize;
|
|
244
|
-
const paginatedOrders = filteredOrders.slice(startIndex, endIndex);
|
|
245
|
-
const totalPages = Math.ceil(filteredOrders.length / pageSize);
|
|
246
164
|
if (loading && orders.length === 0) {
|
|
247
165
|
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Loader, {}) }) });
|
|
248
166
|
}
|
|
@@ -250,8 +168,7 @@ const Orders = () => {
|
|
|
250
168
|
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
251
169
|
EmptyStateLayout,
|
|
252
170
|
{
|
|
253
|
-
|
|
254
|
-
subtitle: error,
|
|
171
|
+
content: error,
|
|
255
172
|
action: /* @__PURE__ */ jsx(Button, { onClick: fetchOrders, children: formatMessage({ id: "payment-plugin.orders.retry", defaultMessage: "Retry" }) })
|
|
256
173
|
}
|
|
257
174
|
) });
|
|
@@ -267,13 +184,14 @@ const Orders = () => {
|
|
|
267
184
|
] }),
|
|
268
185
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
269
186
|
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: exportOrders, children: formatMessage({ id: "payment-plugin.orders.export", defaultMessage: "Export" }) }),
|
|
270
|
-
/* @__PURE__ */ jsx(Button, { onClick: fetchOrders })
|
|
187
|
+
/* @__PURE__ */ jsx(Button, { onClick: fetchOrders, children: formatMessage({ id: "payment-plugin.orders.refresh", defaultMessage: "Refresh" }) })
|
|
271
188
|
] })
|
|
272
189
|
] }) }),
|
|
273
190
|
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
|
|
274
191
|
/* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsx(
|
|
275
192
|
TextInput,
|
|
276
193
|
{
|
|
194
|
+
label: formatMessage({ id: "payment-plugin.orders.search.label", defaultMessage: "Search" }),
|
|
277
195
|
placeholder: formatMessage({
|
|
278
196
|
id: "payment-plugin.orders.search.placeholder",
|
|
279
197
|
defaultMessage: "Search orders..."
|
|
@@ -285,6 +203,7 @@ const Orders = () => {
|
|
|
285
203
|
/* @__PURE__ */ jsx(Grid.Item, { col: 2, children: /* @__PURE__ */ jsxs(
|
|
286
204
|
SingleSelect,
|
|
287
205
|
{
|
|
206
|
+
label: formatMessage({ id: "payment-plugin.orders.status.label", defaultMessage: "Order Status" }),
|
|
288
207
|
placeholder: formatMessage({
|
|
289
208
|
id: "payment-plugin.orders.status.placeholder",
|
|
290
209
|
defaultMessage: "All Statuses"
|
|
@@ -295,8 +214,7 @@ const Orders = () => {
|
|
|
295
214
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.orders.all", defaultMessage: "All" }) }),
|
|
296
215
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "pending", children: formatMessage({ id: "payment-plugin.orders.pending", defaultMessage: "Pending" }) }),
|
|
297
216
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "processing", children: formatMessage({ id: "payment-plugin.orders.processing", defaultMessage: "Processing" }) }),
|
|
298
|
-
/* @__PURE__ */ jsx(SingleSelectOption, { value: "
|
|
299
|
-
/* @__PURE__ */ jsx(SingleSelectOption, { value: "delivered", children: formatMessage({ id: "payment-plugin.orders.delivered", defaultMessage: "Delivered" }) }),
|
|
217
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "completed", children: formatMessage({ id: "payment-plugin.orders.completed", defaultMessage: "Completed" }) }),
|
|
300
218
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "cancelled", children: formatMessage({ id: "payment-plugin.orders.cancelled", defaultMessage: "Cancelled" }) })
|
|
301
219
|
]
|
|
302
220
|
}
|
|
@@ -304,9 +222,10 @@ const Orders = () => {
|
|
|
304
222
|
/* @__PURE__ */ jsx(Grid.Item, { col: 2, children: /* @__PURE__ */ jsxs(
|
|
305
223
|
SingleSelect,
|
|
306
224
|
{
|
|
225
|
+
label: formatMessage({ id: "payment-plugin.orders.paymentStatus.label", defaultMessage: "Payment Status" }),
|
|
307
226
|
placeholder: formatMessage({
|
|
308
227
|
id: "payment-plugin.orders.paymentStatus.placeholder",
|
|
309
|
-
defaultMessage: "All
|
|
228
|
+
defaultMessage: "All"
|
|
310
229
|
}),
|
|
311
230
|
value: filters.paymentStatus,
|
|
312
231
|
onChange: (value) => handleFilterChange("paymentStatus", value),
|
|
@@ -322,6 +241,7 @@ const Orders = () => {
|
|
|
322
241
|
/* @__PURE__ */ jsx(Grid.Item, { col: 2, children: /* @__PURE__ */ jsxs(
|
|
323
242
|
SingleSelect,
|
|
324
243
|
{
|
|
244
|
+
label: formatMessage({ id: "payment-plugin.orders.currency.label", defaultMessage: "Currency" }),
|
|
325
245
|
placeholder: formatMessage({
|
|
326
246
|
id: "payment-plugin.orders.currency.placeholder",
|
|
327
247
|
defaultMessage: "All Currencies"
|
|
@@ -336,31 +256,38 @@ const Orders = () => {
|
|
|
336
256
|
]
|
|
337
257
|
}
|
|
338
258
|
) }),
|
|
339
|
-
/* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsx(Flex, { gap: 2, children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: clearFilters, children: formatMessage({ id: "payment-plugin.orders.clearFilters", defaultMessage: "Clear" }) }) }) })
|
|
259
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsx(Flex, { gap: 2, alignItems: "flex-end", height: "100%", children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: clearFilters, children: formatMessage({ id: "payment-plugin.orders.clearFilters", defaultMessage: "Clear" }) }) }) })
|
|
340
260
|
] }) }) }),
|
|
341
261
|
/* @__PURE__ */ jsx(Box, { marginTop: 4, marginBottom: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage(
|
|
342
|
-
{ id: "payment-plugin.orders.results", defaultMessage: "
|
|
343
|
-
{
|
|
344
|
-
start: startIndex + 1,
|
|
345
|
-
end: Math.min(endIndex, filteredOrders.length),
|
|
346
|
-
total: filteredOrders.length
|
|
347
|
-
}
|
|
262
|
+
{ id: "payment-plugin.orders.results", defaultMessage: "{total} orders" },
|
|
263
|
+
{ total: totalCount }
|
|
348
264
|
) }) }),
|
|
349
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
{
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
265
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(OrderList, { orders }) }),
|
|
266
|
+
totalPages > 1 && /* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxs(Pagination, { activePage: currentPage, pageCount: totalPages, label: "Orders pagination", children: [
|
|
267
|
+
/* @__PURE__ */ jsx(
|
|
268
|
+
PreviousLink,
|
|
269
|
+
{
|
|
270
|
+
as: "button",
|
|
271
|
+
onClick: () => setCurrentPage((p) => Math.max(1, p - 1))
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => /* @__PURE__ */ jsx(
|
|
275
|
+
PageLink,
|
|
276
|
+
{
|
|
277
|
+
number: page,
|
|
278
|
+
as: "button",
|
|
279
|
+
onClick: () => setCurrentPage(page)
|
|
280
|
+
},
|
|
281
|
+
page
|
|
282
|
+
)),
|
|
283
|
+
/* @__PURE__ */ jsx(
|
|
284
|
+
NextLink,
|
|
285
|
+
{
|
|
286
|
+
as: "button",
|
|
287
|
+
onClick: () => setCurrentPage((p) => Math.min(totalPages, p + 1))
|
|
288
|
+
}
|
|
289
|
+
)
|
|
290
|
+
] }) }) })
|
|
364
291
|
] });
|
|
365
292
|
};
|
|
366
293
|
export {
|
|
@@ -10,7 +10,6 @@ const PaymentList = ({
|
|
|
10
10
|
compact = false
|
|
11
11
|
}) => {
|
|
12
12
|
const { formatMessage } = useIntl();
|
|
13
|
-
console.log("Payments:", payments);
|
|
14
13
|
const formatCurrency = (amount, currency = "usd") => {
|
|
15
14
|
return new Intl.NumberFormat("en-US", {
|
|
16
15
|
style: "currency",
|
|
@@ -26,14 +25,14 @@ const PaymentList = ({
|
|
|
26
25
|
};
|
|
27
26
|
const getStatusBadge = (status) => {
|
|
28
27
|
const statusConfig = {
|
|
29
|
-
succeeded: {
|
|
30
|
-
pending: {
|
|
31
|
-
failed: {
|
|
32
|
-
refunded: {
|
|
33
|
-
canceled: {
|
|
28
|
+
succeeded: { variant: "success", label: "Success" },
|
|
29
|
+
pending: { variant: "warning", label: "Pending" },
|
|
30
|
+
failed: { variant: "danger", label: "Failed" },
|
|
31
|
+
refunded: { variant: "secondary", label: "Refunded" },
|
|
32
|
+
canceled: { variant: "neutral", label: "Canceled" }
|
|
34
33
|
};
|
|
35
34
|
const config = statusConfig[status] || statusConfig.pending;
|
|
36
|
-
return /* @__PURE__ */ jsx(Badge, { size: compact ? "S" : "M",
|
|
35
|
+
return /* @__PURE__ */ jsx(Badge, { size: compact ? "S" : "M", variant: config.variant, children: config.label });
|
|
37
36
|
};
|
|
38
37
|
const handlePaymentClick = (payment) => {
|
|
39
38
|
if (onPaymentClick) {
|
|
@@ -64,42 +63,18 @@ const PaymentList = ({
|
|
|
64
63
|
{
|
|
65
64
|
textColor: "neutral800",
|
|
66
65
|
fontWeight: compact ? "normal" : "bold",
|
|
67
|
-
|
|
68
|
-
children: payment.customerName || "Unknown -"
|
|
66
|
+
children: payment.customerName || "Unknown"
|
|
69
67
|
}
|
|
70
68
|
),
|
|
71
|
-
|
|
72
|
-
compact && /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", variant: "epsilon", fontSize: "0.75rem", children: payment.customerEmail })
|
|
69
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral600", variant: "epsilon", children: payment.customerEmail })
|
|
73
70
|
] }) }),
|
|
74
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
75
|
-
Typography,
|
|
76
|
-
{
|
|
77
|
-
textColor: "neutral800",
|
|
78
|
-
fontWeight: "bold",
|
|
79
|
-
fontSize: compact ? "0.875rem" : "1rem",
|
|
80
|
-
children: formatCurrency(payment.amount, payment.currency)
|
|
81
|
-
}
|
|
82
|
-
) }),
|
|
71
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: formatCurrency(payment.amount, payment.currency) }) }),
|
|
83
72
|
/* @__PURE__ */ jsx(Td, { children: getStatusBadge(payment.payment_status) }),
|
|
84
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
children: formatMessage({
|
|
90
|
-
id: `payment-plugin.paymentList.${payment.payment_method}`,
|
|
91
|
-
defaultMessage: payment.payment_method
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
) }),
|
|
95
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
96
|
-
Typography,
|
|
97
|
-
{
|
|
98
|
-
textColor: "neutral600",
|
|
99
|
-
fontSize: compact ? "0.75rem" : "0.875rem",
|
|
100
|
-
children: formatDate(payment.createdAt)
|
|
101
|
-
}
|
|
102
|
-
) }),
|
|
73
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
|
|
74
|
+
id: `payment-plugin.paymentList.${payment.payment_method}`,
|
|
75
|
+
defaultMessage: payment.payment_method
|
|
76
|
+
}) }) }),
|
|
77
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatDate(payment.createdAt) }) }),
|
|
103
78
|
!compact && /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
104
79
|
/* @__PURE__ */ jsx(
|
|
105
80
|
Button,
|
|
@@ -11,7 +11,6 @@ const PaymentList = ({
|
|
|
11
11
|
compact = false
|
|
12
12
|
}) => {
|
|
13
13
|
const { formatMessage } = reactIntl.useIntl();
|
|
14
|
-
console.log("Payments:", payments);
|
|
15
14
|
const formatCurrency = (amount, currency = "usd") => {
|
|
16
15
|
return new Intl.NumberFormat("en-US", {
|
|
17
16
|
style: "currency",
|
|
@@ -27,14 +26,14 @@ const PaymentList = ({
|
|
|
27
26
|
};
|
|
28
27
|
const getStatusBadge = (status) => {
|
|
29
28
|
const statusConfig = {
|
|
30
|
-
succeeded: {
|
|
31
|
-
pending: {
|
|
32
|
-
failed: {
|
|
33
|
-
refunded: {
|
|
34
|
-
canceled: {
|
|
29
|
+
succeeded: { variant: "success", label: "Success" },
|
|
30
|
+
pending: { variant: "warning", label: "Pending" },
|
|
31
|
+
failed: { variant: "danger", label: "Failed" },
|
|
32
|
+
refunded: { variant: "secondary", label: "Refunded" },
|
|
33
|
+
canceled: { variant: "neutral", label: "Canceled" }
|
|
35
34
|
};
|
|
36
35
|
const config = statusConfig[status] || statusConfig.pending;
|
|
37
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { size: compact ? "S" : "M",
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { size: compact ? "S" : "M", variant: config.variant, children: config.label });
|
|
38
37
|
};
|
|
39
38
|
const handlePaymentClick = (payment) => {
|
|
40
39
|
if (onPaymentClick) {
|
|
@@ -65,42 +64,18 @@ const PaymentList = ({
|
|
|
65
64
|
{
|
|
66
65
|
textColor: "neutral800",
|
|
67
66
|
fontWeight: compact ? "normal" : "bold",
|
|
68
|
-
|
|
69
|
-
children: payment.customerName || "Unknown -"
|
|
67
|
+
children: payment.customerName || "Unknown"
|
|
70
68
|
}
|
|
71
69
|
),
|
|
72
|
-
|
|
73
|
-
compact && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", variant: "epsilon", fontSize: "0.75rem", children: payment.customerEmail })
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", variant: "epsilon", children: payment.customerEmail })
|
|
74
71
|
] }) }),
|
|
75
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
-
designSystem.Typography,
|
|
77
|
-
{
|
|
78
|
-
textColor: "neutral800",
|
|
79
|
-
fontWeight: "bold",
|
|
80
|
-
fontSize: compact ? "0.875rem" : "1rem",
|
|
81
|
-
children: formatCurrency(payment.amount, payment.currency)
|
|
82
|
-
}
|
|
83
|
-
) }),
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: formatCurrency(payment.amount, payment.currency) }) }),
|
|
84
73
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: getStatusBadge(payment.payment_status) }),
|
|
85
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
children: formatMessage({
|
|
91
|
-
id: `payment-plugin.paymentList.${payment.payment_method}`,
|
|
92
|
-
defaultMessage: payment.payment_method
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
) }),
|
|
96
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
-
designSystem.Typography,
|
|
98
|
-
{
|
|
99
|
-
textColor: "neutral600",
|
|
100
|
-
fontSize: compact ? "0.75rem" : "0.875rem",
|
|
101
|
-
children: formatDate(payment.createdAt)
|
|
102
|
-
}
|
|
103
|
-
) }),
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
|
75
|
+
id: `payment-plugin.paymentList.${payment.payment_method}`,
|
|
76
|
+
defaultMessage: payment.payment_method
|
|
77
|
+
}) }) }),
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatDate(payment.createdAt) }) }),
|
|
104
79
|
!compact && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
105
80
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
106
81
|
designSystem.Button,
|