@reeboot/strapi-payment-plugin 0.0.1 → 0.0.3
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 +378 -119
- package/dist/_chunks/Analytics-DSJqY9ng.mjs +355 -0
- package/dist/_chunks/Analytics-nBSdLT2v.js +355 -0
- package/dist/_chunks/App-B83DZ9NG.js +70 -0
- package/dist/_chunks/App-BUSTbkyy.mjs +68 -0
- package/dist/_chunks/Customers-BpFzfglV.js +273 -0
- package/dist/_chunks/Customers-C6FH7-zG.mjs +273 -0
- package/dist/_chunks/Dashboard-CNMTzSyc.js +180 -0
- package/dist/_chunks/Dashboard-Dbwl0ZBo.mjs +180 -0
- package/dist/_chunks/Orders-CBkT2YfP.mjs +308 -0
- package/dist/_chunks/Orders-OG-pwV-B.js +308 -0
- package/dist/_chunks/Payments-BLen1P9N.js +489 -0
- package/dist/_chunks/Payments-DSDJ-HWm.mjs +489 -0
- package/dist/_chunks/Settings-Dq1xy32B.js +357 -0
- package/dist/_chunks/Settings-jmGslDsB.mjs +357 -0
- package/dist/_chunks/en-BJocyOVu.mjs +240 -0
- package/dist/_chunks/en-BkVAf_R4.js +240 -0
- package/dist/_chunks/index-BqqrpI6D.js +66 -0
- package/dist/_chunks/index-DS_PYNkf.mjs +67 -0
- package/dist/admin/index.js +2 -63
- package/dist/admin/index.mjs +2 -63
- package/dist/admin/src/components/AnalyticsChart.d.ts +19 -0
- package/dist/admin/src/components/CustomerList.d.ts +21 -0
- package/dist/admin/src/components/OrderList.d.ts +27 -0
- package/dist/admin/src/components/PaymentCard.d.ts +39 -0
- package/dist/admin/src/components/PaymentList.d.ts +19 -0
- package/dist/admin/src/components/RefundModal.d.ts +15 -0
- package/dist/admin/src/pages/Analytics.d.ts +2 -0
- package/dist/admin/src/pages/Customers.d.ts +2 -0
- package/dist/admin/src/pages/Dashboard.d.ts +2 -0
- package/dist/admin/src/pages/HomePage.d.ts +1 -1
- package/dist/admin/src/pages/Orders.d.ts +2 -0
- package/dist/admin/src/pages/Payments.d.ts +2 -0
- package/dist/admin/src/pages/Settings.d.ts +2 -0
- package/dist/admin/src/pluginId.d.ts +1 -1
- package/dist/server/index.js +1770 -992
- package/dist/server/index.mjs +1773 -995
- package/dist/server/src/bootstrap.d.ts +5 -11
- package/dist/server/src/config/index.d.ts +0 -10
- package/dist/server/src/content-types/customer/index.d.ts +69 -0
- package/dist/server/src/content-types/index.d.ts +123 -39
- package/dist/server/src/content-types/{product.d.ts → order/index.d.ts} +26 -19
- package/dist/server/src/content-types/{subscription.d.ts → payment/index.d.ts} +30 -21
- package/dist/server/src/controllers/controller.d.ts +5 -12
- package/dist/server/src/controllers/index.d.ts +29 -34
- package/dist/server/src/controllers/stripe.d.ts +104 -0
- package/dist/server/src/index.d.ts +179 -139
- package/dist/server/src/middlewares/index.d.ts +19 -1
- package/dist/server/src/policies/index.d.ts +3 -1
- package/dist/server/src/routes/{admin-routes.d.ts → admin/index.d.ts} +4 -4
- package/dist/server/src/routes/content-api/index.d.ts +21 -0
- package/dist/server/src/routes/index.d.ts +11 -16
- package/dist/server/src/services/index.d.ts +2 -38
- package/dist/server/src/services/{stripeDriver.d.ts → stripe.d.ts} +52 -59
- package/dist/server/src/types/index.d.ts +179 -0
- package/package.json +20 -25
- package/dist/_chunks/App-DD7GyuRr.mjs +0 -1424
- package/dist/_chunks/App-KZVBFRwo.js +0 -1424
- package/dist/_chunks/en-B4KWt_jN.js +0 -4
- package/dist/_chunks/en-Byx4XI2L.mjs +0 -4
- package/dist/admin/src/components/Header.d.ts +0 -2
- package/dist/admin/src/components/NavigationMenu.d.ts +0 -2
- package/dist/admin/src/components/Sidebar.d.ts +0 -2
- package/dist/admin/src/components/TransactionDetailsModal.d.ts +0 -18
- package/dist/admin/src/components/TransactionList.d.ts +0 -18
- package/dist/admin/src/pages/ConfigurationPage.d.ts +0 -2
- package/dist/admin/src/pages/DashboardPage.d.ts +0 -2
- package/dist/admin/src/pages/ProductsPage.d.ts +0 -2
- package/dist/admin/src/pages/SubscriptionsPage.d.ts +0 -2
- package/dist/admin/src/pages/TransactionsPage.d.ts +0 -2
- package/dist/server/src/controllers/product.d.ts +0 -18
- package/dist/server/src/controllers/subscription.d.ts +0 -16
- package/dist/server/src/controllers/webhook.d.ts +0 -10
- package/dist/server/src/routes/content-api.d.ts +0 -12
- package/dist/server/src/routes/product.d.ts +0 -2
- package/dist/server/src/routes/refund-routes.d.ts +0 -13
- package/dist/server/src/routes/subscription.d.ts +0 -5
- package/dist/server/src/routes/webhook.d.ts +0 -15
- package/dist/server/src/services/paypalDriver.d.ts +0 -47
- package/dist/server/src/services/product.d.ts +0 -7
- package/dist/server/src/services/service.d.ts +0 -26
- package/dist/server/src/services/subscription.d.ts +0 -9
- package/dist/server/src/services/sync.d.ts +0 -13
- package/jest.config.js +0 -13
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { Box, Typography, Flex, ProgressBar, Grid, Loader, EmptyStateLayout, Button, SingleSelect, SingleSelectOption, Card, Badge, Table, Thead, Tr, Th, Tbody, Td } from "@strapi/design-system";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { useFetchClient } from "@strapi/strapi/admin";
|
|
6
|
+
import { P as PLUGIN_ID } from "./index-DS_PYNkf.mjs";
|
|
7
|
+
const AnalyticsChart = ({ data, currency = "usd", type }) => {
|
|
8
|
+
const formatCurrency = (amount) => {
|
|
9
|
+
return new Intl.NumberFormat("en-US", {
|
|
10
|
+
style: "currency",
|
|
11
|
+
currency: currency.toUpperCase()
|
|
12
|
+
}).format(amount);
|
|
13
|
+
};
|
|
14
|
+
const formatNumber = (num) => {
|
|
15
|
+
return new Intl.NumberFormat("en-US").format(num);
|
|
16
|
+
};
|
|
17
|
+
const renderLineChart = (trendData) => {
|
|
18
|
+
const maxRevenue = Math.max(...trendData.revenue);
|
|
19
|
+
const maxPayments = Math.max(...trendData.payments);
|
|
20
|
+
const maxCustomers = Math.max(...trendData.customers);
|
|
21
|
+
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
|
|
22
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsxs(Box, { marginBottom: 4, children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", children: "Revenue Trend" }),
|
|
24
|
+
/* @__PURE__ */ jsx(Flex, { direction: "row", gap: 8, children: trendData.labels.map((label, index) => {
|
|
25
|
+
const revenueValue = trendData.revenue[index];
|
|
26
|
+
const percentage = revenueValue / maxRevenue * 100;
|
|
27
|
+
console.log("Revenue Value:", revenueValue, "Percentage:", percentage);
|
|
28
|
+
console.log("trend data:", trendData);
|
|
29
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
30
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", marginBottom: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", fontWeight: "bold", children: formatCurrency(revenueValue) }) }),
|
|
31
|
+
/* @__PURE__ */ jsx(ProgressBar, { value: percentage })
|
|
32
|
+
] }, index);
|
|
33
|
+
}) })
|
|
34
|
+
] }) }),
|
|
35
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsxs(Box, { marginBottom: 4, children: [
|
|
36
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", children: "Payments Trend" }),
|
|
37
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, children: trendData.labels.map((label, index) => {
|
|
38
|
+
const paymentsValue = trendData.payments[index];
|
|
39
|
+
const percentage = paymentsValue / maxPayments * 100;
|
|
40
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", marginBottom: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", fontWeight: "bold", children: formatNumber(paymentsValue) }) }),
|
|
42
|
+
/* @__PURE__ */ jsx(ProgressBar, { value: percentage })
|
|
43
|
+
] }, index);
|
|
44
|
+
}) })
|
|
45
|
+
] }) }),
|
|
46
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsxs(Box, { marginBottom: 4, children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", children: "Customer Growth" }),
|
|
48
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, children: trendData.labels.map((label, index) => {
|
|
49
|
+
const customersValue = trendData.customers[index];
|
|
50
|
+
const percentage = customersValue / maxCustomers * 100;
|
|
51
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
52
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", marginBottom: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", fontWeight: "bold", children: formatNumber(customersValue) }) }),
|
|
53
|
+
/* @__PURE__ */ jsx(ProgressBar, { value: percentage })
|
|
54
|
+
] }, index);
|
|
55
|
+
}) })
|
|
56
|
+
] }) })
|
|
57
|
+
] }) });
|
|
58
|
+
};
|
|
59
|
+
const renderPieChart = (paymentData) => {
|
|
60
|
+
const colors = ["#4945FF", "#0F9D58", "#FF6B35", "#9C27B0", "#FF9800"];
|
|
61
|
+
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 3, children: paymentData.map((item, index) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
62
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
|
|
63
|
+
/* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, children: [
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
Box,
|
|
66
|
+
{
|
|
67
|
+
style: {
|
|
68
|
+
width: "12px",
|
|
69
|
+
height: "12px",
|
|
70
|
+
backgroundColor: colors[index % colors.length],
|
|
71
|
+
borderRadius: "50%"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", fontWeight: "bold", children: item.method })
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "epsilon", textColor: "neutral600", children: [
|
|
78
|
+
item.percentage,
|
|
79
|
+
"%"
|
|
80
|
+
] })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsx(ProgressBar, { value: item.percentage }),
|
|
83
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "epsilon", textColor: "neutral600", marginTop: 1, children: [
|
|
84
|
+
formatNumber(item.count),
|
|
85
|
+
" transactions"
|
|
86
|
+
] })
|
|
87
|
+
] }, index)) }) });
|
|
88
|
+
};
|
|
89
|
+
const renderBarChart = (chartData) => {
|
|
90
|
+
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: "Bar chart visualization coming soon..." }) });
|
|
91
|
+
};
|
|
92
|
+
const renderChart = () => {
|
|
93
|
+
switch (type) {
|
|
94
|
+
case "line":
|
|
95
|
+
return renderLineChart(data);
|
|
96
|
+
case "pie":
|
|
97
|
+
return renderPieChart(data);
|
|
98
|
+
case "bar":
|
|
99
|
+
return renderBarChart();
|
|
100
|
+
default:
|
|
101
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "danger500", children: "Invalid chart type" });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return /* @__PURE__ */ jsx(Box, { children: renderChart() });
|
|
105
|
+
};
|
|
106
|
+
const Analytics = () => {
|
|
107
|
+
const { formatMessage } = useIntl();
|
|
108
|
+
const { get } = useFetchClient();
|
|
109
|
+
const [analyticsData, setAnalyticsData] = useState(null);
|
|
110
|
+
const [loading, setLoading] = useState(true);
|
|
111
|
+
const [error, setError] = useState(null);
|
|
112
|
+
const [dateRange, setDateRange] = useState("30d");
|
|
113
|
+
const [currency, setCurrency] = useState("usd");
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
fetchAnalyticsData();
|
|
116
|
+
}, [dateRange, currency]);
|
|
117
|
+
const fetchAnalyticsData = async () => {
|
|
118
|
+
try {
|
|
119
|
+
setLoading(true);
|
|
120
|
+
const { data } = await get(`/${PLUGIN_ID}/admin/analytics?period=${dateRange}`);
|
|
121
|
+
if (data.success && data.data) {
|
|
122
|
+
const dailyStats = data.data.dailyStats || {};
|
|
123
|
+
const labels = Object.keys(dailyStats).sort();
|
|
124
|
+
const revenue = labels.map((label) => dailyStats[label].amount);
|
|
125
|
+
const payments = labels.map((label) => dailyStats[label].count);
|
|
126
|
+
setAnalyticsData({
|
|
127
|
+
revenue: {
|
|
128
|
+
total: data.data.totalVolume,
|
|
129
|
+
growth: 0,
|
|
130
|
+
period: `Last ${dateRange}`
|
|
131
|
+
},
|
|
132
|
+
payments: {
|
|
133
|
+
total: data.data.totalTransactions,
|
|
134
|
+
successRate: 100,
|
|
135
|
+
averageAmount: data.data.averageTransaction,
|
|
136
|
+
period: `Last ${dateRange}`
|
|
137
|
+
},
|
|
138
|
+
customers: {
|
|
139
|
+
total: 0,
|
|
140
|
+
newCustomers: 0,
|
|
141
|
+
returningCustomers: 0,
|
|
142
|
+
period: `Last ${dateRange}`
|
|
143
|
+
},
|
|
144
|
+
trends: {
|
|
145
|
+
labels,
|
|
146
|
+
revenue,
|
|
147
|
+
payments,
|
|
148
|
+
customers: Array(labels.length).fill(0)
|
|
149
|
+
},
|
|
150
|
+
topProducts: [],
|
|
151
|
+
paymentMethods: [],
|
|
152
|
+
geographicData: []
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
setLoading(false);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
setError("Failed to fetch analytics data");
|
|
158
|
+
setLoading(false);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const formatCurrency = (amount, currency2 = "usd") => {
|
|
162
|
+
return new Intl.NumberFormat("en-US", {
|
|
163
|
+
style: "currency",
|
|
164
|
+
currency: currency2.toUpperCase()
|
|
165
|
+
}).format(amount);
|
|
166
|
+
};
|
|
167
|
+
const exportReport = () => {
|
|
168
|
+
if (!analyticsData) return;
|
|
169
|
+
const csvContent = [
|
|
170
|
+
["Analytics Report", (/* @__PURE__ */ new Date()).toLocaleDateString()],
|
|
171
|
+
[""],
|
|
172
|
+
["SUMMARY"],
|
|
173
|
+
["Total Revenue", formatCurrency(analyticsData.revenue.total, currency)],
|
|
174
|
+
["Revenue Growth", `${analyticsData.revenue.growth}%`],
|
|
175
|
+
["Total Payments", analyticsData.payments.total.toString()],
|
|
176
|
+
["Success Rate", `${analyticsData.payments.successRate}%`],
|
|
177
|
+
["Average Amount", formatCurrency(analyticsData.payments.averageAmount, currency)],
|
|
178
|
+
["Total Customers", analyticsData.customers.total.toString()],
|
|
179
|
+
["New Customers", analyticsData.customers.newCustomers.toString()],
|
|
180
|
+
[""],
|
|
181
|
+
["TOP PRODUCTS"],
|
|
182
|
+
["Product Name", "Revenue", "Quantity Sold"],
|
|
183
|
+
...analyticsData.topProducts.map((product) => [
|
|
184
|
+
product.name,
|
|
185
|
+
formatCurrency(product.revenue, currency),
|
|
186
|
+
product.quantity.toString()
|
|
187
|
+
]),
|
|
188
|
+
[""],
|
|
189
|
+
["PAYMENT METHODS"],
|
|
190
|
+
["Method", "Count", "Percentage"],
|
|
191
|
+
...analyticsData.paymentMethods.map((method) => [
|
|
192
|
+
method.method,
|
|
193
|
+
method.count.toString(),
|
|
194
|
+
`${method.percentage}%`
|
|
195
|
+
]),
|
|
196
|
+
[""],
|
|
197
|
+
["GEOGRAPHIC DATA"],
|
|
198
|
+
["Country", "Revenue", "Transactions"],
|
|
199
|
+
...analyticsData.geographicData.map((geo) => [
|
|
200
|
+
geo.country,
|
|
201
|
+
formatCurrency(geo.revenue, currency),
|
|
202
|
+
geo.transactions.toString()
|
|
203
|
+
])
|
|
204
|
+
].map((row) => row.join(",")).join("\n");
|
|
205
|
+
const blob = new Blob([csvContent], { type: "text/csv" });
|
|
206
|
+
const url = window.URL.createObjectURL(blob);
|
|
207
|
+
const a = document.createElement("a");
|
|
208
|
+
a.href = url;
|
|
209
|
+
a.download = `payment-analytics-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
|
|
210
|
+
a.click();
|
|
211
|
+
window.URL.revokeObjectURL(url);
|
|
212
|
+
};
|
|
213
|
+
if (loading) {
|
|
214
|
+
return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Loader, {}) }) });
|
|
215
|
+
}
|
|
216
|
+
if (error) {
|
|
217
|
+
return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(
|
|
218
|
+
EmptyStateLayout,
|
|
219
|
+
{
|
|
220
|
+
title: "Error loading analytics",
|
|
221
|
+
subtitle: error,
|
|
222
|
+
action: /* @__PURE__ */ jsx(Button, { onClick: fetchAnalyticsData, children: formatMessage({ id: "payment-plugin.analytics.retry", defaultMessage: "Retry" }) })
|
|
223
|
+
}
|
|
224
|
+
) });
|
|
225
|
+
}
|
|
226
|
+
if (!analyticsData) return null;
|
|
227
|
+
return /* @__PURE__ */ jsxs(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, children: [
|
|
228
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
|
|
229
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
230
|
+
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: "payment-plugin.analytics.title", defaultMessage: "Analytics" }) }),
|
|
231
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({
|
|
232
|
+
id: "payment-plugin.analytics.subtitle",
|
|
233
|
+
defaultMessage: "Payment insights and performance metrics"
|
|
234
|
+
}) })
|
|
235
|
+
] }),
|
|
236
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
237
|
+
/* @__PURE__ */ jsxs(
|
|
238
|
+
SingleSelect,
|
|
239
|
+
{
|
|
240
|
+
value: dateRange,
|
|
241
|
+
onChange: (value) => setDateRange(value),
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "7d", children: "Last 7 days" }),
|
|
244
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "30d", children: "Last 30 days" }),
|
|
245
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "90d", children: "Last 90 days" }),
|
|
246
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "1y", children: "Last year" })
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsxs(
|
|
251
|
+
SingleSelect,
|
|
252
|
+
{
|
|
253
|
+
value: currency,
|
|
254
|
+
onChange: (value) => setCurrency(value),
|
|
255
|
+
children: [
|
|
256
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "usd", children: "USD" }),
|
|
257
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "eur", children: "EUR" }),
|
|
258
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "gbp", children: "GBP" })
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: exportReport, children: formatMessage({ id: "payment-plugin.analytics.export", defaultMessage: "Export Report" }) }),
|
|
263
|
+
/* @__PURE__ */ jsx(Button, { onClick: fetchAnalyticsData, children: formatMessage({ id: "payment-plugin.analytics.refresh", defaultMessage: "Refresh" }) })
|
|
264
|
+
] })
|
|
265
|
+
] }) }),
|
|
266
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: 4, marginBottom: 4, children: [
|
|
267
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
|
268
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({ id: "payment-plugin.analytics.totalRevenue", defaultMessage: "Total Revenue" }) }),
|
|
269
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", children: formatCurrency(analyticsData.revenue.total, currency) }),
|
|
270
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
271
|
+
/* @__PURE__ */ jsxs(Badge, { size: "S", backgroundColor: "success", children: [
|
|
272
|
+
"+",
|
|
273
|
+
analyticsData.revenue.growth,
|
|
274
|
+
"%"
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: analyticsData.revenue.period })
|
|
277
|
+
] })
|
|
278
|
+
] }) }) }) }),
|
|
279
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
|
280
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({ id: "payment-plugin.analytics.successRate", defaultMessage: "Success Rate" }) }),
|
|
281
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", children: [
|
|
282
|
+
analyticsData.payments.successRate,
|
|
283
|
+
"%"
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage(
|
|
286
|
+
{ id: "payment-plugin.analytics.outOfPayments", defaultMessage: "{total} payments" },
|
|
287
|
+
{ total: analyticsData.payments.total }
|
|
288
|
+
) })
|
|
289
|
+
] }) }) }) }),
|
|
290
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
|
291
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({ id: "payment-plugin.analytics.averageAmount", defaultMessage: "Average Amount" }) }),
|
|
292
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", children: formatCurrency(analyticsData.payments.averageAmount, currency) }),
|
|
293
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: analyticsData.payments.period })
|
|
294
|
+
] }) }) }) })
|
|
295
|
+
] }),
|
|
296
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: 4, marginBottom: 4, children: [
|
|
297
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 8, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsxs(Box, { padding: 4, style: { width: "100%" }, children: [
|
|
298
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", tag: "h2", marginBottom: 4, children: formatMessage({ id: "payment-plugin.analytics.trends", defaultMessage: "Revenue Trends" }) }),
|
|
299
|
+
/* @__PURE__ */ jsx(
|
|
300
|
+
AnalyticsChart,
|
|
301
|
+
{
|
|
302
|
+
data: analyticsData.trends,
|
|
303
|
+
currency,
|
|
304
|
+
type: "line"
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
] }) }) }),
|
|
308
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxs(Box, { padding: 4, children: [
|
|
309
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", tag: "h2", marginBottom: 4, children: formatMessage({ id: "payment-plugin.analytics.paymentMethods", defaultMessage: "Payment Methods" }) }),
|
|
310
|
+
/* @__PURE__ */ jsx(
|
|
311
|
+
AnalyticsChart,
|
|
312
|
+
{
|
|
313
|
+
data: analyticsData.paymentMethods,
|
|
314
|
+
type: "pie"
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
] }) }) })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
|
|
320
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsxs(Box, { padding: 4, children: [
|
|
321
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", tag: "h2", marginBottom: 4, children: formatMessage({ id: "payment-plugin.analytics.topProducts", defaultMessage: "Top Products" }) }),
|
|
322
|
+
/* @__PURE__ */ jsxs(Table, { children: [
|
|
323
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
324
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.analytics.product", defaultMessage: "Product" }) }) }),
|
|
325
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.analytics.revenue", defaultMessage: "Revenue" }) }) }),
|
|
326
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.analytics.quantity", defaultMessage: "Quantity" }) }) })
|
|
327
|
+
] }) }),
|
|
328
|
+
/* @__PURE__ */ jsx(Tbody, { children: analyticsData.topProducts.map((product, index) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
329
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: product.name }) }),
|
|
330
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatCurrency(product.revenue, currency) }) }),
|
|
331
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: product.quantity }) })
|
|
332
|
+
] }, index)) })
|
|
333
|
+
] })
|
|
334
|
+
] }) }) }),
|
|
335
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsxs(Box, { padding: 4, children: [
|
|
336
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", tag: "h2", marginBottom: 4, children: formatMessage({ id: "payment-plugin.analytics.geographic", defaultMessage: "Geographic Distribution" }) }),
|
|
337
|
+
/* @__PURE__ */ jsxs(Table, { children: [
|
|
338
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
339
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.analytics.country", defaultMessage: "Country" }) }) }),
|
|
340
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.analytics.revenue", defaultMessage: "Revenue" }) }) }),
|
|
341
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.analytics.transactions", defaultMessage: "Transactions" }) }) })
|
|
342
|
+
] }) }),
|
|
343
|
+
/* @__PURE__ */ jsx(Tbody, { children: analyticsData.geographicData.map((geo, index) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
344
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: geo.country }) }),
|
|
345
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatCurrency(geo.revenue, currency) }) }),
|
|
346
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: geo.transactions }) })
|
|
347
|
+
] }, index)) })
|
|
348
|
+
] })
|
|
349
|
+
] }) }) })
|
|
350
|
+
] })
|
|
351
|
+
] });
|
|
352
|
+
};
|
|
353
|
+
export {
|
|
354
|
+
Analytics
|
|
355
|
+
};
|