@reeboot/strapi-payment-plugin 0.0.3 → 0.0.5

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.
Files changed (46) hide show
  1. package/dist/_chunks/{Analytics-nBSdLT2v.js → Analytics-CLjtRWYA.js} +68 -51
  2. package/dist/_chunks/{Analytics-DSJqY9ng.mjs → Analytics-CQmAVKsq.mjs} +68 -51
  3. package/dist/_chunks/App-DXN62SV6.mjs +118 -0
  4. package/dist/_chunks/App-Dk7XtjNA.js +120 -0
  5. package/dist/_chunks/{Customers-BpFzfglV.js → Customers-BNDi4QBH.js} +113 -51
  6. package/dist/_chunks/{Customers-C6FH7-zG.mjs → Customers-BQzVBQDT.mjs} +114 -52
  7. package/dist/_chunks/Dashboard-CuHC-dit.mjs +311 -0
  8. package/dist/_chunks/Dashboard-UUwohHZa.js +311 -0
  9. package/dist/_chunks/{Orders-CBkT2YfP.mjs → Orders-65mNfu2i.mjs} +140 -80
  10. package/dist/_chunks/{Orders-OG-pwV-B.js → Orders-CitNCdWE.js} +139 -79
  11. package/dist/_chunks/PaymentList-B0CAzInT.mjs +137 -0
  12. package/dist/_chunks/PaymentList-Dy1BAFoD.js +136 -0
  13. package/dist/_chunks/{Payments-DSDJ-HWm.mjs → Payments-FnhoV_2B.mjs} +175 -136
  14. package/dist/_chunks/{Payments-BLen1P9N.js → Payments-TOnygGIW.js} +173 -134
  15. package/dist/_chunks/Settings-BJtDagUs.js +644 -0
  16. package/dist/_chunks/Settings-EoLSuZLe.mjs +644 -0
  17. package/dist/_chunks/{index-DS_PYNkf.mjs → index-2Zd_T7bD.mjs} +1 -1
  18. package/dist/_chunks/{index-BqqrpI6D.js → index-CHEgJ7e5.js} +1 -1
  19. package/dist/admin/index.js +1 -1
  20. package/dist/admin/index.mjs +1 -1
  21. package/dist/admin/src/components/CustomerList.d.ts +1 -13
  22. package/dist/admin/src/components/IntegrationModal.d.ts +7 -0
  23. package/dist/admin/src/components/OrderList.d.ts +1 -19
  24. package/dist/admin/src/components/PaymentCard.d.ts +2 -33
  25. package/dist/admin/src/components/PaymentList.d.ts +3 -11
  26. package/dist/admin/src/components/RefundModal.d.ts +2 -8
  27. package/dist/admin/src/types/index.d.ts +47 -0
  28. package/dist/server/index.js +198 -92
  29. package/dist/server/index.mjs +198 -92
  30. package/dist/server/src/content-types/index.d.ts +9 -2
  31. package/dist/server/src/content-types/order/index.d.ts +8 -1
  32. package/dist/server/src/content-types/payment/index.d.ts +1 -1
  33. package/dist/server/src/index.d.ts +9 -2
  34. package/dist/server/src/types/api.d.ts +31 -0
  35. package/dist/server/src/types/customer.d.ts +2 -0
  36. package/dist/server/src/types/index.d.ts +4 -179
  37. package/dist/server/src/types/order.d.ts +2 -0
  38. package/dist/server/src/types/payment.d.ts +2 -0
  39. package/package.json +8 -7
  40. package/dist/_chunks/App-B83DZ9NG.js +0 -70
  41. package/dist/_chunks/App-BUSTbkyy.mjs +0 -68
  42. package/dist/_chunks/Dashboard-CNMTzSyc.js +0 -180
  43. package/dist/_chunks/Dashboard-Dbwl0ZBo.mjs +0 -180
  44. package/dist/_chunks/Settings-Dq1xy32B.js +0 -357
  45. package/dist/_chunks/Settings-jmGslDsB.mjs +0 -357
  46. package/dist/admin/src/pages/HomePage.d.ts +0 -2
@@ -1,9 +1,117 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
- import { Box, Flex, Loader, EmptyStateLayout, Button, Typography, Card, Grid, TextInput, SingleSelect, SingleSelectOption, Table, Thead, Tr, Th, Tbody, Td, Pagination, Badge } 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 } 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-DS_PYNkf.mjs";
6
+ import { P as PLUGIN_ID } from "./index-2Zd_T7bD.mjs";
7
+ const OrderList = ({ orders, onOrderClick, compact = false }) => {
8
+ const { formatMessage } = useIntl();
9
+ console.log("Orders:", orders);
10
+ const formatCurrency = (amount, currency = "usd") => {
11
+ return new Intl.NumberFormat("en-US", {
12
+ style: "currency",
13
+ currency: currency.toUpperCase()
14
+ }).format(amount);
15
+ };
16
+ const getStatusBadge = (status, type) => {
17
+ const configs = {
18
+ order: {
19
+ pending: { color: "warning", label: "Pending" },
20
+ processing: { color: "info", label: "Processing" },
21
+ shipped: { color: "secondary", label: "Shipped" },
22
+ delivered: { color: "success", label: "Delivered" },
23
+ cancelled: { color: "danger", label: "Cancelled" },
24
+ refunded: { color: "neutral", label: "Refunded" }
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
+ }
32
+ };
33
+ let config;
34
+ if (type === "order") {
35
+ config = configs.order[status] || configs.order.pending;
36
+ } else {
37
+ config = configs.payment[status] || configs.payment.unpaid;
38
+ }
39
+ return /* @__PURE__ */ jsx(Badge, { size: compact ? "S" : "M", backgroundColor: config.color, children: config.label });
40
+ };
41
+ const handleOrderClick = (order) => {
42
+ if (onOrderClick) {
43
+ onOrderClick(order);
44
+ }
45
+ };
46
+ if (orders.length === 0) {
47
+ return /* @__PURE__ */ jsx(Box, { padding: 4, textAlign: "center", children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({ id: "payment-plugin.orderList.empty", defaultMessage: "No orders found" }) }) });
48
+ }
49
+ return /* @__PURE__ */ jsxs(Table, { children: [
50
+ /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
51
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.orderNumber", defaultMessage: "Order #" }) }) }),
52
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.customer", defaultMessage: "Customer" }) }) }),
53
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.items", defaultMessage: "Items" }) }) }),
54
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.total", defaultMessage: "Total" }) }) }),
55
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.status", defaultMessage: "Status" }) }) }),
56
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.paymentStatus", defaultMessage: "Payment" }) }) })
57
+ ] }) }),
58
+ /* @__PURE__ */ jsx(Tbody, { children: orders.map((order) => /* @__PURE__ */ jsxs(
59
+ Tr,
60
+ {
61
+ onClick: () => handleOrderClick(order),
62
+ style: { cursor: onOrderClick ? "pointer" : "default" },
63
+ 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
+ ) }),
74
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, children: [
75
+ /* @__PURE__ */ jsx(
76
+ Typography,
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 })
85
+ ] }) }),
86
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(
87
+ Typography,
88
+ {
89
+ textColor: "neutral600",
90
+ fontSize: compact ? "0.75rem" : "0.875rem",
91
+ children: [
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
+ ) }),
107
+ /* @__PURE__ */ jsx(Td, { children: getStatusBadge(order.order_status, "order") }),
108
+ /* @__PURE__ */ jsx(Td, { children: getStatusBadge(order.paymentStatus, "payment") })
109
+ ]
110
+ },
111
+ order.id
112
+ )) })
113
+ ] });
114
+ };
7
115
  const Orders = () => {
8
116
  const { formatMessage } = useIntl();
9
117
  const { get } = useFetchClient();
@@ -15,7 +123,7 @@ const Orders = () => {
15
123
  const [pageSize, setPageSize] = useState(25);
16
124
  const [totalCount, setTotalCount] = useState(0);
17
125
  const [filters, setFilters] = useState({
18
- status: "",
126
+ order_status: "",
19
127
  paymentStatus: "",
20
128
  dateRange: { from: null, to: null },
21
129
  search: "",
@@ -33,22 +141,17 @@ const Orders = () => {
33
141
  const queryParams = new URLSearchParams({
34
142
  page: currentPage.toString(),
35
143
  pageSize: pageSize.toString(),
36
- ...filters.status && { status: filters.status }
144
+ ...filters.order_status && { order_status: filters.order_status }
37
145
  });
38
146
  const { data } = await get(`/${PLUGIN_ID}/admin/orders?${queryParams}`);
39
147
  if (data.success && data.data) {
40
148
  const formattedOrders = data.data.map((o) => ({
149
+ ...o,
41
150
  id: o.documentId,
42
- orderNumber: o.order_number,
43
151
  customerEmail: o.customer?.email || "N/A",
44
- customerName: o.customer ? `${o.customer.firstName || ""} ${o.customer.lastName || ""}`.trim() : "N/A",
45
- status: o.status,
46
- totalAmount: o.total_amount,
47
- currency: o.currency,
48
- paymentStatus: o.status === "completed" ? "paid" : "unpaid",
49
- items: Array.isArray(o.items) ? o.items : [],
50
- createdAt: o.createdAt,
51
- updatedAt: o.updatedAt
152
+ customerName: o.customer ? `${o.customer.first_name || ""} ${o.customer.last_name || ""}`.trim() : "N/A",
153
+ paymentStatus: o.payment_status || (o.order_status === "completed" ? "paid" : "unpaid"),
154
+ items: Array.isArray(o.items) ? o.items : []
52
155
  }));
53
156
  setOrders(formattedOrders);
54
157
  setTotalCount(data.meta.pagination.total);
@@ -64,11 +167,11 @@ const Orders = () => {
64
167
  if (filters.search) {
65
168
  const searchLower = filters.search.toLowerCase();
66
169
  filtered = filtered.filter(
67
- (order) => order.orderNumber.toLowerCase().includes(searchLower) || order.customerEmail.toLowerCase().includes(searchLower) || order.customerName?.toLowerCase().includes(searchLower)
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)
68
171
  );
69
172
  }
70
- if (filters.status) {
71
- filtered = filtered.filter((order) => order.status === filters.status);
173
+ if (filters.order_status) {
174
+ filtered = filtered.filter((order) => order.order_status === filters.order_status);
72
175
  }
73
176
  if (filters.paymentStatus) {
74
177
  filtered = filtered.filter((order) => order.paymentStatus === filters.paymentStatus);
@@ -88,11 +191,8 @@ const Orders = () => {
88
191
  }
89
192
  setFilteredOrders(filtered);
90
193
  };
91
- const formatCurrency = (amount, currency = "usd") => {
92
- return new Intl.NumberFormat("en-US", {
93
- style: "currency",
94
- currency: currency.toUpperCase()
95
- }).format(amount);
194
+ const handleOrderClick = (order) => {
195
+ console.log("Clicked order:", order);
96
196
  };
97
197
  const formatDate = (dateString) => {
98
198
  return new Date(dateString).toLocaleDateString("en-US", {
@@ -103,33 +203,13 @@ const Orders = () => {
103
203
  minute: "2-digit"
104
204
  });
105
205
  };
106
- const getStatusBadge = (status, type) => {
107
- const configs = {
108
- order: {
109
- pending: { color: "warning", label: "Pending" },
110
- processing: { color: "info", label: "Processing" },
111
- shipped: { color: "secondary", label: "Shipped" },
112
- delivered: { color: "success", label: "Delivered" },
113
- cancelled: { color: "danger", label: "Cancelled" },
114
- refunded: { color: "neutral", label: "Refunded" }
115
- },
116
- payment: {
117
- unpaid: { color: "danger", label: "Unpaid" },
118
- paid: { color: "success", label: "Paid" },
119
- partially_paid: { color: "warning", label: "Partially Paid" },
120
- refunded: { color: "neutral", label: "Refunded" }
121
- }
122
- };
123
- const config = type === "order" ? configs.order[status] || configs.order.pending : configs.payment[status] || configs.payment.unpaid;
124
- return /* @__PURE__ */ jsx(Badge, { size: "S", backgroundColor: config.color, children: config.label });
125
- };
126
206
  const handleFilterChange = (key, value) => {
127
207
  setFilters((prev) => ({ ...prev, [key]: value }));
128
208
  setCurrentPage(1);
129
209
  };
130
210
  const clearFilters = () => {
131
211
  setFilters({
132
- status: "",
212
+ order_status: "",
133
213
  paymentStatus: "",
134
214
  dateRange: { from: null, to: null },
135
215
  search: "",
@@ -141,12 +221,12 @@ const Orders = () => {
141
221
  const csvContent = [
142
222
  ["Order Number", "Customer Email", "Customer Name", "Status", "Payment Status", "Total Amount", "Currency", "Date"],
143
223
  ...filteredOrders.map((order) => [
144
- order.orderNumber,
145
- order.customerEmail,
224
+ order.order_number || "",
225
+ order.customerEmail || "",
146
226
  order.customerName || "",
147
- order.status,
148
- order.paymentStatus,
149
- (order.totalAmount / 100).toString(),
227
+ order.order_status,
228
+ order.paymentStatus || "",
229
+ order.total_amount.toString(),
150
230
  order.currency,
151
231
  formatDate(order.createdAt)
152
232
  ])
@@ -164,10 +244,10 @@ const Orders = () => {
164
244
  const paginatedOrders = filteredOrders.slice(startIndex, endIndex);
165
245
  const totalPages = Math.ceil(filteredOrders.length / pageSize);
166
246
  if (loading && orders.length === 0) {
167
- return /* @__PURE__ */ jsx(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Loader, {}) }) });
247
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Loader, {}) }) });
168
248
  }
169
249
  if (error) {
170
- return /* @__PURE__ */ jsx(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: /* @__PURE__ */ jsx(
250
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
171
251
  EmptyStateLayout,
172
252
  {
173
253
  title: "Error loading orders",
@@ -176,7 +256,7 @@ const Orders = () => {
176
256
  }
177
257
  ) });
178
258
  }
179
- return /* @__PURE__ */ jsxs(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: [
259
+ return /* @__PURE__ */ jsxs(Box, { children: [
180
260
  /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
181
261
  /* @__PURE__ */ jsxs(Box, { children: [
182
262
  /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: "payment-plugin.orders.title", defaultMessage: "Orders" }) }),
@@ -187,7 +267,7 @@ const Orders = () => {
187
267
  ] }),
188
268
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
189
269
  /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: exportOrders, children: formatMessage({ id: "payment-plugin.orders.export", defaultMessage: "Export" }) }),
190
- /* @__PURE__ */ jsx(Button, { onClick: () => window.location.reload(), children: formatMessage({ id: "payment-plugin.orders.refresh", defaultMessage: "Refresh" }) })
270
+ /* @__PURE__ */ jsx(Button, { onClick: fetchOrders })
191
271
  ] })
192
272
  ] }) }),
193
273
  /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
@@ -209,8 +289,8 @@ const Orders = () => {
209
289
  id: "payment-plugin.orders.status.placeholder",
210
290
  defaultMessage: "All Statuses"
211
291
  }),
212
- value: filters.status,
213
- onChange: (value) => handleFilterChange("status", value),
292
+ value: filters.order_status,
293
+ onChange: (value) => handleFilterChange("order_status", value),
214
294
  children: [
215
295
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.orders.all", defaultMessage: "All" }) }),
216
296
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "pending", children: formatMessage({ id: "payment-plugin.orders.pending", defaultMessage: "Pending" }) }),
@@ -266,33 +346,13 @@ const Orders = () => {
266
346
  total: filteredOrders.length
267
347
  }
268
348
  ) }) }),
269
- /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Table, { children: [
270
- /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
271
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.orderNumber", defaultMessage: "Order #" }) }) }),
272
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.customer", defaultMessage: "Customer" }) }) }),
273
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.items", defaultMessage: "Items" }) }) }),
274
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.total", defaultMessage: "Total" }) }) }),
275
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.status", defaultMessage: "Order Status" }) }) }),
276
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.paymentStatus", defaultMessage: "Payment Status" }) }) }),
277
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.date", defaultMessage: "Date" }) }) })
278
- ] }) }),
279
- /* @__PURE__ */ jsx(Tbody, { children: paginatedOrders.map((order) => /* @__PURE__ */ jsxs(Tr, { children: [
280
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", fontFamily: "monospace", children: order.orderNumber }) }),
281
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Box, { children: [
282
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: order.customerName || "Unknown -" }),
283
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", variant: "epsilon", children: order.customerEmail })
284
- ] }) }),
285
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", children: [
286
- order.items.length,
287
- " ",
288
- order.items.length === 1 ? "item" : "items"
289
- ] }) }),
290
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: formatCurrency(order.totalAmount, order.currency) }) }),
291
- /* @__PURE__ */ jsx(Td, { children: getStatusBadge(order.status, "order") }),
292
- /* @__PURE__ */ jsx(Td, { children: getStatusBadge(order.paymentStatus, "payment") }),
293
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatDate(order.createdAt) }) })
294
- ] }, order.id)) })
295
- ] }) }) }),
349
+ /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(
350
+ OrderList,
351
+ {
352
+ orders: paginatedOrders,
353
+ onOrderClick: handleOrderClick
354
+ }
355
+ ) }),
296
356
  totalPages > 1 && /* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsx(
297
357
  Pagination,
298
358
  {
@@ -5,7 +5,115 @@ const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const reactIntl = require("react-intl");
7
7
  const admin = require("@strapi/strapi/admin");
8
- const index = require("./index-BqqrpI6D.js");
8
+ const index = require("./index-CHEgJ7e5.js");
9
+ const OrderList = ({ orders, onOrderClick, compact = false }) => {
10
+ const { formatMessage } = reactIntl.useIntl();
11
+ console.log("Orders:", orders);
12
+ const formatCurrency = (amount, currency = "usd") => {
13
+ return new Intl.NumberFormat("en-US", {
14
+ style: "currency",
15
+ currency: currency.toUpperCase()
16
+ }).format(amount);
17
+ };
18
+ const getStatusBadge = (status, type) => {
19
+ const configs = {
20
+ order: {
21
+ pending: { color: "warning", label: "Pending" },
22
+ processing: { color: "info", label: "Processing" },
23
+ shipped: { color: "secondary", label: "Shipped" },
24
+ delivered: { color: "success", label: "Delivered" },
25
+ cancelled: { color: "danger", label: "Cancelled" },
26
+ refunded: { color: "neutral", label: "Refunded" }
27
+ },
28
+ payment: {
29
+ unpaid: { color: "danger", label: "Unpaid" },
30
+ paid: { color: "success", label: "Paid" },
31
+ partially_paid: { color: "warning", label: "Partially Paid" },
32
+ refunded: { color: "neutral", label: "Refunded" }
33
+ }
34
+ };
35
+ let config;
36
+ if (type === "order") {
37
+ config = configs.order[status] || configs.order.pending;
38
+ } else {
39
+ config = configs.payment[status] || configs.payment.unpaid;
40
+ }
41
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { size: compact ? "S" : "M", backgroundColor: config.color, children: config.label });
42
+ };
43
+ const handleOrderClick = (order) => {
44
+ if (onOrderClick) {
45
+ onOrderClick(order);
46
+ }
47
+ };
48
+ if (orders.length === 0) {
49
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, textAlign: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({ id: "payment-plugin.orderList.empty", defaultMessage: "No orders found" }) }) });
50
+ }
51
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { children: [
52
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
53
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.orderNumber", defaultMessage: "Order #" }) }) }),
54
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.customer", defaultMessage: "Customer" }) }) }),
55
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.items", defaultMessage: "Items" }) }) }),
56
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.total", defaultMessage: "Total" }) }) }),
57
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.status", defaultMessage: "Status" }) }) }),
58
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: compact ? "epsilon" : "delta", children: formatMessage({ id: "payment-plugin.orderList.paymentStatus", defaultMessage: "Payment" }) }) })
59
+ ] }) }),
60
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: orders.map((order) => /* @__PURE__ */ jsxRuntime.jsxs(
61
+ designSystem.Tr,
62
+ {
63
+ onClick: () => handleOrderClick(order),
64
+ style: { cursor: onOrderClick ? "pointer" : "default" },
65
+ children: [
66
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
67
+ designSystem.Typography,
68
+ {
69
+ textColor: "neutral800",
70
+ fontWeight: "bold",
71
+ fontFamily: "monospace",
72
+ fontSize: compact ? "0.875rem" : "1rem",
73
+ children: order.order_number
74
+ }
75
+ ) }),
76
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, children: [
77
+ /* @__PURE__ */ jsxRuntime.jsx(
78
+ designSystem.Typography,
79
+ {
80
+ textColor: "neutral800",
81
+ fontWeight: compact ? "normal" : "bold",
82
+ fontSize: compact ? "0.875rem" : "1rem",
83
+ children: order.customerName || "Unknown"
84
+ }
85
+ ),
86
+ compact && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", variant: "epsilon", fontSize: "0.75rem", children: order.customerEmail })
87
+ ] }) }),
88
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(
89
+ designSystem.Typography,
90
+ {
91
+ textColor: "neutral600",
92
+ fontSize: compact ? "0.75rem" : "0.875rem",
93
+ children: [
94
+ order.items ? order.items.length : 0,
95
+ " ",
96
+ order.items && order.items.length === 1 ? "item" : "items"
97
+ ]
98
+ }
99
+ ) }),
100
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
101
+ designSystem.Typography,
102
+ {
103
+ textColor: "neutral800",
104
+ fontWeight: "bold",
105
+ fontSize: compact ? "0.875rem" : "1rem",
106
+ children: formatCurrency(order.total_amount, order.currency)
107
+ }
108
+ ) }),
109
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: getStatusBadge(order.order_status, "order") }),
110
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: getStatusBadge(order.paymentStatus, "payment") })
111
+ ]
112
+ },
113
+ order.id
114
+ )) })
115
+ ] });
116
+ };
9
117
  const Orders = () => {
10
118
  const { formatMessage } = reactIntl.useIntl();
11
119
  const { get } = admin.useFetchClient();
@@ -17,7 +125,7 @@ const Orders = () => {
17
125
  const [pageSize, setPageSize] = React.useState(25);
18
126
  const [totalCount, setTotalCount] = React.useState(0);
19
127
  const [filters, setFilters] = React.useState({
20
- status: "",
128
+ order_status: "",
21
129
  paymentStatus: "",
22
130
  dateRange: { from: null, to: null },
23
131
  search: "",
@@ -35,22 +143,17 @@ const Orders = () => {
35
143
  const queryParams = new URLSearchParams({
36
144
  page: currentPage.toString(),
37
145
  pageSize: pageSize.toString(),
38
- ...filters.status && { status: filters.status }
146
+ ...filters.order_status && { order_status: filters.order_status }
39
147
  });
40
148
  const { data } = await get(`/${index.PLUGIN_ID}/admin/orders?${queryParams}`);
41
149
  if (data.success && data.data) {
42
150
  const formattedOrders = data.data.map((o) => ({
151
+ ...o,
43
152
  id: o.documentId,
44
- orderNumber: o.order_number,
45
153
  customerEmail: o.customer?.email || "N/A",
46
- customerName: o.customer ? `${o.customer.firstName || ""} ${o.customer.lastName || ""}`.trim() : "N/A",
47
- status: o.status,
48
- totalAmount: o.total_amount,
49
- currency: o.currency,
50
- paymentStatus: o.status === "completed" ? "paid" : "unpaid",
51
- items: Array.isArray(o.items) ? o.items : [],
52
- createdAt: o.createdAt,
53
- updatedAt: o.updatedAt
154
+ customerName: o.customer ? `${o.customer.first_name || ""} ${o.customer.last_name || ""}`.trim() : "N/A",
155
+ paymentStatus: o.payment_status || (o.order_status === "completed" ? "paid" : "unpaid"),
156
+ items: Array.isArray(o.items) ? o.items : []
54
157
  }));
55
158
  setOrders(formattedOrders);
56
159
  setTotalCount(data.meta.pagination.total);
@@ -66,11 +169,11 @@ const Orders = () => {
66
169
  if (filters.search) {
67
170
  const searchLower = filters.search.toLowerCase();
68
171
  filtered = filtered.filter(
69
- (order) => order.orderNumber.toLowerCase().includes(searchLower) || order.customerEmail.toLowerCase().includes(searchLower) || order.customerName?.toLowerCase().includes(searchLower)
172
+ (order) => order.order_number && order.order_number.toLowerCase().includes(searchLower) || order.customerEmail && order.customerEmail.toLowerCase().includes(searchLower) || order.customerName && order.customerName.toLowerCase().includes(searchLower)
70
173
  );
71
174
  }
72
- if (filters.status) {
73
- filtered = filtered.filter((order) => order.status === filters.status);
175
+ if (filters.order_status) {
176
+ filtered = filtered.filter((order) => order.order_status === filters.order_status);
74
177
  }
75
178
  if (filters.paymentStatus) {
76
179
  filtered = filtered.filter((order) => order.paymentStatus === filters.paymentStatus);
@@ -90,11 +193,8 @@ const Orders = () => {
90
193
  }
91
194
  setFilteredOrders(filtered);
92
195
  };
93
- const formatCurrency = (amount, currency = "usd") => {
94
- return new Intl.NumberFormat("en-US", {
95
- style: "currency",
96
- currency: currency.toUpperCase()
97
- }).format(amount);
196
+ const handleOrderClick = (order) => {
197
+ console.log("Clicked order:", order);
98
198
  };
99
199
  const formatDate = (dateString) => {
100
200
  return new Date(dateString).toLocaleDateString("en-US", {
@@ -105,33 +205,13 @@ const Orders = () => {
105
205
  minute: "2-digit"
106
206
  });
107
207
  };
108
- const getStatusBadge = (status, type) => {
109
- const configs = {
110
- order: {
111
- pending: { color: "warning", label: "Pending" },
112
- processing: { color: "info", label: "Processing" },
113
- shipped: { color: "secondary", label: "Shipped" },
114
- delivered: { color: "success", label: "Delivered" },
115
- cancelled: { color: "danger", label: "Cancelled" },
116
- refunded: { color: "neutral", label: "Refunded" }
117
- },
118
- payment: {
119
- unpaid: { color: "danger", label: "Unpaid" },
120
- paid: { color: "success", label: "Paid" },
121
- partially_paid: { color: "warning", label: "Partially Paid" },
122
- refunded: { color: "neutral", label: "Refunded" }
123
- }
124
- };
125
- const config = type === "order" ? configs.order[status] || configs.order.pending : configs.payment[status] || configs.payment.unpaid;
126
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { size: "S", backgroundColor: config.color, children: config.label });
127
- };
128
208
  const handleFilterChange = (key, value) => {
129
209
  setFilters((prev) => ({ ...prev, [key]: value }));
130
210
  setCurrentPage(1);
131
211
  };
132
212
  const clearFilters = () => {
133
213
  setFilters({
134
- status: "",
214
+ order_status: "",
135
215
  paymentStatus: "",
136
216
  dateRange: { from: null, to: null },
137
217
  search: "",
@@ -143,12 +223,12 @@ const Orders = () => {
143
223
  const csvContent = [
144
224
  ["Order Number", "Customer Email", "Customer Name", "Status", "Payment Status", "Total Amount", "Currency", "Date"],
145
225
  ...filteredOrders.map((order) => [
146
- order.orderNumber,
147
- order.customerEmail,
226
+ order.order_number || "",
227
+ order.customerEmail || "",
148
228
  order.customerName || "",
149
- order.status,
150
- order.paymentStatus,
151
- (order.totalAmount / 100).toString(),
229
+ order.order_status,
230
+ order.paymentStatus || "",
231
+ order.total_amount.toString(),
152
232
  order.currency,
153
233
  formatDate(order.createdAt)
154
234
  ])
@@ -166,10 +246,10 @@ const Orders = () => {
166
246
  const paginatedOrders = filteredOrders.slice(startIndex, endIndex);
167
247
  const totalPages = Math.ceil(filteredOrders.length / pageSize);
168
248
  if (loading && orders.length === 0) {
169
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, {}) }) });
249
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, {}) }) });
170
250
  }
171
251
  if (error) {
172
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: /* @__PURE__ */ jsxRuntime.jsx(
252
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
173
253
  designSystem.EmptyStateLayout,
174
254
  {
175
255
  title: "Error loading orders",
@@ -178,7 +258,7 @@ const Orders = () => {
178
258
  }
179
259
  ) });
180
260
  }
181
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: [
261
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
182
262
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
183
263
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
184
264
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: "payment-plugin.orders.title", defaultMessage: "Orders" }) }),
@@ -189,7 +269,7 @@ const Orders = () => {
189
269
  ] }),
190
270
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
191
271
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: exportOrders, children: formatMessage({ id: "payment-plugin.orders.export", defaultMessage: "Export" }) }),
192
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => window.location.reload(), children: formatMessage({ id: "payment-plugin.orders.refresh", defaultMessage: "Refresh" }) })
272
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: fetchOrders })
193
273
  ] })
194
274
  ] }) }),
195
275
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
@@ -211,8 +291,8 @@ const Orders = () => {
211
291
  id: "payment-plugin.orders.status.placeholder",
212
292
  defaultMessage: "All Statuses"
213
293
  }),
214
- value: filters.status,
215
- onChange: (value) => handleFilterChange("status", value),
294
+ value: filters.order_status,
295
+ onChange: (value) => handleFilterChange("order_status", value),
216
296
  children: [
217
297
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.orders.all", defaultMessage: "All" }) }),
218
298
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "pending", children: formatMessage({ id: "payment-plugin.orders.pending", defaultMessage: "Pending" }) }),
@@ -268,33 +348,13 @@ const Orders = () => {
268
348
  total: filteredOrders.length
269
349
  }
270
350
  ) }) }),
271
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { children: [
272
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
273
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.orderNumber", defaultMessage: "Order #" }) }) }),
274
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.customer", defaultMessage: "Customer" }) }) }),
275
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.items", defaultMessage: "Items" }) }) }),
276
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.total", defaultMessage: "Total" }) }) }),
277
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.status", defaultMessage: "Order Status" }) }) }),
278
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.paymentStatus", defaultMessage: "Payment Status" }) }) }),
279
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.orders.date", defaultMessage: "Date" }) }) })
280
- ] }) }),
281
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: paginatedOrders.map((order) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
282
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", fontFamily: "monospace", children: order.orderNumber }) }),
283
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
284
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: order.customerName || "Unknown -" }),
285
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", variant: "epsilon", children: order.customerEmail })
286
- ] }) }),
287
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral600", children: [
288
- order.items.length,
289
- " ",
290
- order.items.length === 1 ? "item" : "items"
291
- ] }) }),
292
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: formatCurrency(order.totalAmount, order.currency) }) }),
293
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: getStatusBadge(order.status, "order") }),
294
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: getStatusBadge(order.paymentStatus, "payment") }),
295
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatDate(order.createdAt) }) })
296
- ] }, order.id)) })
297
- ] }) }) }),
351
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(
352
+ OrderList,
353
+ {
354
+ orders: paginatedOrders,
355
+ onOrderClick: handleOrderClick
356
+ }
357
+ ) }),
298
358
  totalPages > 1 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
299
359
  designSystem.Pagination,
300
360
  {