medusa-analytics 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +476 -848
- package/.medusa/server/src/admin/index.mjs +477 -849
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { useState, useEffect, useMemo } from "react";
|
|
|
3
3
|
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
4
4
|
import { CurrencyDollar, ShoppingCart, TruckFast, Cash, UsersSolid, User, UserGroup, Trash, Tag, CubeSolid, ChartBar } from "@medusajs/icons";
|
|
5
5
|
import { Container, Text, Heading, Label, Table } from "@medusajs/ui";
|
|
6
|
-
import { ResponsiveContainer,
|
|
6
|
+
import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip, Bar, ComposedChart, Line, Legend, Area, LineChart, ReferenceLine, PieChart, Pie, Cell, ScatterChart, Scatter } from "recharts";
|
|
7
7
|
const ACCENT_STYLES = {
|
|
8
8
|
blue: {
|
|
9
9
|
border: "border-sky-400/30",
|
|
@@ -295,37 +295,72 @@ function formatChartLabel$2(value) {
|
|
|
295
295
|
function formatPercent(value) {
|
|
296
296
|
return `${value.toFixed(1)}%`;
|
|
297
297
|
}
|
|
298
|
-
function ordersCountFromPiePayload(payload) {
|
|
299
|
-
if (typeof payload !== "object" || payload === null) return 0;
|
|
300
|
-
if (!("orders_count" in payload)) return 0;
|
|
301
|
-
const c = payload.orders_count;
|
|
302
|
-
return Math.floor(Number(c) || 0);
|
|
303
|
-
}
|
|
304
298
|
function formatShortNumber$1(value) {
|
|
305
299
|
return new Intl.NumberFormat("en-IN", {
|
|
306
300
|
notation: "compact",
|
|
307
301
|
maximumFractionDigits: value < 10 ? 1 : 0
|
|
308
302
|
}).format(value);
|
|
309
303
|
}
|
|
310
|
-
|
|
304
|
+
const SALES_GRANULARITY_TABS = [
|
|
305
|
+
{ value: "day", label: "Day" },
|
|
306
|
+
{ value: "hour", label: "Hour" },
|
|
307
|
+
{ value: "week", label: "Week" },
|
|
308
|
+
{ value: "month", label: "Month" }
|
|
309
|
+
];
|
|
310
|
+
function monthKeyFromDateStr(dateStr) {
|
|
311
|
+
if (dateStr.length >= 7) return dateStr.slice(0, 7);
|
|
312
|
+
return dateStr;
|
|
313
|
+
}
|
|
314
|
+
function formatMonthBucketLabel(ymKey) {
|
|
315
|
+
const [ys, ms] = ymKey.split("-");
|
|
316
|
+
const y = Number(ys);
|
|
317
|
+
const m = Number(ms);
|
|
318
|
+
if (!Number.isFinite(y) || !Number.isFinite(m)) return ymKey;
|
|
319
|
+
return new Intl.DateTimeFormat("en-IN", {
|
|
320
|
+
month: "short",
|
|
321
|
+
year: "numeric",
|
|
322
|
+
timeZone: "UTC"
|
|
323
|
+
}).format(new Date(Date.UTC(y, m - 1, 1)));
|
|
324
|
+
}
|
|
325
|
+
function aggregateDailyOrdersForBreakdown(rows, keyFn, labelFn) {
|
|
326
|
+
const map = /* @__PURE__ */ new Map();
|
|
327
|
+
for (const d of rows) {
|
|
328
|
+
const key = keyFn(d);
|
|
329
|
+
const cur = map.get(key) ?? { orders: 0, revenue: 0, bucketRows: [] };
|
|
330
|
+
cur.orders += d.orders_count;
|
|
331
|
+
cur.revenue += d.total_revenue;
|
|
332
|
+
cur.bucketRows.push(d);
|
|
333
|
+
map.set(key, cur);
|
|
334
|
+
}
|
|
335
|
+
return Array.from(map.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([key, v]) => ({
|
|
336
|
+
key,
|
|
337
|
+
label: labelFn(key, v.bucketRows),
|
|
338
|
+
orders_count: v.orders,
|
|
339
|
+
revenue: v.revenue
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
function isSalesBreakdownBarRow(value) {
|
|
343
|
+
if (typeof value !== "object" || value === null) return false;
|
|
344
|
+
const v = value;
|
|
345
|
+
return typeof v.key === "string" && typeof v.label === "string" && typeof v.orders_count === "number" && typeof v.revenue === "number";
|
|
346
|
+
}
|
|
347
|
+
function SalesBreakdownTooltip({
|
|
311
348
|
active,
|
|
312
|
-
payload
|
|
313
|
-
label
|
|
349
|
+
payload
|
|
314
350
|
}) {
|
|
315
|
-
var _a, _b
|
|
351
|
+
var _a, _b;
|
|
316
352
|
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
317
|
-
const row =
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const revenue = ((_d = payload.find((entry) => entry.name === "Revenue")) == null ? void 0 : _d.value) ?? 0;
|
|
321
|
-
return /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { title: displayLabel, children: [
|
|
353
|
+
const row = isSalesBreakdownBarRow((_a = payload[0]) == null ? void 0 : _a.payload) ? (_b = payload[0]) == null ? void 0 : _b.payload : void 0;
|
|
354
|
+
if (!row) return null;
|
|
355
|
+
return /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { variant: "compact", title: row.label, children: [
|
|
322
356
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
323
|
-
"
|
|
324
|
-
/* @__PURE__ */ jsx("strong", { children:
|
|
357
|
+
"Revenue: ",
|
|
358
|
+
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(row.revenue) })
|
|
325
359
|
] }),
|
|
326
360
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
327
|
-
"
|
|
328
|
-
|
|
361
|
+
"Orders:",
|
|
362
|
+
" ",
|
|
363
|
+
/* @__PURE__ */ jsx("strong", { children: Math.floor(row.orders_count).toLocaleString() })
|
|
329
364
|
] })
|
|
330
365
|
] });
|
|
331
366
|
}
|
|
@@ -347,21 +382,6 @@ function OrdersTodayTooltip({
|
|
|
347
382
|
(row == null ? void 0 : row.isToday) ? /* @__PURE__ */ jsx("div", { style: { color: "#6B7280" }, children: "Current day" }) : null
|
|
348
383
|
] });
|
|
349
384
|
}
|
|
350
|
-
function OrdersSparklineTooltip({
|
|
351
|
-
active,
|
|
352
|
-
payload,
|
|
353
|
-
label
|
|
354
|
-
}) {
|
|
355
|
-
var _a, _b, _c;
|
|
356
|
-
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
357
|
-
const row = isDailyOrderRow((_a = payload[0]) == null ? void 0 : _a.payload) ? (_b = payload[0]) == null ? void 0 : _b.payload : void 0;
|
|
358
|
-
const displayLabel = (row == null ? void 0 : row.label) ?? (label ? new Date(label).toLocaleDateString() : "");
|
|
359
|
-
const orders = Number((_c = payload[0]) == null ? void 0 : _c.value) || 0;
|
|
360
|
-
return /* @__PURE__ */ jsx(AnalyticsTooltipCard, { variant: "compact", title: displayLabel, children: /* @__PURE__ */ jsxs("div", { children: [
|
|
361
|
-
"Orders: ",
|
|
362
|
-
/* @__PURE__ */ jsx("strong", { children: Math.floor(orders).toLocaleString() })
|
|
363
|
-
] }) });
|
|
364
|
-
}
|
|
365
385
|
function OutcomesTrendTooltip({
|
|
366
386
|
active,
|
|
367
387
|
payload,
|
|
@@ -378,6 +398,53 @@ function OutcomesTrendTooltip({
|
|
|
378
398
|
/* @__PURE__ */ jsx("strong", { children: Math.floor(Number(entry.value) || 0).toLocaleString() })
|
|
379
399
|
] }, String(entry.name))) });
|
|
380
400
|
}
|
|
401
|
+
function isTrendRowDetailed(value) {
|
|
402
|
+
if (!isDailyOrderRow(value)) return false;
|
|
403
|
+
const v = value;
|
|
404
|
+
return typeof v.aov === "number" && typeof v.prev_revenue === "number" && typeof v.prev_orders === "number" && typeof v.prev_aov === "number";
|
|
405
|
+
}
|
|
406
|
+
function CombinedMetricsTooltip({
|
|
407
|
+
active,
|
|
408
|
+
payload
|
|
409
|
+
}) {
|
|
410
|
+
var _a, _b;
|
|
411
|
+
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
412
|
+
const row = isTrendRowDetailed((_a = payload[0]) == null ? void 0 : _a.payload) ? (_b = payload[0]) == null ? void 0 : _b.payload : void 0;
|
|
413
|
+
if (!row) return null;
|
|
414
|
+
const title = row.label ?? formatChartLabel$2(row.date);
|
|
415
|
+
return /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { variant: "compact", title, children: [
|
|
416
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
417
|
+
"Revenue:",
|
|
418
|
+
" ",
|
|
419
|
+
/* @__PURE__ */ jsx("strong", { children: formatCompactCurrency$1(row.total_revenue) }),
|
|
420
|
+
/* @__PURE__ */ jsxs("span", { className: "text-ui-fg-muted", children: [
|
|
421
|
+
" ",
|
|
422
|
+
"· prev ",
|
|
423
|
+
formatCompactCurrency$1(row.prev_revenue)
|
|
424
|
+
] })
|
|
425
|
+
] }),
|
|
426
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
427
|
+
"Orders:",
|
|
428
|
+
" ",
|
|
429
|
+
/* @__PURE__ */ jsx("strong", { children: Math.floor(row.orders_count).toLocaleString() }),
|
|
430
|
+
/* @__PURE__ */ jsxs("span", { className: "text-ui-fg-muted", children: [
|
|
431
|
+
" ",
|
|
432
|
+
"· prev ",
|
|
433
|
+
Math.floor(row.prev_orders).toLocaleString()
|
|
434
|
+
] })
|
|
435
|
+
] }),
|
|
436
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
437
|
+
"AOV (non-canc.):",
|
|
438
|
+
" ",
|
|
439
|
+
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(row.aov) }),
|
|
440
|
+
/* @__PURE__ */ jsxs("span", { className: "text-ui-fg-muted", children: [
|
|
441
|
+
" ",
|
|
442
|
+
"· prev ",
|
|
443
|
+
formatCurrency$1(row.prev_aov)
|
|
444
|
+
] })
|
|
445
|
+
] })
|
|
446
|
+
] });
|
|
447
|
+
}
|
|
381
448
|
const KPI_ICON_BG$2 = {
|
|
382
449
|
green: "bg-emerald-500/20",
|
|
383
450
|
blue: "bg-sky-500/20",
|
|
@@ -391,53 +458,6 @@ const KPI_ICONS$2 = {
|
|
|
391
458
|
amber: Cash
|
|
392
459
|
};
|
|
393
460
|
const PIE_PALETTE = ["#6366F1", "#94A3B8", "#10B981", "#F59E0B"];
|
|
394
|
-
function TrafficRevenueDonut({ traffic }) {
|
|
395
|
-
return /* @__PURE__ */ jsx("div", { className: "h-[152px] w-full shrink-0", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(PieChart, { margin: { top: 2, right: 2, left: 2, bottom: 2 }, children: [
|
|
396
|
-
/* @__PURE__ */ jsx(
|
|
397
|
-
Pie,
|
|
398
|
-
{
|
|
399
|
-
data: traffic,
|
|
400
|
-
dataKey: "revenue",
|
|
401
|
-
nameKey: "label",
|
|
402
|
-
cx: "50%",
|
|
403
|
-
cy: "48%",
|
|
404
|
-
innerRadius: 34,
|
|
405
|
-
outerRadius: 54,
|
|
406
|
-
paddingAngle: 2,
|
|
407
|
-
children: traffic.map((_, i) => /* @__PURE__ */ jsx(Cell, { fill: PIE_PALETTE[i % PIE_PALETTE.length] }, `traffic-slice-${i}`))
|
|
408
|
-
}
|
|
409
|
-
),
|
|
410
|
-
/* @__PURE__ */ jsx(
|
|
411
|
-
Tooltip,
|
|
412
|
-
{
|
|
413
|
-
content: ({ active, payload }) => {
|
|
414
|
-
var _a, _b, _c;
|
|
415
|
-
return active && (payload == null ? void 0 : payload.length) ? /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { variant: "compact", title: String(((_a = payload[0]) == null ? void 0 : _a.name) ?? ""), children: [
|
|
416
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
417
|
-
"Revenue:",
|
|
418
|
-
" ",
|
|
419
|
-
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(Number((_b = payload[0]) == null ? void 0 : _b.value) || 0) })
|
|
420
|
-
] }),
|
|
421
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
422
|
-
"Orders:",
|
|
423
|
-
" ",
|
|
424
|
-
/* @__PURE__ */ jsx("strong", { children: ordersCountFromPiePayload((_c = payload[0]) == null ? void 0 : _c.payload).toLocaleString() })
|
|
425
|
-
] })
|
|
426
|
-
] }) : null;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
),
|
|
430
|
-
/* @__PURE__ */ jsx(
|
|
431
|
-
Legend,
|
|
432
|
-
{
|
|
433
|
-
wrapperStyle: { fontSize: 9, paddingTop: 0 },
|
|
434
|
-
verticalAlign: "bottom",
|
|
435
|
-
height: 22,
|
|
436
|
-
iconType: "circle"
|
|
437
|
-
}
|
|
438
|
-
)
|
|
439
|
-
] }) }) });
|
|
440
|
-
}
|
|
441
461
|
function AtlasKpiCard$2({
|
|
442
462
|
label,
|
|
443
463
|
value,
|
|
@@ -497,7 +517,7 @@ function EmptyAnalyticsPanel$1({
|
|
|
497
517
|
] });
|
|
498
518
|
}
|
|
499
519
|
function OrdersDashboard() {
|
|
500
|
-
var _a, _b
|
|
520
|
+
var _a, _b;
|
|
501
521
|
const [data, setData] = useState(null);
|
|
502
522
|
const [loading, setLoading] = useState(true);
|
|
503
523
|
const [error, setError] = useState(null);
|
|
@@ -513,6 +533,7 @@ function OrdersDashboard() {
|
|
|
513
533
|
const [todayContext, setTodayContext] = useState([]);
|
|
514
534
|
const [todayContextLoading, setTodayContextLoading] = useState(true);
|
|
515
535
|
const [todayContextError, setTodayContextError] = useState(null);
|
|
536
|
+
const [salesGranularity, setSalesGranularity] = useState("day");
|
|
516
537
|
useEffect(() => {
|
|
517
538
|
let cancelled = false;
|
|
518
539
|
setLoading(true);
|
|
@@ -708,14 +729,61 @@ function OrdersDashboard() {
|
|
|
708
729
|
revenue: h.revenue
|
|
709
730
|
}));
|
|
710
731
|
}, [ordersInsights]);
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
732
|
+
const salesBreakdownChartRows = useMemo(() => {
|
|
733
|
+
if (salesGranularity === "hour") {
|
|
734
|
+
return hourlyChartRows.map((h) => ({
|
|
735
|
+
key: `hour-${h.hour}`,
|
|
736
|
+
label: h.label,
|
|
737
|
+
orders_count: h.orders_count,
|
|
738
|
+
revenue: h.revenue
|
|
739
|
+
}));
|
|
740
|
+
}
|
|
741
|
+
if (salesGranularity === "week") {
|
|
742
|
+
if (!ordersInsights) return [];
|
|
743
|
+
return ordersInsights.byWeekday.map((w) => ({
|
|
744
|
+
key: `weekday-${w.weekday}`,
|
|
745
|
+
label: w.label,
|
|
746
|
+
orders_count: w.orders_count,
|
|
747
|
+
revenue: w.revenue
|
|
748
|
+
}));
|
|
749
|
+
}
|
|
750
|
+
if (salesGranularity === "month") {
|
|
751
|
+
return aggregateDailyOrdersForBreakdown(
|
|
752
|
+
dailyOrders,
|
|
753
|
+
(d) => monthKeyFromDateStr(d.date),
|
|
754
|
+
(ymKey) => formatMonthBucketLabel(ymKey)
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
return dailyOrders.map((d) => ({
|
|
758
|
+
key: d.date,
|
|
759
|
+
label: d.label ?? formatChartLabel$2(d.date),
|
|
760
|
+
orders_count: d.orders_count,
|
|
761
|
+
revenue: d.total_revenue
|
|
717
762
|
}));
|
|
718
|
-
}, [ordersInsights]);
|
|
763
|
+
}, [salesGranularity, dailyOrders, hourlyChartRows, ordersInsights]);
|
|
764
|
+
const salesBreakdownDescription = useMemo(() => {
|
|
765
|
+
var _a2;
|
|
766
|
+
const rangeLabel = ((_a2 = OVER_TIME_PERIODS.find((p) => p.value === overTimePeriod)) == null ? void 0 : _a2.label) ?? "selected range";
|
|
767
|
+
const insightsHint = `Order-time breakdown uses last ${insightsWindowDays} days (UTC).`;
|
|
768
|
+
switch (salesGranularity) {
|
|
769
|
+
case "day":
|
|
770
|
+
return `Revenue by calendar day for ${rangeLabel} (aligned with Revenue & orders).`;
|
|
771
|
+
case "hour":
|
|
772
|
+
return `${insightsHint} Bars show revenue by hour of day.`;
|
|
773
|
+
case "week":
|
|
774
|
+
return `Revenue by UTC weekday — last ${insightsWindowDays} days.`;
|
|
775
|
+
case "month":
|
|
776
|
+
return `Revenue summed by calendar month (UTC) across ${rangeLabel}.`;
|
|
777
|
+
default:
|
|
778
|
+
return "";
|
|
779
|
+
}
|
|
780
|
+
}, [salesGranularity, overTimePeriod, insightsWindowDays]);
|
|
781
|
+
const salesBreakdownXAxisInterval = useMemo(() => {
|
|
782
|
+
const n = salesBreakdownChartRows.length;
|
|
783
|
+
if (salesGranularity === "hour") return 3;
|
|
784
|
+
if (salesGranularity === "day" && n > 24) return Math.max(0, Math.ceil(n / 10) - 1);
|
|
785
|
+
return 0;
|
|
786
|
+
}, [salesGranularity, salesBreakdownChartRows.length]);
|
|
719
787
|
const ordersVsDraftsPie = useMemo(() => {
|
|
720
788
|
var _a2;
|
|
721
789
|
if (!ordersInsights) return [];
|
|
@@ -752,10 +820,6 @@ function OrdersDashboard() {
|
|
|
752
820
|
};
|
|
753
821
|
});
|
|
754
822
|
}, [dailyOrders]);
|
|
755
|
-
const trafficTotalRevenue = useMemo(
|
|
756
|
-
() => (ordersInsights == null ? void 0 : ordersInsights.traffic.reduce((sum, t) => sum + (t.revenue || 0), 0)) ?? 0,
|
|
757
|
-
[ordersInsights]
|
|
758
|
-
);
|
|
759
823
|
const quickPulseMetrics = [
|
|
760
824
|
{
|
|
761
825
|
label: "Range revenue",
|
|
@@ -796,6 +860,84 @@ function OrdersDashboard() {
|
|
|
796
860
|
if (error || !data) {
|
|
797
861
|
return /* @__PURE__ */ jsx(Container, { className: "p-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger", children: error ?? "Failed to load analytics" }) });
|
|
798
862
|
}
|
|
863
|
+
const needsSalesOverTime = salesGranularity === "day" || salesGranularity === "month";
|
|
864
|
+
const needsSalesInsights = salesGranularity === "hour" || salesGranularity === "week";
|
|
865
|
+
const salesBreakdownBody = (() => {
|
|
866
|
+
if (needsSalesOverTime && overTimeLoading) {
|
|
867
|
+
return /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[min(176px,28vh)] items-center justify-center py-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading chart…" }) }) });
|
|
868
|
+
}
|
|
869
|
+
if (needsSalesOverTime && overTimeError) {
|
|
870
|
+
return /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[min(176px,28vh)] items-center justify-center px-2 py-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-center text-xs", children: overTimeError }) }) });
|
|
871
|
+
}
|
|
872
|
+
if (needsSalesInsights && insightsLoading) {
|
|
873
|
+
return /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[min(176px,28vh)] items-center justify-center py-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading chart…" }) }) });
|
|
874
|
+
}
|
|
875
|
+
if (needsSalesInsights && insightsError) {
|
|
876
|
+
return /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[min(176px,28vh)] items-center justify-center px-2 py-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-center text-xs", children: insightsError }) }) });
|
|
877
|
+
}
|
|
878
|
+
if (salesBreakdownChartRows.length === 0) {
|
|
879
|
+
return /* @__PURE__ */ jsx(
|
|
880
|
+
EmptyAnalyticsPanel$1,
|
|
881
|
+
{
|
|
882
|
+
title: "No sales data",
|
|
883
|
+
description: "Nothing to show for this view and range."
|
|
884
|
+
}
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
return /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "h-[min(200px,30vh)] min-h-[160px] w-full sm:h-[min(220px,32vh)]", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
888
|
+
BarChart,
|
|
889
|
+
{
|
|
890
|
+
data: salesBreakdownChartRows,
|
|
891
|
+
margin: { top: 4, right: 8, left: 4, bottom: 4 },
|
|
892
|
+
children: [
|
|
893
|
+
/* @__PURE__ */ jsx(
|
|
894
|
+
CartesianGrid,
|
|
895
|
+
{
|
|
896
|
+
strokeDasharray: "3 3",
|
|
897
|
+
vertical: false,
|
|
898
|
+
stroke: "rgba(148,163,184,0.12)"
|
|
899
|
+
}
|
|
900
|
+
),
|
|
901
|
+
/* @__PURE__ */ jsx(
|
|
902
|
+
XAxis,
|
|
903
|
+
{
|
|
904
|
+
dataKey: "label",
|
|
905
|
+
tick: CHART_AXIS_TICK_SM$1,
|
|
906
|
+
tickLine: false,
|
|
907
|
+
axisLine: false,
|
|
908
|
+
interval: salesBreakdownXAxisInterval
|
|
909
|
+
}
|
|
910
|
+
),
|
|
911
|
+
/* @__PURE__ */ jsx(
|
|
912
|
+
YAxis,
|
|
913
|
+
{
|
|
914
|
+
width: 44,
|
|
915
|
+
tick: CHART_AXIS_TICK_SM$1,
|
|
916
|
+
tickLine: false,
|
|
917
|
+
axisLine: false,
|
|
918
|
+
tickFormatter: (v) => formatCompactCurrency$1(Number(v))
|
|
919
|
+
}
|
|
920
|
+
),
|
|
921
|
+
/* @__PURE__ */ jsx(
|
|
922
|
+
Tooltip,
|
|
923
|
+
{
|
|
924
|
+
content: /* @__PURE__ */ jsx(SalesBreakdownTooltip, {}),
|
|
925
|
+
cursor: { fill: "rgba(148,163,184,0.08)" }
|
|
926
|
+
}
|
|
927
|
+
),
|
|
928
|
+
/* @__PURE__ */ jsx(
|
|
929
|
+
Bar,
|
|
930
|
+
{
|
|
931
|
+
dataKey: "revenue",
|
|
932
|
+
name: "Revenue",
|
|
933
|
+
fill: "#D946EF",
|
|
934
|
+
radius: [6, 6, 0, 0]
|
|
935
|
+
}
|
|
936
|
+
)
|
|
937
|
+
]
|
|
938
|
+
}
|
|
939
|
+
) }) }) });
|
|
940
|
+
})();
|
|
799
941
|
return /* @__PURE__ */ jsx(AnalyticsDashboardShell, { children: /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-2xl border border-ui-border-base/80 bg-ui-bg-base shadow-sm", children: [
|
|
800
942
|
/* @__PURE__ */ jsx(
|
|
801
943
|
AnalyticsDashboardHeader,
|
|
@@ -910,397 +1052,197 @@ function OrdersDashboard() {
|
|
|
910
1052
|
] }) })
|
|
911
1053
|
] }),
|
|
912
1054
|
!overTimeLoading && !overTimeError && dailyOrders.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
913
|
-
/* @__PURE__ */ jsxs(
|
|
914
|
-
/* @__PURE__ */ jsxs(
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
var _a2, _b2, _c2, _d;
|
|
944
|
-
return active && (payload == null ? void 0 : payload.length) ? /* @__PURE__ */ jsxs(
|
|
945
|
-
AnalyticsTooltipCard,
|
|
946
|
-
{
|
|
947
|
-
variant: "compact",
|
|
948
|
-
title: String(
|
|
949
|
-
isDailyOrderRow((_a2 = payload[0]) == null ? void 0 : _a2.payload) ? ((_b2 = payload[0]) == null ? void 0 : _b2.payload.label) ?? formatChartLabel$2(String(label)) : label
|
|
950
|
-
),
|
|
951
|
-
children: [
|
|
952
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
953
|
-
"This:",
|
|
954
|
-
" ",
|
|
955
|
-
/* @__PURE__ */ jsx("strong", { children: formatCompactCurrency$1(
|
|
956
|
-
Number(
|
|
957
|
-
(_c2 = payload.find((p) => p.dataKey === "total_revenue")) == null ? void 0 : _c2.value
|
|
958
|
-
) || 0
|
|
959
|
-
) })
|
|
960
|
-
] }),
|
|
961
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
962
|
-
"Previous:",
|
|
963
|
-
" ",
|
|
964
|
-
/* @__PURE__ */ jsx("strong", { children: formatCompactCurrency$1(
|
|
965
|
-
Number(
|
|
966
|
-
(_d = payload.find((p) => p.dataKey === "prev_revenue")) == null ? void 0 : _d.value
|
|
967
|
-
) || 0
|
|
968
|
-
) })
|
|
969
|
-
] })
|
|
970
|
-
]
|
|
971
|
-
}
|
|
972
|
-
) : null;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
),
|
|
976
|
-
/* @__PURE__ */ jsx(
|
|
977
|
-
Line,
|
|
978
|
-
{
|
|
979
|
-
type: "natural",
|
|
980
|
-
dataKey: "total_revenue",
|
|
981
|
-
name: "This period",
|
|
982
|
-
stroke: "#D946EF",
|
|
983
|
-
strokeWidth: 2,
|
|
984
|
-
dot: false
|
|
985
|
-
}
|
|
986
|
-
),
|
|
987
|
-
/* @__PURE__ */ jsx(
|
|
988
|
-
Line,
|
|
989
|
-
{
|
|
990
|
-
type: "natural",
|
|
991
|
-
dataKey: "prev_revenue",
|
|
992
|
-
name: "Previous",
|
|
993
|
-
stroke: "#94a3b8",
|
|
994
|
-
strokeWidth: 1.5,
|
|
995
|
-
strokeDasharray: "5 4",
|
|
996
|
-
dot: false
|
|
997
|
-
}
|
|
998
|
-
)
|
|
999
|
-
]
|
|
1000
|
-
}
|
|
1001
|
-
) }) })
|
|
1002
|
-
] }),
|
|
1003
|
-
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
1004
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Orders count" }),
|
|
1005
|
-
/* @__PURE__ */ jsx("div", { className: "h-[118px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1006
|
-
LineChart,
|
|
1007
|
-
{
|
|
1008
|
-
data: trendRowsDetailed,
|
|
1009
|
-
margin: { top: 4, right: 4, left: 0, bottom: 0 },
|
|
1010
|
-
children: [
|
|
1011
|
-
/* @__PURE__ */ jsx(
|
|
1012
|
-
CartesianGrid,
|
|
1013
|
-
{
|
|
1014
|
-
strokeDasharray: "3 3",
|
|
1015
|
-
vertical: false,
|
|
1016
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
1017
|
-
}
|
|
1018
|
-
),
|
|
1019
|
-
/* @__PURE__ */ jsx(XAxis, { dataKey: "date", hide: true }),
|
|
1020
|
-
/* @__PURE__ */ jsx(
|
|
1021
|
-
YAxis,
|
|
1022
|
-
{
|
|
1023
|
-
width: 28,
|
|
1024
|
-
tick: CHART_AXIS_TICK_SM$1,
|
|
1025
|
-
allowDecimals: false
|
|
1026
|
-
}
|
|
1027
|
-
),
|
|
1028
|
-
/* @__PURE__ */ jsx(
|
|
1029
|
-
Tooltip,
|
|
1030
|
-
{
|
|
1031
|
-
content: ({ active, payload, label }) => {
|
|
1032
|
-
var _a2, _b2;
|
|
1033
|
-
return active && (payload == null ? void 0 : payload.length) ? /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { variant: "compact", title: String(label), children: [
|
|
1034
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1035
|
-
"This:",
|
|
1036
|
-
" ",
|
|
1037
|
-
/* @__PURE__ */ jsx("strong", { children: Math.floor(
|
|
1038
|
-
Number(
|
|
1039
|
-
(_a2 = payload.find((p) => p.dataKey === "orders_count")) == null ? void 0 : _a2.value
|
|
1040
|
-
) || 0
|
|
1041
|
-
).toLocaleString() })
|
|
1042
|
-
] }),
|
|
1043
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1044
|
-
"Previous:",
|
|
1045
|
-
" ",
|
|
1046
|
-
/* @__PURE__ */ jsx("strong", { children: Math.floor(
|
|
1047
|
-
Number(
|
|
1048
|
-
(_b2 = payload.find((p) => p.dataKey === "prev_orders")) == null ? void 0 : _b2.value
|
|
1049
|
-
) || 0
|
|
1050
|
-
).toLocaleString() })
|
|
1051
|
-
] })
|
|
1052
|
-
] }) : null;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
),
|
|
1056
|
-
/* @__PURE__ */ jsx(
|
|
1057
|
-
Line,
|
|
1058
|
-
{
|
|
1059
|
-
type: "natural",
|
|
1060
|
-
dataKey: "orders_count",
|
|
1061
|
-
name: "This period",
|
|
1062
|
-
stroke: "#38BDF8",
|
|
1063
|
-
strokeWidth: 2,
|
|
1064
|
-
dot: false
|
|
1065
|
-
}
|
|
1066
|
-
),
|
|
1067
|
-
/* @__PURE__ */ jsx(
|
|
1068
|
-
Line,
|
|
1069
|
-
{
|
|
1070
|
-
type: "natural",
|
|
1071
|
-
dataKey: "prev_orders",
|
|
1072
|
-
name: "Previous",
|
|
1073
|
-
stroke: "#94a3b8",
|
|
1074
|
-
strokeWidth: 1.5,
|
|
1075
|
-
strokeDasharray: "5 4",
|
|
1076
|
-
dot: false
|
|
1077
|
-
}
|
|
1078
|
-
)
|
|
1079
|
-
]
|
|
1080
|
-
}
|
|
1081
|
-
) }) })
|
|
1055
|
+
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
1056
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-1 flex flex-col gap-0.5 sm:flex-row sm:items-start sm:justify-between", children: [
|
|
1057
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1058
|
+
/* @__PURE__ */ jsx(Text, { className: "text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Revenue, orders & AOV" }),
|
|
1059
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-[9px] leading-snug", children: "One timeline · solid = this range, dashed = previous period (same length)" })
|
|
1060
|
+
] }),
|
|
1061
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-x-3 gap-y-0.5 text-[9px] text-ui-fg-muted sm:justify-end", children: [
|
|
1062
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
1063
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full bg-fuchsia-500" }),
|
|
1064
|
+
"Revenue"
|
|
1065
|
+
] }),
|
|
1066
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
1067
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full bg-sky-400" }),
|
|
1068
|
+
"Orders"
|
|
1069
|
+
] }),
|
|
1070
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
1071
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full bg-amber-500" }),
|
|
1072
|
+
"AOV"
|
|
1073
|
+
] }),
|
|
1074
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
1075
|
+
/* @__PURE__ */ jsx(
|
|
1076
|
+
"span",
|
|
1077
|
+
{
|
|
1078
|
+
className: "h-0 w-4 shrink-0 border-t border-dashed border-slate-400",
|
|
1079
|
+
"aria-hidden": true
|
|
1080
|
+
}
|
|
1081
|
+
),
|
|
1082
|
+
"Previous"
|
|
1083
|
+
] })
|
|
1084
|
+
] })
|
|
1082
1085
|
] }),
|
|
1083
|
-
/* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "AOV (non-cancelled)" }),
|
|
1085
|
-
/* @__PURE__ */ jsx("div", { className: "h-[118px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1086
|
-
LineChart,
|
|
1087
|
-
{
|
|
1088
|
-
data: trendRowsDetailed,
|
|
1089
|
-
margin: { top: 4, right: 4, left: 0, bottom: 0 },
|
|
1090
|
-
children: [
|
|
1091
|
-
/* @__PURE__ */ jsx(
|
|
1092
|
-
CartesianGrid,
|
|
1093
|
-
{
|
|
1094
|
-
strokeDasharray: "3 3",
|
|
1095
|
-
vertical: false,
|
|
1096
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
1097
|
-
}
|
|
1098
|
-
),
|
|
1099
|
-
/* @__PURE__ */ jsx(XAxis, { dataKey: "date", hide: true }),
|
|
1100
|
-
/* @__PURE__ */ jsx(
|
|
1101
|
-
YAxis,
|
|
1102
|
-
{
|
|
1103
|
-
width: 36,
|
|
1104
|
-
tick: CHART_AXIS_TICK_SM$1,
|
|
1105
|
-
tickFormatter: (v) => formatCompactCurrency$1(Number(v))
|
|
1106
|
-
}
|
|
1107
|
-
),
|
|
1108
|
-
/* @__PURE__ */ jsx(
|
|
1109
|
-
Tooltip,
|
|
1110
|
-
{
|
|
1111
|
-
content: ({ active, payload, label }) => {
|
|
1112
|
-
var _a2, _b2;
|
|
1113
|
-
return active && (payload == null ? void 0 : payload.length) ? /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { variant: "compact", title: String(label), children: [
|
|
1114
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1115
|
-
"This:",
|
|
1116
|
-
" ",
|
|
1117
|
-
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(
|
|
1118
|
-
Number(
|
|
1119
|
-
(_a2 = payload.find((p) => p.dataKey === "aov")) == null ? void 0 : _a2.value
|
|
1120
|
-
) || 0
|
|
1121
|
-
) })
|
|
1122
|
-
] }),
|
|
1123
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1124
|
-
"Previous:",
|
|
1125
|
-
" ",
|
|
1126
|
-
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(
|
|
1127
|
-
Number(
|
|
1128
|
-
(_b2 = payload.find((p) => p.dataKey === "prev_aov")) == null ? void 0 : _b2.value
|
|
1129
|
-
) || 0
|
|
1130
|
-
) })
|
|
1131
|
-
] })
|
|
1132
|
-
] }) : null;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
),
|
|
1136
|
-
/* @__PURE__ */ jsx(
|
|
1137
|
-
Line,
|
|
1138
|
-
{
|
|
1139
|
-
type: "natural",
|
|
1140
|
-
dataKey: "aov",
|
|
1141
|
-
name: "This period",
|
|
1142
|
-
stroke: "#D97706",
|
|
1143
|
-
strokeWidth: 2,
|
|
1144
|
-
dot: false
|
|
1145
|
-
}
|
|
1146
|
-
),
|
|
1147
|
-
/* @__PURE__ */ jsx(
|
|
1148
|
-
Line,
|
|
1149
|
-
{
|
|
1150
|
-
type: "natural",
|
|
1151
|
-
dataKey: "prev_aov",
|
|
1152
|
-
name: "Previous",
|
|
1153
|
-
stroke: "#94a3b8",
|
|
1154
|
-
strokeWidth: 1.5,
|
|
1155
|
-
strokeDasharray: "5 4",
|
|
1156
|
-
dot: false
|
|
1157
|
-
}
|
|
1158
|
-
)
|
|
1159
|
-
]
|
|
1160
|
-
}
|
|
1161
|
-
) }) })
|
|
1162
|
-
] })
|
|
1163
|
-
] }),
|
|
1164
|
-
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", className: "mt-1.5", children: [
|
|
1165
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Revenue breakdown (stacked — by order status)" }),
|
|
1166
|
-
/* @__PURE__ */ jsx("div", { className: "h-[min(168px,26vh)] min-h-[140px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1086
|
+
/* @__PURE__ */ jsx("div", { className: "h-[min(220px,32vh)] min-h-[156px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1167
1087
|
ComposedChart,
|
|
1168
1088
|
{
|
|
1169
|
-
data:
|
|
1170
|
-
margin: { top:
|
|
1089
|
+
data: trendRowsDetailed,
|
|
1090
|
+
margin: { top: 6, right: 8, left: 2, bottom: 4 },
|
|
1171
1091
|
children: [
|
|
1172
1092
|
/* @__PURE__ */ jsx(
|
|
1173
1093
|
CartesianGrid,
|
|
1174
1094
|
{
|
|
1175
|
-
stroke: "rgba(148,163,184,0.14)",
|
|
1176
1095
|
strokeDasharray: "3 3",
|
|
1177
|
-
vertical: false
|
|
1096
|
+
vertical: false,
|
|
1097
|
+
stroke: "rgba(148,163,184,0.12)"
|
|
1178
1098
|
}
|
|
1179
1099
|
),
|
|
1180
1100
|
/* @__PURE__ */ jsx(
|
|
1181
1101
|
XAxis,
|
|
1182
1102
|
{
|
|
1183
1103
|
dataKey: "date",
|
|
1184
|
-
tick:
|
|
1104
|
+
tick: CHART_AXIS_TICK_SM$1,
|
|
1185
1105
|
tickLine: false,
|
|
1186
1106
|
axisLine: false,
|
|
1187
1107
|
tickFormatter: (value, index) => {
|
|
1188
|
-
const row =
|
|
1189
|
-
return (row == null ? void 0 : row.label) ?? formatChartLabel$2(value);
|
|
1108
|
+
const row = trendRowsDetailed[index];
|
|
1109
|
+
return (row == null ? void 0 : row.label) ?? formatChartLabel$2(String(value));
|
|
1190
1110
|
}
|
|
1191
1111
|
}
|
|
1192
1112
|
),
|
|
1193
1113
|
/* @__PURE__ */ jsx(
|
|
1194
1114
|
YAxis,
|
|
1195
1115
|
{
|
|
1196
|
-
|
|
1116
|
+
yAxisId: "orders",
|
|
1117
|
+
width: 30,
|
|
1118
|
+
tick: CHART_AXIS_TICK_SM$1,
|
|
1119
|
+
tickLine: false,
|
|
1120
|
+
axisLine: false,
|
|
1121
|
+
allowDecimals: false,
|
|
1122
|
+
tickFormatter: (v) => Math.floor(Number(v) || 0).toLocaleString()
|
|
1123
|
+
}
|
|
1124
|
+
),
|
|
1125
|
+
/* @__PURE__ */ jsx(
|
|
1126
|
+
YAxis,
|
|
1127
|
+
{
|
|
1128
|
+
yAxisId: "revenue",
|
|
1129
|
+
orientation: "right",
|
|
1130
|
+
width: 42,
|
|
1131
|
+
tick: CHART_AXIS_TICK_SM$1,
|
|
1132
|
+
tickLine: false,
|
|
1133
|
+
axisLine: false,
|
|
1134
|
+
tickFormatter: (v) => formatCompactCurrency$1(Number(v))
|
|
1135
|
+
}
|
|
1136
|
+
),
|
|
1137
|
+
/* @__PURE__ */ jsx(
|
|
1138
|
+
YAxis,
|
|
1139
|
+
{
|
|
1140
|
+
yAxisId: "aov",
|
|
1141
|
+
orientation: "right",
|
|
1142
|
+
width: 40,
|
|
1143
|
+
tick: CHART_AXIS_TICK_SM$1,
|
|
1144
|
+
tickLine: false,
|
|
1145
|
+
axisLine: false,
|
|
1197
1146
|
tickFormatter: (v) => formatCompactCurrency$1(Number(v))
|
|
1198
1147
|
}
|
|
1199
1148
|
),
|
|
1200
1149
|
/* @__PURE__ */ jsx(
|
|
1201
1150
|
Tooltip,
|
|
1202
1151
|
{
|
|
1203
|
-
content:
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
] }, String(p.name))) }) : null
|
|
1152
|
+
content: /* @__PURE__ */ jsx(CombinedMetricsTooltip, {}),
|
|
1153
|
+
cursor: {
|
|
1154
|
+
stroke: "rgba(248, 250, 252, 0.35)",
|
|
1155
|
+
strokeWidth: 1
|
|
1156
|
+
}
|
|
1209
1157
|
}
|
|
1210
1158
|
),
|
|
1211
|
-
/* @__PURE__ */ jsx(Legend, { wrapperStyle: { fontSize: 10 }, iconType: "circle" }),
|
|
1212
1159
|
/* @__PURE__ */ jsx(
|
|
1213
|
-
|
|
1160
|
+
Line,
|
|
1214
1161
|
{
|
|
1162
|
+
yAxisId: "orders",
|
|
1215
1163
|
type: "natural",
|
|
1216
|
-
dataKey: "
|
|
1217
|
-
name: "
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
fillOpacity: 0.85
|
|
1164
|
+
dataKey: "orders_count",
|
|
1165
|
+
name: "Orders",
|
|
1166
|
+
stroke: "#38BDF8",
|
|
1167
|
+
strokeWidth: 2,
|
|
1168
|
+
dot: false
|
|
1222
1169
|
}
|
|
1223
1170
|
),
|
|
1224
1171
|
/* @__PURE__ */ jsx(
|
|
1225
|
-
|
|
1172
|
+
Line,
|
|
1226
1173
|
{
|
|
1174
|
+
yAxisId: "orders",
|
|
1227
1175
|
type: "natural",
|
|
1228
|
-
dataKey: "
|
|
1229
|
-
name: "
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1176
|
+
dataKey: "prev_orders",
|
|
1177
|
+
name: "Orders (prev)",
|
|
1178
|
+
stroke: "#64748b",
|
|
1179
|
+
strokeWidth: 1.5,
|
|
1180
|
+
strokeDasharray: "5 4",
|
|
1181
|
+
dot: false
|
|
1234
1182
|
}
|
|
1235
1183
|
),
|
|
1236
1184
|
/* @__PURE__ */ jsx(
|
|
1237
|
-
|
|
1185
|
+
Line,
|
|
1238
1186
|
{
|
|
1187
|
+
yAxisId: "revenue",
|
|
1239
1188
|
type: "natural",
|
|
1240
|
-
dataKey: "
|
|
1241
|
-
name: "
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1189
|
+
dataKey: "total_revenue",
|
|
1190
|
+
name: "Revenue",
|
|
1191
|
+
stroke: "#D946EF",
|
|
1192
|
+
strokeWidth: 2,
|
|
1193
|
+
dot: false
|
|
1194
|
+
}
|
|
1195
|
+
),
|
|
1196
|
+
/* @__PURE__ */ jsx(
|
|
1197
|
+
Line,
|
|
1198
|
+
{
|
|
1199
|
+
yAxisId: "revenue",
|
|
1200
|
+
type: "natural",
|
|
1201
|
+
dataKey: "prev_revenue",
|
|
1202
|
+
name: "Revenue (prev)",
|
|
1203
|
+
stroke: "#64748b",
|
|
1204
|
+
strokeWidth: 1.5,
|
|
1205
|
+
strokeDasharray: "5 4",
|
|
1206
|
+
dot: false
|
|
1207
|
+
}
|
|
1208
|
+
),
|
|
1209
|
+
/* @__PURE__ */ jsx(
|
|
1210
|
+
Line,
|
|
1211
|
+
{
|
|
1212
|
+
yAxisId: "aov",
|
|
1213
|
+
type: "natural",
|
|
1214
|
+
dataKey: "aov",
|
|
1215
|
+
name: "AOV",
|
|
1216
|
+
stroke: "#D97706",
|
|
1217
|
+
strokeWidth: 2,
|
|
1218
|
+
dot: false
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
/* @__PURE__ */ jsx(
|
|
1222
|
+
Line,
|
|
1223
|
+
{
|
|
1224
|
+
yAxisId: "aov",
|
|
1225
|
+
type: "natural",
|
|
1226
|
+
dataKey: "prev_aov",
|
|
1227
|
+
name: "AOV (prev)",
|
|
1228
|
+
stroke: "#64748b",
|
|
1229
|
+
strokeWidth: 1.5,
|
|
1230
|
+
strokeDasharray: "5 4",
|
|
1231
|
+
dot: false
|
|
1246
1232
|
}
|
|
1247
1233
|
)
|
|
1248
1234
|
]
|
|
1249
1235
|
}
|
|
1250
1236
|
) }) })
|
|
1251
|
-
] })
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
/* @__PURE__ */ jsxs("div", { className: "relative space-y-1", children: [
|
|
1256
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-1.5", children: [
|
|
1257
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-0", children: [
|
|
1258
|
-
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-[10px] font-medium uppercase tracking-[0.16em]", children: "Trend overview" }),
|
|
1259
|
-
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-base text-sm font-semibold", children: ((_b = OVER_TIME_PERIODS.find((period) => period.value === overTimePeriod)) == null ? void 0 : _b.label) ?? "One week" })
|
|
1260
|
-
] }),
|
|
1261
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2 text-[10px] text-ui-fg-muted", children: [
|
|
1262
|
-
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
1263
|
-
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-sky-400" }),
|
|
1264
|
-
"Orders"
|
|
1265
|
-
] }),
|
|
1266
|
-
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
1267
|
-
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-fuchsia-400" }),
|
|
1268
|
-
"Revenue"
|
|
1269
|
-
] })
|
|
1270
|
-
] })
|
|
1271
|
-
] }),
|
|
1272
|
-
/* @__PURE__ */ jsx("div", { className: "h-[min(200px,30vh)] min-h-[160px] sm:h-[min(216px,32vh)]", children: overTimeLoading ? /* @__PURE__ */ jsx(
|
|
1273
|
-
"div",
|
|
1274
|
-
{
|
|
1275
|
-
className: "flex h-full items-center justify-center",
|
|
1276
|
-
role: "status",
|
|
1277
|
-
"aria-label": "Loading orders over time",
|
|
1278
|
-
children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading chart…" })
|
|
1279
|
-
}
|
|
1280
|
-
) : overTimeError ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-xs", children: overTimeError }) }) : /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1237
|
+
] }),
|
|
1238
|
+
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", className: "mt-1.5", children: [
|
|
1239
|
+
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Revenue breakdown (stacked — by order status)" }),
|
|
1240
|
+
/* @__PURE__ */ jsx("div", { className: "h-[min(168px,26vh)] min-h-[140px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1281
1241
|
ComposedChart,
|
|
1282
1242
|
{
|
|
1283
1243
|
data: dailyOrders,
|
|
1284
|
-
margin: { top: 4, right:
|
|
1244
|
+
margin: { top: 4, right: 8, left: -4, bottom: 0 },
|
|
1285
1245
|
children: [
|
|
1286
|
-
/* @__PURE__ */ jsxs("defs", { children: [
|
|
1287
|
-
/* @__PURE__ */ jsxs("linearGradient", { id: "ordersGradient", x1: "0", y1: "0", x2: "1", y2: "0", children: [
|
|
1288
|
-
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "#67E8F9" }),
|
|
1289
|
-
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "#3B82F6" })
|
|
1290
|
-
] }),
|
|
1291
|
-
/* @__PURE__ */ jsxs("linearGradient", { id: "revenueGradient", x1: "0", y1: "0", x2: "1", y2: "0", children: [
|
|
1292
|
-
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "#F472B6" }),
|
|
1293
|
-
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "#C084FC" })
|
|
1294
|
-
] }),
|
|
1295
|
-
/* @__PURE__ */ jsxs("linearGradient", { id: "ordersAreaFill", x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
1296
|
-
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "#38BDF8", stopOpacity: 0.22 }),
|
|
1297
|
-
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "#38BDF8", stopOpacity: 0 })
|
|
1298
|
-
] }),
|
|
1299
|
-
/* @__PURE__ */ jsxs("linearGradient", { id: "revenueAreaFill", x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
1300
|
-
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "#E879F9", stopOpacity: 0.2 }),
|
|
1301
|
-
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "#E879F9", stopOpacity: 0 })
|
|
1302
|
-
] })
|
|
1303
|
-
] }),
|
|
1304
1246
|
/* @__PURE__ */ jsx(
|
|
1305
1247
|
CartesianGrid,
|
|
1306
1248
|
{
|
|
@@ -1325,156 +1267,85 @@ function OrdersDashboard() {
|
|
|
1325
1267
|
/* @__PURE__ */ jsx(
|
|
1326
1268
|
YAxis,
|
|
1327
1269
|
{
|
|
1328
|
-
yAxisId: "orders",
|
|
1329
|
-
width: 32,
|
|
1330
|
-
tick: CHART_AXIS_TICK$2,
|
|
1331
|
-
tickLine: false,
|
|
1332
|
-
axisLine: false,
|
|
1333
|
-
allowDecimals: false,
|
|
1334
|
-
tickFormatter: (value) => Math.floor(Number(value) || 0).toLocaleString()
|
|
1335
|
-
}
|
|
1336
|
-
),
|
|
1337
|
-
/* @__PURE__ */ jsx(
|
|
1338
|
-
YAxis,
|
|
1339
|
-
{
|
|
1340
|
-
yAxisId: "revenue",
|
|
1341
|
-
orientation: "right",
|
|
1342
|
-
width: 40,
|
|
1343
1270
|
tick: CHART_AXIS_TICK$2,
|
|
1344
|
-
|
|
1345
|
-
axisLine: false,
|
|
1346
|
-
tickFormatter: (value) => formatCompactCurrency$1(Number(value) || 0)
|
|
1271
|
+
tickFormatter: (v) => formatCompactCurrency$1(Number(v))
|
|
1347
1272
|
}
|
|
1348
1273
|
),
|
|
1349
1274
|
/* @__PURE__ */ jsx(
|
|
1350
1275
|
Tooltip,
|
|
1351
1276
|
{
|
|
1352
|
-
content: /* @__PURE__ */ jsx(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1277
|
+
content: ({ active, payload, label }) => active && (payload == null ? void 0 : payload.length) ? /* @__PURE__ */ jsx(AnalyticsTooltipCard, { variant: "compact", title: String(label), children: payload.map((p) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1278
|
+
p.name,
|
|
1279
|
+
":",
|
|
1280
|
+
" ",
|
|
1281
|
+
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(Number(p.value) || 0) })
|
|
1282
|
+
] }, String(p.name))) }) : null
|
|
1357
1283
|
}
|
|
1358
1284
|
),
|
|
1285
|
+
/* @__PURE__ */ jsx(Legend, { wrapperStyle: { fontSize: 10 }, iconType: "circle" }),
|
|
1359
1286
|
/* @__PURE__ */ jsx(
|
|
1360
1287
|
Area,
|
|
1361
1288
|
{
|
|
1362
|
-
yAxisId: "orders",
|
|
1363
1289
|
type: "natural",
|
|
1364
|
-
dataKey: "
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1290
|
+
dataKey: "revenue_delivered",
|
|
1291
|
+
name: "Delivered",
|
|
1292
|
+
stackId: "r",
|
|
1293
|
+
fill: "#10B981",
|
|
1294
|
+
stroke: "#059669",
|
|
1295
|
+
fillOpacity: 0.85
|
|
1369
1296
|
}
|
|
1370
1297
|
),
|
|
1371
1298
|
/* @__PURE__ */ jsx(
|
|
1372
1299
|
Area,
|
|
1373
1300
|
{
|
|
1374
|
-
yAxisId: "revenue",
|
|
1375
|
-
type: "natural",
|
|
1376
|
-
dataKey: "total_revenue",
|
|
1377
|
-
stroke: "none",
|
|
1378
|
-
fill: "url(#revenueAreaFill)",
|
|
1379
|
-
isAnimationActive: false,
|
|
1380
|
-
legendType: "none"
|
|
1381
|
-
}
|
|
1382
|
-
),
|
|
1383
|
-
/* @__PURE__ */ jsx(
|
|
1384
|
-
Line,
|
|
1385
|
-
{
|
|
1386
|
-
yAxisId: "orders",
|
|
1387
1301
|
type: "natural",
|
|
1388
|
-
dataKey: "
|
|
1389
|
-
name: "
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1302
|
+
dataKey: "revenue_open",
|
|
1303
|
+
name: "Open / pending",
|
|
1304
|
+
stackId: "r",
|
|
1305
|
+
fill: "#3B82F6",
|
|
1306
|
+
stroke: "#2563eb",
|
|
1307
|
+
fillOpacity: 0.85
|
|
1394
1308
|
}
|
|
1395
1309
|
),
|
|
1396
1310
|
/* @__PURE__ */ jsx(
|
|
1397
|
-
|
|
1311
|
+
Area,
|
|
1398
1312
|
{
|
|
1399
|
-
yAxisId: "revenue",
|
|
1400
1313
|
type: "natural",
|
|
1401
|
-
dataKey: "
|
|
1402
|
-
name: "
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1314
|
+
dataKey: "revenue_cancelled",
|
|
1315
|
+
name: "Cancelled",
|
|
1316
|
+
stackId: "r",
|
|
1317
|
+
fill: "#F87171",
|
|
1318
|
+
stroke: "#EF4444",
|
|
1319
|
+
fillOpacity: 0.75
|
|
1407
1320
|
}
|
|
1408
1321
|
)
|
|
1409
1322
|
]
|
|
1410
1323
|
}
|
|
1411
1324
|
) }) })
|
|
1412
1325
|
] })
|
|
1413
|
-
] })
|
|
1326
|
+
] }) : null
|
|
1414
1327
|
] })
|
|
1415
1328
|
}
|
|
1416
1329
|
) }),
|
|
1417
1330
|
/* @__PURE__ */ jsxs("div", { className: "col-span-12 flex flex-col gap-2 xl:col-span-6", children: [
|
|
1418
|
-
/* @__PURE__ */
|
|
1331
|
+
/* @__PURE__ */ jsx(
|
|
1419
1332
|
AnalyticsSection,
|
|
1420
1333
|
{
|
|
1421
1334
|
variant: "atlas",
|
|
1422
1335
|
title: "Pulse & range",
|
|
1423
|
-
description: "Window totals
|
|
1424
|
-
children:
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
{
|
|
1428
|
-
|
|
1429
|
-
children:
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
)) }),
|
|
1437
|
-
!overTimeLoading && !overTimeError && dailyOrders.length > 0 ? /* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", className: "mt-1.5", children: [
|
|
1438
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Orders (time series)" }),
|
|
1439
|
-
/* @__PURE__ */ jsx("div", { className: "h-[76px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
1440
|
-
LineChart,
|
|
1441
|
-
{
|
|
1442
|
-
data: dailyOrders,
|
|
1443
|
-
margin: { top: 2, right: 4, left: -18, bottom: 2 },
|
|
1444
|
-
children: [
|
|
1445
|
-
/* @__PURE__ */ jsx(
|
|
1446
|
-
CartesianGrid,
|
|
1447
|
-
{
|
|
1448
|
-
strokeDasharray: "3 3",
|
|
1449
|
-
vertical: false,
|
|
1450
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
1451
|
-
}
|
|
1452
|
-
),
|
|
1453
|
-
/* @__PURE__ */ jsx(XAxis, { dataKey: "date", hide: true }),
|
|
1454
|
-
/* @__PURE__ */ jsx(YAxis, { hide: true, domain: ["auto", "auto"] }),
|
|
1455
|
-
/* @__PURE__ */ jsx(
|
|
1456
|
-
Tooltip,
|
|
1457
|
-
{
|
|
1458
|
-
content: /* @__PURE__ */ jsx(OrdersSparklineTooltip, {}),
|
|
1459
|
-
cursor: { stroke: "rgba(148,163,184,0.35)", strokeWidth: 1 }
|
|
1460
|
-
}
|
|
1461
|
-
),
|
|
1462
|
-
/* @__PURE__ */ jsx(
|
|
1463
|
-
Line,
|
|
1464
|
-
{
|
|
1465
|
-
type: "natural",
|
|
1466
|
-
dataKey: "orders_count",
|
|
1467
|
-
stroke: "#3b82f6",
|
|
1468
|
-
strokeWidth: 2,
|
|
1469
|
-
dot: { r: 2, fill: "#3b82f6" },
|
|
1470
|
-
activeDot: { r: 3 }
|
|
1471
|
-
}
|
|
1472
|
-
)
|
|
1473
|
-
]
|
|
1474
|
-
}
|
|
1475
|
-
) }) })
|
|
1476
|
-
] }) : null
|
|
1477
|
-
]
|
|
1336
|
+
description: "Window totals for the selected range.",
|
|
1337
|
+
children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: quickPulseMetrics.map((metric) => /* @__PURE__ */ jsxs(
|
|
1338
|
+
"div",
|
|
1339
|
+
{
|
|
1340
|
+
className: `rounded-lg border border-ui-border-base bg-ui-bg-base px-2 py-2 shadow-sm ${metric.accentClassName}`.trim(),
|
|
1341
|
+
children: [
|
|
1342
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-[10px] font-medium uppercase tracking-[0.14em]", children: metric.label }),
|
|
1343
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-base mt-0.5 text-sm font-semibold tracking-tight", children: metric.value }),
|
|
1344
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted mt-0.5 text-[9px] leading-snug", children: metric.helper })
|
|
1345
|
+
]
|
|
1346
|
+
},
|
|
1347
|
+
metric.label
|
|
1348
|
+
)) })
|
|
1478
1349
|
}
|
|
1479
1350
|
),
|
|
1480
1351
|
/* @__PURE__ */ jsx(
|
|
@@ -1482,7 +1353,7 @@ function OrdersDashboard() {
|
|
|
1482
1353
|
{
|
|
1483
1354
|
variant: "atlas",
|
|
1484
1355
|
title: "Order → fulfillment funnel",
|
|
1485
|
-
description: `Stages by order created date (UTC), same range as Revenue & orders (${((
|
|
1356
|
+
description: `Stages by order created date (UTC), same range as Revenue & orders (${((_b = OVER_TIME_PERIODS.find((p) => p.value === overTimePeriod)) == null ? void 0 : _b.label) ?? "period"}). Not storefront visitors.`,
|
|
1486
1357
|
children: overTimeLoading ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[120px] items-center justify-center py-3", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading…" }) }) }) : overTimeError ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[120px] items-center justify-center px-2 py-3", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-center text-xs", children: overTimeError }) }) }) : funnelTimeSeriesRows.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1487
1358
|
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
1488
1359
|
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Stage counts (time series)" }),
|
|
@@ -1713,21 +1584,6 @@ function OrdersDashboard() {
|
|
|
1713
1584
|
}
|
|
1714
1585
|
)
|
|
1715
1586
|
}
|
|
1716
|
-
),
|
|
1717
|
-
/* @__PURE__ */ jsx(
|
|
1718
|
-
AnalyticsSection,
|
|
1719
|
-
{
|
|
1720
|
-
variant: "atlas",
|
|
1721
|
-
title: "Order revenue (attribution)",
|
|
1722
|
-
description: "All revenue is from captured Medusa orders until storefront channel data exists.",
|
|
1723
|
-
children: insightsLoading ? /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center py-3", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading…" }) }) : insightsError ? /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center px-2 py-3", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-center text-xs", children: insightsError }) }) : ordersInsights && ordersInsights.traffic.length > 0 ? trafficTotalRevenue <= 0 ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted px-0.5 text-center text-[11px] leading-snug", children: "No recorded revenue in this window (totals may be zero until orders are paid or finalized)." }) : /* @__PURE__ */ jsx(TrafficRevenueDonut, { traffic: ordersInsights.traffic }) : /* @__PURE__ */ jsx(
|
|
1724
|
-
EmptyAnalyticsPanel$1,
|
|
1725
|
-
{
|
|
1726
|
-
title: "No order revenue",
|
|
1727
|
-
description: "No orders in this window."
|
|
1728
|
-
}
|
|
1729
|
-
)
|
|
1730
|
-
}
|
|
1731
1587
|
)
|
|
1732
1588
|
] })
|
|
1733
1589
|
] }),
|
|
@@ -1969,86 +1825,46 @@ function OrdersDashboard() {
|
|
|
1969
1825
|
}
|
|
1970
1826
|
)
|
|
1971
1827
|
] }),
|
|
1972
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-3 grid grid-cols-1 items-start gap-
|
|
1828
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 grid grid-cols-1 items-start gap-3 xl:grid-cols-12", children: [
|
|
1973
1829
|
/* @__PURE__ */ jsx(
|
|
1974
1830
|
AnalyticsSection,
|
|
1975
1831
|
{
|
|
1976
1832
|
variant: "atlas",
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1833
|
+
className: "xl:col-span-8",
|
|
1834
|
+
title: "Sales breakdown",
|
|
1835
|
+
description: salesBreakdownDescription,
|
|
1836
|
+
actionsBare: true,
|
|
1837
|
+
actions: /* @__PURE__ */ jsx(
|
|
1838
|
+
"div",
|
|
1981
1839
|
{
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
vertical: false,
|
|
1990
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
1991
|
-
}
|
|
1992
|
-
),
|
|
1993
|
-
/* @__PURE__ */ jsx(
|
|
1994
|
-
XAxis,
|
|
1995
|
-
{
|
|
1996
|
-
dataKey: "label",
|
|
1997
|
-
tick: CHART_AXIS_TICK$2
|
|
1998
|
-
}
|
|
1999
|
-
),
|
|
2000
|
-
/* @__PURE__ */ jsx(
|
|
2001
|
-
YAxis,
|
|
2002
|
-
{
|
|
2003
|
-
width: 40,
|
|
2004
|
-
tick: CHART_AXIS_TICK_SM$1,
|
|
2005
|
-
tickFormatter: (v) => formatCompactCurrency$1(Number(v))
|
|
2006
|
-
}
|
|
2007
|
-
),
|
|
2008
|
-
/* @__PURE__ */ jsx(
|
|
2009
|
-
Tooltip,
|
|
1840
|
+
className: "flex flex-wrap items-center gap-1 rounded-lg border border-ui-border-base bg-ui-bg-subtle/40 p-0.5",
|
|
1841
|
+
role: "tablist",
|
|
1842
|
+
"aria-label": "Sales breakdown granularity",
|
|
1843
|
+
children: SALES_GRANULARITY_TABS.map((tab) => {
|
|
1844
|
+
const selected = salesGranularity === tab.value;
|
|
1845
|
+
return /* @__PURE__ */ jsx(
|
|
1846
|
+
"button",
|
|
2010
1847
|
{
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
) })
|
|
2022
|
-
] }),
|
|
2023
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2024
|
-
"Orders:",
|
|
2025
|
-
" ",
|
|
2026
|
-
/* @__PURE__ */ jsx("strong", { children: Math.floor(
|
|
2027
|
-
Number(
|
|
2028
|
-
(_b2 = payload.find((p) => p.dataKey === "orders_count")) == null ? void 0 : _b2.value
|
|
2029
|
-
) || 0
|
|
2030
|
-
).toLocaleString() })
|
|
2031
|
-
] })
|
|
2032
|
-
] }) : null;
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
),
|
|
2036
|
-
/* @__PURE__ */ jsx(Bar, { dataKey: "revenue", name: "Revenue", fill: "#D946EF", radius: [4, 4, 0, 0] })
|
|
2037
|
-
]
|
|
2038
|
-
}
|
|
2039
|
-
) }) }) }) : /* @__PURE__ */ jsx(
|
|
2040
|
-
EmptyAnalyticsPanel$1,
|
|
2041
|
-
{
|
|
2042
|
-
title: "No weekday data",
|
|
2043
|
-
description: "No orders in this window."
|
|
1848
|
+
type: "button",
|
|
1849
|
+
role: "tab",
|
|
1850
|
+
"aria-selected": selected,
|
|
1851
|
+
onClick: () => setSalesGranularity(tab.value),
|
|
1852
|
+
className: `rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-fg-interactive ${selected ? "bg-ui-bg-base text-ui-fg-base shadow-sm" : "text-ui-fg-muted hover:text-ui-fg-base"}`,
|
|
1853
|
+
children: tab.label
|
|
1854
|
+
},
|
|
1855
|
+
tab.value
|
|
1856
|
+
);
|
|
1857
|
+
})
|
|
2044
1858
|
}
|
|
2045
|
-
)
|
|
1859
|
+
),
|
|
1860
|
+
children: salesBreakdownBody
|
|
2046
1861
|
}
|
|
2047
1862
|
),
|
|
2048
1863
|
/* @__PURE__ */ jsx(
|
|
2049
1864
|
AnalyticsSection,
|
|
2050
1865
|
{
|
|
2051
1866
|
variant: "atlas",
|
|
1867
|
+
className: "xl:col-span-4",
|
|
2052
1868
|
title: "Placed orders vs drafts",
|
|
2053
1869
|
description: "Window order count vs current open draft orders (admin). Not storefront cart abandonment.",
|
|
2054
1870
|
children: insightsLoading ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center py-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading…" }) }) }) : insightsError ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center px-2 py-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-center text-xs", children: insightsError }) }) }) : ordersVsDraftsPie.some((s) => s.value > 0) ? /* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
@@ -2107,82 +1923,6 @@ function OrdersDashboard() {
|
|
|
2107
1923
|
}
|
|
2108
1924
|
)
|
|
2109
1925
|
}
|
|
2110
|
-
),
|
|
2111
|
-
/* @__PURE__ */ jsx(
|
|
2112
|
-
AnalyticsSection,
|
|
2113
|
-
{
|
|
2114
|
-
variant: "atlas",
|
|
2115
|
-
title: "Sales by hour (UTC)",
|
|
2116
|
-
description: `Orders created by hour — last ${insightsWindowDays} days.`,
|
|
2117
|
-
children: insightsLoading ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center py-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "Loading…" }) }) }) : insightsError ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center px-2 py-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger text-center text-xs", children: insightsError }) }) }) : hourlyChartRows.length > 0 ? /* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsx("div", { className: "h-[min(176px,28vh)] min-h-[148px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
2118
|
-
BarChart,
|
|
2119
|
-
{
|
|
2120
|
-
data: hourlyChartRows,
|
|
2121
|
-
margin: { top: 2, right: 4, left: -8, bottom: 2 },
|
|
2122
|
-
children: [
|
|
2123
|
-
/* @__PURE__ */ jsx(
|
|
2124
|
-
CartesianGrid,
|
|
2125
|
-
{
|
|
2126
|
-
strokeDasharray: "3 3",
|
|
2127
|
-
vertical: false,
|
|
2128
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
2129
|
-
}
|
|
2130
|
-
),
|
|
2131
|
-
/* @__PURE__ */ jsx(
|
|
2132
|
-
XAxis,
|
|
2133
|
-
{
|
|
2134
|
-
dataKey: "label",
|
|
2135
|
-
interval: 3,
|
|
2136
|
-
tick: CHART_AXIS_TICK_SM$1
|
|
2137
|
-
}
|
|
2138
|
-
),
|
|
2139
|
-
/* @__PURE__ */ jsx(
|
|
2140
|
-
YAxis,
|
|
2141
|
-
{
|
|
2142
|
-
width: 28,
|
|
2143
|
-
tick: CHART_AXIS_TICK$2,
|
|
2144
|
-
allowDecimals: false
|
|
2145
|
-
}
|
|
2146
|
-
),
|
|
2147
|
-
/* @__PURE__ */ jsx(
|
|
2148
|
-
Tooltip,
|
|
2149
|
-
{
|
|
2150
|
-
content: ({ active, payload, label }) => {
|
|
2151
|
-
var _a2, _b2;
|
|
2152
|
-
return active && (payload == null ? void 0 : payload.length) ? /* @__PURE__ */ jsxs(AnalyticsTooltipCard, { variant: "compact", title: String(label), children: [
|
|
2153
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2154
|
-
"Orders:",
|
|
2155
|
-
" ",
|
|
2156
|
-
/* @__PURE__ */ jsx("strong", { children: Math.floor(
|
|
2157
|
-
Number(
|
|
2158
|
-
(_a2 = payload.find((p) => p.dataKey === "orders_count")) == null ? void 0 : _a2.value
|
|
2159
|
-
) || 0
|
|
2160
|
-
).toLocaleString() })
|
|
2161
|
-
] }),
|
|
2162
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2163
|
-
"Revenue:",
|
|
2164
|
-
" ",
|
|
2165
|
-
/* @__PURE__ */ jsx("strong", { children: formatCurrency$1(
|
|
2166
|
-
Number(
|
|
2167
|
-
(_b2 = payload.find((p) => p.dataKey === "revenue")) == null ? void 0 : _b2.value
|
|
2168
|
-
) || 0
|
|
2169
|
-
) })
|
|
2170
|
-
] })
|
|
2171
|
-
] }) : null;
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
),
|
|
2175
|
-
/* @__PURE__ */ jsx(Bar, { dataKey: "orders_count", name: "Orders", fill: "#38BDF8", radius: [4, 4, 0, 0] })
|
|
2176
|
-
]
|
|
2177
|
-
}
|
|
2178
|
-
) }) }) }) : /* @__PURE__ */ jsx(
|
|
2179
|
-
EmptyAnalyticsPanel$1,
|
|
2180
|
-
{
|
|
2181
|
-
title: "No hourly data",
|
|
2182
|
-
description: "No orders in this window."
|
|
2183
|
-
}
|
|
2184
|
-
)
|
|
2185
|
-
}
|
|
2186
1926
|
)
|
|
2187
1927
|
] })
|
|
2188
1928
|
] })
|
|
@@ -2896,7 +2636,7 @@ function EmptyAnalyticsPanel({ title, description }) {
|
|
|
2896
2636
|
] });
|
|
2897
2637
|
}
|
|
2898
2638
|
function ProductsDashboard() {
|
|
2899
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
2639
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2900
2640
|
const [summaryDays, setSummaryDays] = useState("all");
|
|
2901
2641
|
const [graphPeriod, setGraphPeriod] = useState("one_week");
|
|
2902
2642
|
const [topSellerPeriod, setTopSellerPeriod] = useState("week");
|
|
@@ -3023,7 +2763,7 @@ function ProductsDashboard() {
|
|
|
3023
2763
|
};
|
|
3024
2764
|
}, [salesChannelId, topSellerPeriod]);
|
|
3025
2765
|
useEffect(() => {
|
|
3026
|
-
var _a2
|
|
2766
|
+
var _a2;
|
|
3027
2767
|
let cancelled = false;
|
|
3028
2768
|
if (topSellersLoading) {
|
|
3029
2769
|
setBestSellersTrendLoading(true);
|
|
@@ -3039,7 +2779,12 @@ function ProductsDashboard() {
|
|
|
3039
2779
|
cancelled = true;
|
|
3040
2780
|
};
|
|
3041
2781
|
}
|
|
3042
|
-
const
|
|
2782
|
+
const topSellersByUnits2 = [...(topSellers == null ? void 0 : topSellers.products) ?? []].sort((a, b) => {
|
|
2783
|
+
if (b.units_sold !== a.units_sold) return b.units_sold - a.units_sold;
|
|
2784
|
+
if (b.order_count !== a.order_count) return b.order_count - a.order_count;
|
|
2785
|
+
return b.revenue - a.revenue;
|
|
2786
|
+
});
|
|
2787
|
+
const topProductId = (_a2 = topSellersByUnits2[0]) == null ? void 0 : _a2.product_id;
|
|
3043
2788
|
if (!topProductId) {
|
|
3044
2789
|
setBestSellersTrendLoading(false);
|
|
3045
2790
|
setBestSellersTrendError(null);
|
|
@@ -3185,16 +2930,24 @@ function ProductsDashboard() {
|
|
|
3185
2930
|
}, [series]);
|
|
3186
2931
|
const peakRevenuePoint = series.length > 0 ? series.reduce((peak, point) => point.revenue > peak.revenue ? point : peak) : null;
|
|
3187
2932
|
const viewsConnectedForPulse = ((summary == null ? void 0 : summary.productViewsConnected) ?? false) || (overTime == null ? void 0 : overTime.productViewsConnected) === true || (topSellers == null ? void 0 : topSellers.productViewsConnected) === true || (performance == null ? void 0 : performance.productViewsConnected) === true;
|
|
2933
|
+
const topSellersByUnits = useMemo(
|
|
2934
|
+
() => [...(topSellers == null ? void 0 : topSellers.products) ?? []].sort((a, b) => {
|
|
2935
|
+
if (b.units_sold !== a.units_sold) return b.units_sold - a.units_sold;
|
|
2936
|
+
if (b.order_count !== a.order_count) return b.order_count - a.order_count;
|
|
2937
|
+
return b.revenue - a.revenue;
|
|
2938
|
+
}),
|
|
2939
|
+
[topSellers]
|
|
2940
|
+
);
|
|
3188
2941
|
const bestSellersTrendSeries = (bestSellersTrend == null ? void 0 : bestSellersTrend.series) ?? [];
|
|
3189
2942
|
const mostViewedTrendSeries = (mostViewedTrend == null ? void 0 : mostViewedTrend.series) ?? [];
|
|
3190
|
-
const bestSellerTrendProductTitle = ((_a = bestSellersTrend == null ? void 0 : bestSellersTrend.product) == null ? void 0 : _a.product_title) ?? ((
|
|
3191
|
-
const mostViewedTrendProductTitle = ((
|
|
2943
|
+
const bestSellerTrendProductTitle = ((_a = bestSellersTrend == null ? void 0 : bestSellersTrend.product) == null ? void 0 : _a.product_title) ?? ((_b = topSellersByUnits[0]) == null ? void 0 : _b.product_title) ?? null;
|
|
2944
|
+
const mostViewedTrendProductTitle = ((_c = mostViewedTrend == null ? void 0 : mostViewedTrend.product) == null ? void 0 : _c.product_title) ?? ((_e = (_d = performance == null ? void 0 : performance.topViewedProducts) == null ? void 0 : _d[0]) == null ? void 0 : _e.product_title) ?? null;
|
|
3192
2945
|
const viewsVsUnitsScatterData = useMemo(
|
|
3193
2946
|
() => ((performance == null ? void 0 : performance.topViewedProducts) ?? []).slice(0, 48).filter((row) => row.total_views > 0 || row.units_sold > 0),
|
|
3194
2947
|
[performance]
|
|
3195
2948
|
);
|
|
3196
|
-
const selectedSummaryPeriod = ((
|
|
3197
|
-
const selectedGraphPeriodLabel = ((
|
|
2949
|
+
const selectedSummaryPeriod = ((_f = SUMMARY_PERIODS.find((p) => p.value === summaryDays)) == null ? void 0 : _f.label) ?? "All time";
|
|
2950
|
+
const selectedGraphPeriodLabel = ((_g = GRAPH_PERIODS.find((p) => p.value === graphPeriod)) == null ? void 0 : _g.label) ?? "One week";
|
|
3198
2951
|
const quickPulseMetrics = [
|
|
3199
2952
|
{
|
|
3200
2953
|
label: "Range units",
|
|
@@ -3236,7 +2989,7 @@ function ProductsDashboard() {
|
|
|
3236
2989
|
return /* @__PURE__ */ jsx(Container, { className: "p-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-danger", children: summaryError ?? "Failed to load product analytics" }) });
|
|
3237
2990
|
}
|
|
3238
2991
|
const viewsConnected = summary.productViewsConnected || (overTime == null ? void 0 : overTime.productViewsConnected) === true || (topSellers == null ? void 0 : topSellers.productViewsConnected) === true || (performance == null ? void 0 : performance.productViewsConnected) === true;
|
|
3239
|
-
const selectedChannelLabel = salesChannelId === "all" ? "All channels" : ((
|
|
2992
|
+
const selectedChannelLabel = salesChannelId === "all" ? "All channels" : ((_h = salesChannels.find((channel) => channel.id === salesChannelId)) == null ? void 0 : _h.name) ?? "Selected channel";
|
|
3240
2993
|
const primaryStats = [
|
|
3241
2994
|
{
|
|
3242
2995
|
label: "Units sold",
|
|
@@ -3405,9 +3158,9 @@ function ProductsDashboard() {
|
|
|
3405
3158
|
}
|
|
3406
3159
|
)
|
|
3407
3160
|
] }),
|
|
3408
|
-
children: /* @__PURE__ */ jsxs("div", { className: "
|
|
3409
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-
|
|
3410
|
-
/* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3161
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3162
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 sm:grid-cols-3 sm:gap-1.5", children: [
|
|
3163
|
+
/* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", className: "min-h-0", children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3411
3164
|
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-[10px] font-medium uppercase tracking-[0.14em]", children: "Window units" }),
|
|
3412
3165
|
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-base text-lg font-semibold tracking-tight", children: formatShortNumber(trendTotals.totalUnits) }),
|
|
3413
3166
|
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-muted text-[10px]", children: [
|
|
@@ -3415,7 +3168,7 @@ function ProductsDashboard() {
|
|
|
3415
3168
|
trendTotals.avgUnitsPerDay.toFixed(1)
|
|
3416
3169
|
] })
|
|
3417
3170
|
] }) }),
|
|
3418
|
-
/* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3171
|
+
/* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", className: "min-h-0", children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3419
3172
|
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-[10px] font-medium uppercase tracking-[0.14em]", children: "Window revenue" }),
|
|
3420
3173
|
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-base text-lg font-semibold tracking-tight", children: formatCompactCurrency(trendTotals.totalRevenue) }),
|
|
3421
3174
|
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-muted text-[10px]", children: [
|
|
@@ -3423,7 +3176,7 @@ function ProductsDashboard() {
|
|
|
3423
3176
|
formatCompactCurrency(trendTotals.avgRevenuePerDay)
|
|
3424
3177
|
] })
|
|
3425
3178
|
] }) }),
|
|
3426
|
-
/* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3179
|
+
/* @__PURE__ */ jsx(AnalyticsChartSurface, { variant: "atlas", className: "min-h-0", children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3427
3180
|
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-[10px] font-medium uppercase tracking-[0.14em]", children: "Window views" }),
|
|
3428
3181
|
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-base text-lg font-semibold tracking-tight", children: formatShortNumber(trendTotals.totalViews) }),
|
|
3429
3182
|
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-muted text-[10px]", children: [
|
|
@@ -3432,131 +3185,6 @@ function ProductsDashboard() {
|
|
|
3432
3185
|
] })
|
|
3433
3186
|
] }) })
|
|
3434
3187
|
] }),
|
|
3435
|
-
!overTimeLoading && !overTimeError && series.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-1.5 md:grid-cols-3", children: [
|
|
3436
|
-
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
3437
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Units sold" }),
|
|
3438
|
-
/* @__PURE__ */ jsx("div", { className: "h-[96px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
3439
|
-
LineChart,
|
|
3440
|
-
{
|
|
3441
|
-
data: series,
|
|
3442
|
-
margin: { top: 4, right: 4, left: 0, bottom: 0 },
|
|
3443
|
-
children: [
|
|
3444
|
-
/* @__PURE__ */ jsx(
|
|
3445
|
-
CartesianGrid,
|
|
3446
|
-
{
|
|
3447
|
-
strokeDasharray: "3 3",
|
|
3448
|
-
vertical: false,
|
|
3449
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
3450
|
-
}
|
|
3451
|
-
),
|
|
3452
|
-
/* @__PURE__ */ jsx(XAxis, { dataKey: "date", hide: true }),
|
|
3453
|
-
/* @__PURE__ */ jsx(
|
|
3454
|
-
YAxis,
|
|
3455
|
-
{
|
|
3456
|
-
width: 28,
|
|
3457
|
-
tick: CHART_AXIS_TICK_SM,
|
|
3458
|
-
allowDecimals: false
|
|
3459
|
-
}
|
|
3460
|
-
),
|
|
3461
|
-
/* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(MiniTrendTooltip, {}) }),
|
|
3462
|
-
/* @__PURE__ */ jsx(
|
|
3463
|
-
Line,
|
|
3464
|
-
{
|
|
3465
|
-
type: "natural",
|
|
3466
|
-
dataKey: "units_sold",
|
|
3467
|
-
name: "Units sold",
|
|
3468
|
-
stroke: PRODUCT_CHART_COLORS.units,
|
|
3469
|
-
strokeWidth: 2,
|
|
3470
|
-
dot: false
|
|
3471
|
-
}
|
|
3472
|
-
)
|
|
3473
|
-
]
|
|
3474
|
-
}
|
|
3475
|
-
) }) })
|
|
3476
|
-
] }),
|
|
3477
|
-
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
3478
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Views" }),
|
|
3479
|
-
/* @__PURE__ */ jsx("div", { className: "h-[96px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
3480
|
-
LineChart,
|
|
3481
|
-
{
|
|
3482
|
-
data: series,
|
|
3483
|
-
margin: { top: 4, right: 4, left: 0, bottom: 0 },
|
|
3484
|
-
children: [
|
|
3485
|
-
/* @__PURE__ */ jsx(
|
|
3486
|
-
CartesianGrid,
|
|
3487
|
-
{
|
|
3488
|
-
strokeDasharray: "3 3",
|
|
3489
|
-
vertical: false,
|
|
3490
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
3491
|
-
}
|
|
3492
|
-
),
|
|
3493
|
-
/* @__PURE__ */ jsx(XAxis, { dataKey: "date", hide: true }),
|
|
3494
|
-
/* @__PURE__ */ jsx(
|
|
3495
|
-
YAxis,
|
|
3496
|
-
{
|
|
3497
|
-
width: 28,
|
|
3498
|
-
tick: CHART_AXIS_TICK_SM,
|
|
3499
|
-
allowDecimals: false
|
|
3500
|
-
}
|
|
3501
|
-
),
|
|
3502
|
-
/* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(MiniTrendTooltip, {}) }),
|
|
3503
|
-
/* @__PURE__ */ jsx(
|
|
3504
|
-
Line,
|
|
3505
|
-
{
|
|
3506
|
-
type: "natural",
|
|
3507
|
-
dataKey: "views",
|
|
3508
|
-
name: "Views",
|
|
3509
|
-
stroke: PRODUCT_CHART_COLORS.views,
|
|
3510
|
-
strokeWidth: 2,
|
|
3511
|
-
dot: false
|
|
3512
|
-
}
|
|
3513
|
-
)
|
|
3514
|
-
]
|
|
3515
|
-
}
|
|
3516
|
-
) }) })
|
|
3517
|
-
] }),
|
|
3518
|
-
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", children: [
|
|
3519
|
-
/* @__PURE__ */ jsx(Text, { className: "mb-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-ui-fg-muted", children: "Revenue" }),
|
|
3520
|
-
/* @__PURE__ */ jsx("div", { className: "h-[96px] w-full", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
3521
|
-
LineChart,
|
|
3522
|
-
{
|
|
3523
|
-
data: series,
|
|
3524
|
-
margin: { top: 4, right: 4, left: 0, bottom: 0 },
|
|
3525
|
-
children: [
|
|
3526
|
-
/* @__PURE__ */ jsx(
|
|
3527
|
-
CartesianGrid,
|
|
3528
|
-
{
|
|
3529
|
-
strokeDasharray: "3 3",
|
|
3530
|
-
vertical: false,
|
|
3531
|
-
stroke: "rgba(148,163,184,0.12)"
|
|
3532
|
-
}
|
|
3533
|
-
),
|
|
3534
|
-
/* @__PURE__ */ jsx(XAxis, { dataKey: "date", hide: true }),
|
|
3535
|
-
/* @__PURE__ */ jsx(
|
|
3536
|
-
YAxis,
|
|
3537
|
-
{
|
|
3538
|
-
width: 36,
|
|
3539
|
-
tick: CHART_AXIS_TICK_SM,
|
|
3540
|
-
tickFormatter: (v) => formatCompactCurrency(Number(v))
|
|
3541
|
-
}
|
|
3542
|
-
),
|
|
3543
|
-
/* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(MiniTrendTooltip, {}) }),
|
|
3544
|
-
/* @__PURE__ */ jsx(
|
|
3545
|
-
Line,
|
|
3546
|
-
{
|
|
3547
|
-
type: "natural",
|
|
3548
|
-
dataKey: "revenue",
|
|
3549
|
-
name: "Revenue",
|
|
3550
|
-
stroke: PRODUCT_CHART_COLORS.revenue,
|
|
3551
|
-
strokeWidth: 2,
|
|
3552
|
-
dot: false
|
|
3553
|
-
}
|
|
3554
|
-
)
|
|
3555
|
-
]
|
|
3556
|
-
}
|
|
3557
|
-
) }) })
|
|
3558
|
-
] })
|
|
3559
|
-
] }) : null,
|
|
3560
3188
|
/* @__PURE__ */ jsxs(AnalyticsChartSurface, { variant: "atlas", className: "relative overflow-hidden", children: [
|
|
3561
3189
|
/* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-x-6 top-0 h-12 rounded-b-full bg-gradient-to-r from-sky-400/10 via-fuchsia-400/10 to-transparent blur-xl" }),
|
|
3562
3190
|
/* @__PURE__ */ jsxs("div", { className: "relative space-y-1", children: [
|
|
@@ -3782,7 +3410,7 @@ function ProductsDashboard() {
|
|
|
3782
3410
|
variant: "atlas",
|
|
3783
3411
|
actionsBare: true,
|
|
3784
3412
|
title: "Best sellers",
|
|
3785
|
-
description: bestSellerTrendProductTitle ? `Revenue and units over time for “${bestSellerTrendProductTitle}” (#1 by
|
|
3413
|
+
description: bestSellerTrendProductTitle ? `Revenue and units over time for “${bestSellerTrendProductTitle}” (#1 by units sold in this window; all-time uses a 12‑month chart).` : "Revenue and units over time for the top product by units sold in this window (all-time leaderboard uses a 12‑month chart).",
|
|
3786
3414
|
actions: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3787
3415
|
/* @__PURE__ */ jsx(
|
|
3788
3416
|
Label,
|
|
@@ -3946,7 +3574,7 @@ function ProductsDashboard() {
|
|
|
3946
3574
|
variant: "atlas",
|
|
3947
3575
|
className: "min-w-0 md:col-span-1 xl:col-span-1",
|
|
3948
3576
|
title: "Leaderboard table",
|
|
3949
|
-
description: "Products ranked by
|
|
3577
|
+
description: "Products ranked by units sold — same window as Best sellers.",
|
|
3950
3578
|
children: /* @__PURE__ */ jsx("div", { className: "min-h-[212px] min-w-0 sm:min-h-[228px]", children: /* @__PURE__ */ jsx(AnalyticsTableSurface, { className: "shadow-sm", children: /* @__PURE__ */ jsxs(Table, { className: LEADERBOARD_TABLE_CLASS, children: [
|
|
3951
3579
|
/* @__PURE__ */ jsx(Table.Header, { children: /* @__PURE__ */ jsxs(Table.Row, { children: [
|
|
3952
3580
|
/* @__PURE__ */ jsx(Table.HeaderCell, { className: TABLE_HEAD_CELL_NOWRAP, children: "Product" }),
|
|
@@ -3961,12 +3589,12 @@ function ProductsDashboard() {
|
|
|
3961
3589
|
/* @__PURE__ */ jsx(Table.Cell, {}),
|
|
3962
3590
|
/* @__PURE__ */ jsx(Table.Cell, {})
|
|
3963
3591
|
] }) : null,
|
|
3964
|
-
!topSellersError ?
|
|
3965
|
-
var _a2
|
|
3592
|
+
!topSellersError ? topSellersByUnits.slice(0, 8).map((product) => {
|
|
3593
|
+
var _a2;
|
|
3966
3594
|
return /* @__PURE__ */ jsxs(
|
|
3967
3595
|
Table.Row,
|
|
3968
3596
|
{
|
|
3969
|
-
className: product.product_id === ((
|
|
3597
|
+
className: product.product_id === ((_a2 = topSellersByUnits[0]) == null ? void 0 : _a2.product_id) ? "bg-emerald-500/5" : void 0,
|
|
3970
3598
|
children: [
|
|
3971
3599
|
/* @__PURE__ */ jsx(Table.Cell, { children: product.product_title }),
|
|
3972
3600
|
/* @__PURE__ */ jsx(Table.Cell, { children: product.units_sold.toLocaleString() }),
|
|
@@ -3977,7 +3605,7 @@ function ProductsDashboard() {
|
|
|
3977
3605
|
product.product_id
|
|
3978
3606
|
);
|
|
3979
3607
|
}) : null,
|
|
3980
|
-
!topSellersLoading && !topSellersError && (((
|
|
3608
|
+
!topSellersLoading && !topSellersError && (((_i = topSellers == null ? void 0 : topSellers.products) == null ? void 0 : _i.length) ?? 0) === 0 ? /* @__PURE__ */ jsxs(Table.Row, { children: [
|
|
3981
3609
|
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "No best seller data yet." }) }),
|
|
3982
3610
|
/* @__PURE__ */ jsx(Table.Cell, {}),
|
|
3983
3611
|
/* @__PURE__ */ jsx(Table.Cell, {}),
|
|
@@ -4133,7 +3761,7 @@ function ProductsDashboard() {
|
|
|
4133
3761
|
/* @__PURE__ */ jsx(Table.Cell, { children: product.units_sold.toLocaleString() }),
|
|
4134
3762
|
/* @__PURE__ */ jsx(Table.Cell, { children: formatRatio(product.views_per_unit) })
|
|
4135
3763
|
] }, product.product_id)),
|
|
4136
|
-
!performanceLoading && !performanceError && (((
|
|
3764
|
+
!performanceLoading && !performanceError && (((_j = performance == null ? void 0 : performance.viewOpportunities) == null ? void 0 : _j.length) ?? 0) === 0 ? /* @__PURE__ */ jsxs(Table.Row, { children: [
|
|
4137
3765
|
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted text-xs", children: "No product view opportunities yet." }) }),
|
|
4138
3766
|
/* @__PURE__ */ jsx(Table.Cell, {}),
|
|
4139
3767
|
/* @__PURE__ */ jsx(Table.Cell, {}),
|