@medialane/ui 0.275.0 → 0.277.0

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/describe-error.ts"],"sourcesContent":["import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from \"@medialane/sdk\";\nimport { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from \"./wallet-error.js\";\nimport { describeWalletFailure, passkeyUnsupportedReason } from \"./wallet-failure.js\";\n\nexport const NOT_SUBMITTED = \"Request not completed. Nothing was submitted.\";\nexport const NETWORK_BUSY = \"Our service is very busy right now. Please try again in a minute.\";\nexport const CONNECTION_FAILED = \"We couldn't connect. Check your internet connection and try again.\";\n\nexport interface ErrorNotice {\n title?: string;\n message: string;\n description?: string;\n isUserRejection: boolean;\n retryable: boolean;\n}\n\nconst notice = (title: string | undefined, message: string, description?: string, retryable = true): ErrorNotice => ({\n title,\n message,\n description,\n isUserRejection: false,\n retryable,\n});\n\nfunction unexplained(error: unknown): ErrorNotice {\n const id = (error as { requestId?: unknown } | null)?.requestId;\n const reference = (typeof id === \"string\" && id !== \"\" ? id : crypto.randomUUID()).slice(0, 8);\n console.error(\"[medialane] unexplained failure\", { reference, error });\n return notice(undefined, `Share reference ${reference} with support.`);\n}\n\nfunction isBusy(error: unknown): boolean {\n return /-32001|unable to complete request|rate.?limit|too many requests/i.test(collectErrorText(error));\n}\n\nfunction isConnectionFailure(error: unknown): boolean {\n return /failed to fetch|fetch failed|load failed|networkerror when attempting/i.test(collectErrorText(error));\n}\n\nfunction apiReason(error: MedialaneApiError): string | undefined {\n const body = error.details;\n if (body && typeof body === \"object\" && \"error\" in body) {\n const reason = (body as { error?: unknown }).error;\n if (typeof reason === \"string\" && reason.trim() !== \"\") return reason;\n }\n return undefined;\n}\n\nexport function describeError(error: unknown): ErrorNotice {\n if (error instanceof PasskeyCancelledError || isUserRejectedRequest(error)) {\n const unclear = isBareExecuteFailure(error) || error instanceof PasskeyCancelledError;\n return {\n title: \"Request not completed\",\n message: NOT_SUBMITTED,\n description: unclear\n ? \"Your wallet didn't complete this request. You may have closed or declined it, it may need extra verification such as 2FA before it can sign, or it may have hit a temporary network hiccup. Try again in a moment.\"\n : \"Your wallet didn't complete this request. You may have closed or declined it, or it may need extra verification before it can sign.\",\n isUserRejection: true,\n retryable: true,\n };\n }\n\n if (passkeyUnsupportedReason(error)) {\n return notice(\"Passkey not supported\", describeWalletFailure(error).message);\n }\n\n if (error instanceof WrongNetworkError) {\n return notice(\n \"Wrong network\",\n \"Your wallet is connected to the wrong network. Nothing was submitted.\",\n \"Switch your wallet to Starknet Mainnet, then try again.\",\n );\n }\n\n if (error instanceof UserFacingError) {\n return notice(undefined, error.message, undefined, error.retryable);\n }\n\n if (error instanceof MedialaneApiError) {\n if (error.status === 429) return notice(\"Service busy\", NETWORK_BUSY);\n const reason = error.status >= 500 ? undefined : apiReason(error);\n return reason ? notice(undefined, reason) : unexplained(error);\n }\n\n if (isBusy(error)) {\n return notice(\"Service busy\", NETWORK_BUSY);\n }\n\n if (isConnectionFailure(error)) {\n return notice(\"Connection problem\", CONNECTION_FAILED);\n }\n\n const text = collectErrorText(error).toLowerCase();\n if (text.includes(\"insufficient\") && /balance|allowance|funds/.test(text)) {\n return notice(\n \"Insufficient balance\",\n \"You don't have enough balance to complete this transaction.\",\n \"Add funds to your wallet, then try again.\",\n );\n }\n\n return unexplained(error);\n}\n\nexport { UserFacingError };\n"],"mappings":"AAAA,SAAS,mBAAmB,uBAAuB,uBAAuB;AAC1E,SAAS,mBAAmB,sBAAsB,uBAAuB,wBAAwB;AACjG,SAAS,uBAAuB,gCAAgC;AAEzD,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAUjC,MAAM,SAAS,CAAC,OAA2B,SAAiB,aAAsB,YAAY,UAAuB;AAAA,EACnH;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AA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,IAAK,QAAO,OAAO,gBAAgB,YAAY;AACpE,UAAM,SAAS,MAAM,UAAU,MAAM,SAAY,UAAU,KAAK;AAChE,WAAO,SAAS,OAAO,QAAW,MAAM,IAAI,YAAY,KAAK;AAAA,EAC/D;AAEA,MAAI,OAAO,KAAK,GAAG;AACjB,WAAO,OAAO,gBAAgB,YAAY;AAAA,EAC5C;AAEA,MAAI,oBAAoB,KAAK,GAAG;AAC9B,WAAO,OAAO,sBAAsB,iBAAiB;AAAA,EACvD;AAEA,QAAM,OAAO,iBAAiB,KAAK,EAAE,YAAY;AACjD,MAAI,KAAK,SAAS,cAAc,KAAK,0BAA0B,KAAK,IAAI,GAAG;AACzE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,YAAY,KAAK;AAC1B;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/describe-error.ts"],"sourcesContent":["import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from \"@medialane/sdk\";\nimport { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from \"./wallet-error.js\";\nimport { describeWalletFailure, passkeyUnsupportedReason } from \"./wallet-failure.js\";\n\nexport const NOT_SUBMITTED = \"Request not completed. Nothing was submitted.\";\nexport const NETWORK_BUSY = \"Our service is very busy right now. Please try again in a minute.\";\nexport const CONNECTION_FAILED = \"We couldn't connect. Check your internet connection and try again.\";\n\nexport interface ErrorNotice {\n title?: string;\n message: string;\n description?: string;\n isUserRejection: boolean;\n retryable: boolean;\n}\n\nconst notice = (title: string | undefined, message: string, description?: string, retryable = true): ErrorNotice => ({\n title,\n message,\n description,\n isUserRejection: false,\n retryable,\n});\n\nfunction unexplained(error: unknown): ErrorNotice {\n const id = (error as { requestId?: unknown } | null)?.requestId;\n const reference = (typeof id === \"string\" && id !== \"\" ? id : crypto.randomUUID()).slice(0, 8);\n console.error(\"[medialane] unexplained failure\", { reference, error });\n return notice(undefined, `Share reference ${reference} with support.`);\n}\n\nfunction isBusy(error: unknown): boolean {\n return /-32001|unable to complete request|rate.?limit|too many requests/i.test(collectErrorText(error));\n}\n\nfunction isConnectionFailure(error: unknown): boolean {\n return /failed to fetch|fetch failed|load failed|networkerror when attempting/i.test(collectErrorText(error));\n}\n\nfunction apiReason(error: MedialaneApiError): string | undefined {\n const body = error.details;\n if (body && typeof body === \"object\" && \"error\" in body) {\n const reason = (body as { error?: unknown }).error;\n if (typeof reason === \"string\" && reason.trim() !== \"\") return reason;\n }\n return undefined;\n}\n\nexport function describeError(error: unknown): ErrorNotice {\n if (error instanceof PasskeyCancelledError || isUserRejectedRequest(error)) {\n const unclear = isBareExecuteFailure(error) || error instanceof PasskeyCancelledError;\n return {\n title: \"Request not completed\",\n message: NOT_SUBMITTED,\n description: unclear\n ? \"Your wallet didn't complete this request. You may have closed or declined it, it may need extra verification such as 2FA before it can sign, or it may have hit a temporary network hiccup. Try again in a moment.\"\n : \"Your wallet didn't complete this request. You may have closed or declined it, or it may need extra verification before it can sign.\",\n isUserRejection: true,\n retryable: true,\n };\n }\n\n if (passkeyUnsupportedReason(error)) {\n return notice(\"Passkey not supported\", describeWalletFailure(error).message);\n }\n\n if (error instanceof WrongNetworkError) {\n return notice(\n \"Wrong network\",\n \"Your wallet is connected to the wrong network. Nothing was submitted.\",\n \"Switch your wallet to Starknet Mainnet, then try again.\",\n );\n }\n\n if (error instanceof UserFacingError) {\n return notice(undefined, error.message, undefined, error.retryable);\n }\n\n if (error instanceof MedialaneApiError) {\n if (error.status === 429) return notice(\"Service busy\", NETWORK_BUSY);\n const reason = error.status >= 500 ? undefined : apiReason(error);\n return reason ? notice(undefined, reason, undefined, false) : unexplained(error);\n }\n\n if (isBusy(error)) {\n return notice(\"Service busy\", NETWORK_BUSY);\n }\n\n if (isConnectionFailure(error)) {\n return notice(\"Connection problem\", CONNECTION_FAILED);\n }\n\n const text = collectErrorText(error).toLowerCase();\n if (text.includes(\"insufficient\") && /balance|allowance|funds/.test(text)) {\n return notice(\n \"Insufficient balance\",\n \"You don't have enough balance to complete this transaction.\",\n \"Add funds to your wallet, then try again.\",\n );\n }\n\n return unexplained(error);\n}\n\nexport { UserFacingError };\n"],"mappings":"AAAA,SAAS,mBAAmB,uBAAuB,uBAAuB;AAC1E,SAAS,mBAAmB,sBAAsB,uBAAuB,wBAAwB;AACjG,SAAS,uBAAuB,gCAAgC;AAEzD,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAUjC,MAAM,SAAS,CAAC,OAA2B,SAAiB,aAAsB,YAAY,UAAuB;AAAA,EACnH;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AACF;AAEA,SAAS,YAAY,OAA6B;AAChD,QAAM,KAAM,OAA0C;AACtD,QAAM,aAAa,OAAO,OAAO,YAAY,OAAO,KAAK,KAAK,OAAO,WAAW,GAAG,MAAM,GAAG,CAAC;AAC7F,UAAQ,MAAM,mCAAmC,EAAE,WAAW,MAAM,CAAC;AACrE,SAAO,OAAO,QAAW,mBAAmB,SAAS,gBAAgB;AACvE;AAEA,SAAS,OAAO,OAAyB;AACvC,SAAO,mEAAmE,KAAK,iBAAiB,KAAK,CAAC;AACxG;AAEA,SAAS,oBAAoB,OAAyB;AACpD,SAAO,yEAAyE,KAAK,iBAAiB,KAAK,CAAC;AAC9G;AAEA,SAAS,UAAU,OAA8C;AAC/D,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,OAAO,SAAS,YAAY,WAAW,MAAM;AACvD,UAAM,SAAU,KAA6B;AAC7C,QAAI,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,GAAI,QAAO;AAAA,EACjE;AACA,SAAO;AACT;AAEO,SAAS,cAAc,OAA6B;AACzD,MAAI,iBAAiB,yBAAyB,sBAAsB,KAAK,GAAG;AAC1E,UAAM,UAAU,qBAAqB,KAAK,KAAK,iBAAiB;AAChE,WAAO;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa,UACT,uNACA;AAAA,MACJ,iBAAiB;AAAA,MACjB,WAAW;AAAA,IACb;AAAA,EACF;AAEA,MAAI,yBAAyB,KAAK,GAAG;AACnC,WAAO,OAAO,yBAAyB,sBAAsB,KAAK,EAAE,OAAO;AAAA,EAC7E;AAEA,MAAI,iBAAiB,mBAAmB;AACtC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,iBAAiB,iBAAiB;AACpC,WAAO,OAAO,QAAW,MAAM,SAAS,QAAW,MAAM,SAAS;AAAA,EACpE;AAEA,MAAI,iBAAiB,mBAAmB;AACtC,QAAI,MAAM,WAAW,IAAK,QAAO,OAAO,gBAAgB,YAAY;AACpE,UAAM,SAAS,MAAM,UAAU,MAAM,SAAY,UAAU,KAAK;AAChE,WAAO,SAAS,OAAO,QAAW,QAAQ,QAAW,KAAK,IAAI,YAAY,KAAK;AAAA,EACjF;AAEA,MAAI,OAAO,KAAK,GAAG;AACjB,WAAO,OAAO,gBAAgB,YAAY;AAAA,EAC5C;AAEA,MAAI,oBAAoB,KAAK,GAAG;AAC9B,WAAO,OAAO,sBAAsB,iBAAiB;AAAA,EACvD;AAEA,QAAM,OAAO,iBAAiB,KAAK,EAAE,YAAY;AACjD,MAAI,KAAK,SAAS,cAAc,KAAK,0BAA0B,KAAK,IAAI,GAAG;AACzE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,YAAY,KAAK;AAC1B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medialane/ui",
3
- "version": "0.275.0",
3
+ "version": "0.277.0",
4
4
  "description": "Shared UI components for Medialane apps",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,170 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var creator_analytics_exports = {};
21
- __export(creator_analytics_exports, {
22
- CreatorAnalytics: () => CreatorAnalytics
23
- });
24
- module.exports = __toCommonJS(creator_analytics_exports);
25
- var import_jsx_runtime = require("react/jsx-runtime");
26
- var import_react = require("react");
27
- var import_recharts = require("recharts");
28
- var import_lucide_react = require("lucide-react");
29
- function parsePrice(formatted) {
30
- if (!formatted) return 0;
31
- return parseFloat(formatted.replace(/[^0-9.]/g, "")) || 0;
32
- }
33
- function buildDailyVolume(sales) {
34
- const buckets = /* @__PURE__ */ new Map();
35
- const now = Date.now();
36
- for (let i = 29; i >= 0; i--) {
37
- const d = new Date(now - i * 864e5);
38
- buckets.set(
39
- d.toLocaleDateString("en-US", { month: "short", day: "numeric" }),
40
- 0
41
- );
42
- }
43
- for (const s of sales) {
44
- const ts = typeof s.timestamp === "number" ? s.timestamp * 1e3 : new Date(s.timestamp).getTime();
45
- if (now - ts > 30 * 864e5) continue;
46
- const label = new Date(ts).toLocaleDateString("en-US", {
47
- month: "short",
48
- day: "numeric"
49
- });
50
- buckets.set(label, (buckets.get(label) ?? 0) + parsePrice(s.price?.formatted));
51
- }
52
- return Array.from(buckets.entries()).map(([label, volume]) => ({ label, volume }));
53
- }
54
- function CreatorAnalytics({ activities, isLoading }) {
55
- const { sales, totalVolume, topCurrency, dailyVolume } = (0, import_react.useMemo)(() => {
56
- const sales2 = activities.filter((a) => a.type === "sale");
57
- const byCurrency = /* @__PURE__ */ new Map();
58
- for (const s of sales2) {
59
- const cur = s.price?.currency ?? "STRK";
60
- byCurrency.set(cur, (byCurrency.get(cur) ?? 0) + parsePrice(s.price?.formatted));
61
- }
62
- const sorted = [...byCurrency.entries()].sort((a, b) => b[1] - a[1]);
63
- const topCurrency2 = sorted[0]?.[0] ?? "STRK";
64
- const totalVolume2 = sorted[0]?.[1] ?? 0;
65
- const dailyVolume2 = buildDailyVolume(
66
- sales2.filter((s) => (s.price?.currency ?? "STRK") === topCurrency2)
67
- );
68
- return { sales: sales2, totalVolume: totalVolume2, topCurrency: topCurrency2, dailyVolume: dailyVolume2 };
69
- }, [activities]);
70
- if (isLoading) {
71
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "space-y-4 animate-pulse", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-20 rounded-xl bg-muted" }, i)) });
72
- }
73
- if (sales.length === 0) {
74
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "py-12 text-center text-sm text-muted-foreground", children: "No sales recorded yet." });
75
- }
76
- const stats = [
77
- {
78
- label: "Total Sales",
79
- value: sales.length.toString(),
80
- icon: import_lucide_react.ShoppingBag
81
- },
82
- {
83
- label: `Total Volume (${topCurrency})`,
84
- value: totalVolume.toFixed(2),
85
- icon: import_lucide_react.Coins
86
- },
87
- {
88
- label: "Last 30 Days",
89
- value: `${dailyVolume.filter((d) => d.volume > 0).length} active days`,
90
- icon: import_lucide_react.TrendingUp
91
- }
92
- ];
93
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-6", children: [
94
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-3", children: stats.map(({ label, value, icon: Icon }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
95
- "div",
96
- {
97
- className: "rounded-xl border border-border bg-card/50 p-4 space-y-1",
98
- children: [
99
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 text-muted-foreground", children: [
100
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { className: "h-3.5 w-3.5" }),
101
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs font-medium uppercase tracking-wide", children: label })
102
- ] }),
103
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-2xl font-bold tabular-nums", children: value })
104
- ]
105
- },
106
- label
107
- )) }),
108
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rounded-xl border border-border bg-card/50 p-4 space-y-2", children: [
109
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: [
110
- "30-day volume \xB7 ",
111
- topCurrency
112
- ] }),
113
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: 140, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
114
- import_recharts.BarChart,
115
- {
116
- data: dailyVolume,
117
- margin: { top: 4, right: 4, bottom: 0, left: 0 },
118
- children: [
119
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
- import_recharts.XAxis,
121
- {
122
- dataKey: "label",
123
- tick: { fontSize: 10, fill: "hsl(var(--muted-foreground))" },
124
- axisLine: false,
125
- tickLine: false,
126
- interval: 6
127
- }
128
- ),
129
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
- import_recharts.YAxis,
131
- {
132
- tick: { fontSize: 10, fill: "hsl(var(--muted-foreground))" },
133
- axisLine: false,
134
- tickLine: false,
135
- width: 40
136
- }
137
- ),
138
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
139
- import_recharts.Tooltip,
140
- {
141
- contentStyle: {
142
- background: "hsl(var(--background))",
143
- border: "1px solid hsl(var(--border))",
144
- borderRadius: "8px",
145
- fontSize: "12px",
146
- color: "hsl(var(--foreground))"
147
- },
148
- formatter: (value) => [`${value} ${topCurrency}`, "Volume"]
149
- }
150
- ),
151
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
- import_recharts.Bar,
153
- {
154
- dataKey: "volume",
155
- fill: "hsl(var(--primary))",
156
- radius: [3, 3, 0, 0],
157
- maxBarSize: 24
158
- }
159
- )
160
- ]
161
- }
162
- ) })
163
- ] })
164
- ] });
165
- }
166
- // Annotate the CommonJS export names for ESM import in node:
167
- 0 && (module.exports = {
168
- CreatorAnalytics
169
- });
170
- //# sourceMappingURL=creator-analytics.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/creator-analytics.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport {\n BarChart,\n Bar,\n XAxis,\n YAxis,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\";\nimport type { ApiActivity } from \"@medialane/sdk\";\nimport { TrendingUp, ShoppingBag, Coins } from \"lucide-react\";\n\ninterface CreatorAnalyticsProps {\n activities: ApiActivity[];\n isLoading: boolean;\n}\n\ninterface DayStat {\n label: string;\n volume: number;\n}\n\nfunction parsePrice(formatted: string | null | undefined): number {\n if (!formatted) return 0;\n return parseFloat(formatted.replace(/[^0-9.]/g, \"\")) || 0;\n}\n\nfunction buildDailyVolume(sales: ApiActivity[]): DayStat[] {\n const buckets = new Map<string, number>();\n const now = Date.now();\n\n for (let i = 29; i >= 0; i--) {\n const d = new Date(now - i * 86_400_000);\n buckets.set(\n d.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\" }),\n 0\n );\n }\n for (const s of sales) {\n const ts =\n typeof s.timestamp === \"number\"\n ? s.timestamp * 1000\n : new Date(s.timestamp).getTime();\n if (now - ts > 30 * 86_400_000) continue;\n const label = new Date(ts).toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n });\n buckets.set(label, (buckets.get(label) ?? 0) + parsePrice(s.price?.formatted));\n }\n return Array.from(buckets.entries()).map(([label, volume]) => ({ label, volume }));\n}\n\nexport function CreatorAnalytics({ activities, isLoading }: CreatorAnalyticsProps) {\n const { sales, totalVolume, topCurrency, dailyVolume } = useMemo(() => {\n const sales = activities.filter((a) => a.type === \"sale\");\n\n const byCurrency = new Map<string, number>();\n for (const s of sales) {\n const cur = s.price?.currency ?? \"STRK\";\n byCurrency.set(cur, (byCurrency.get(cur) ?? 0) + parsePrice(s.price?.formatted));\n }\n const sorted = [...byCurrency.entries()].sort((a, b) => b[1] - a[1]);\n const topCurrency = sorted[0]?.[0] ?? \"STRK\";\n const totalVolume = sorted[0]?.[1] ?? 0;\n\n const dailyVolume = buildDailyVolume(\n sales.filter((s) => (s.price?.currency ?? \"STRK\") === topCurrency)\n );\n\n return { sales, totalVolume, topCurrency, dailyVolume };\n }, [activities]);\n\n if (isLoading) {\n return (\n <div className=\"space-y-4 animate-pulse\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-20 rounded-xl bg-muted\" />\n ))}\n </div>\n );\n }\n\n if (sales.length === 0) {\n return (\n <div className=\"py-12 text-center text-sm text-muted-foreground\">\n No sales recorded yet.\n </div>\n );\n }\n\n const stats = [\n {\n label: \"Total Sales\",\n value: sales.length.toString(),\n icon: ShoppingBag,\n },\n {\n label: `Total Volume (${topCurrency})`,\n value: totalVolume.toFixed(2),\n icon: Coins,\n },\n {\n label: \"Last 30 Days\",\n value: `${dailyVolume.filter((d) => d.volume > 0).length} active days`,\n icon: TrendingUp,\n },\n ];\n\n return (\n <div className=\"space-y-6\">\n\n <div className=\"grid grid-cols-1 sm:grid-cols-3 gap-3\">\n {stats.map(({ label, value, icon: Icon }) => (\n <div\n key={label}\n className=\"rounded-xl border border-border bg-card/50 p-4 space-y-1\"\n >\n <div className=\"flex items-center gap-2 text-muted-foreground\">\n <Icon className=\"h-3.5 w-3.5\" />\n <p className=\"text-xs font-medium uppercase tracking-wide\">{label}</p>\n </div>\n <p className=\"text-2xl font-bold tabular-nums\">{value}</p>\n </div>\n ))}\n </div>\n\n <div className=\"rounded-xl border border-border bg-card/50 p-4 space-y-2\">\n <p className=\"text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n 30-day volume · {topCurrency}\n </p>\n <ResponsiveContainer width=\"100%\" height={140}>\n <BarChart\n data={dailyVolume}\n margin={{ top: 4, right: 4, bottom: 0, left: 0 }}\n >\n <XAxis\n dataKey=\"label\"\n tick={{ fontSize: 10, fill: \"hsl(var(--muted-foreground))\" }}\n axisLine={false}\n tickLine={false}\n interval={6}\n />\n <YAxis\n tick={{ fontSize: 10, fill: \"hsl(var(--muted-foreground))\" }}\n axisLine={false}\n tickLine={false}\n width={40}\n />\n <Tooltip\n contentStyle={{\n background: \"hsl(var(--background))\",\n border: \"1px solid hsl(var(--border))\",\n borderRadius: \"8px\",\n fontSize: \"12px\",\n color: \"hsl(var(--foreground))\",\n }}\n formatter={(value) => [`${value} ${topCurrency}`, \"Volume\"]}\n />\n <Bar\n dataKey=\"volume\"\n fill=\"hsl(var(--primary))\"\n radius={[3, 3, 0, 0]}\n maxBarSize={24}\n />\n </BarChart>\n </ResponsiveContainer>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+EU;AA7EV,mBAAwB;AACxB,sBAOO;AAEP,0BAA+C;AAY/C,SAAS,WAAW,WAA8C;AAChE,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,WAAW,UAAU,QAAQ,YAAY,EAAE,CAAC,KAAK;AAC1D;AAEA,SAAS,iBAAiB,OAAiC;AACzD,QAAM,UAAU,oBAAI,IAAoB;AACxC,QAAM,MAAM,KAAK,IAAI;AAErB,WAAS,IAAI,IAAI,KAAK,GAAG,KAAK;AAC5B,UAAM,IAAI,IAAI,KAAK,MAAM,IAAI,KAAU;AACvC,YAAQ;AAAA,MACN,EAAE,mBAAmB,SAAS,EAAE,OAAO,SAAS,KAAK,UAAU,CAAC;AAAA,MACh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AAAA,UACC,MAAM;AAAA,UACN,QAAQ,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE;AAAA,UAE/C;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,MAAM,EAAE,UAAU,IAAI,MAAM,+BAA+B;AAAA,gBAC3D,UAAU;AAAA,gBACV,UAAU;AAAA,gBACV,UAAU;AAAA;AAAA,YACZ;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,MAAM,EAAE,UAAU,IAAI,MAAM,+BAA+B;AAAA,gBAC3D,UAAU;AAAA,gBACV,UAAU;AAAA,gBACV,OAAO;AAAA;AAAA,YACT;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,cAAc;AAAA,kBACZ,YAAY;AAAA,kBACZ,QAAQ;AAAA,kBACR,cAAc;AAAA,kBACd,UAAU;AAAA,kBACV,OAAO;AAAA,gBACT;AAAA,gBACA,WAAW,CAAC,UAAU,CAAC,GAAG,KAAK,IAAI,WAAW,IAAI,QAAQ;AAAA;AAAA,YAC5D;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,gBACnB,YAAY;AAAA;AAAA,YACd;AAAA;AAAA;AAAA,MACF,GACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["sales","topCurrency","totalVolume","dailyVolume"]}
@@ -1,10 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ApiActivity } from '@medialane/sdk';
3
-
4
- interface CreatorAnalyticsProps {
5
- activities: ApiActivity[];
6
- isLoading: boolean;
7
- }
8
- declare function CreatorAnalytics({ activities, isLoading }: CreatorAnalyticsProps): react_jsx_runtime.JSX.Element;
9
-
10
- export { CreatorAnalytics };
@@ -1,10 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ApiActivity } from '@medialane/sdk';
3
-
4
- interface CreatorAnalyticsProps {
5
- activities: ApiActivity[];
6
- isLoading: boolean;
7
- }
8
- declare function CreatorAnalytics({ activities, isLoading }: CreatorAnalyticsProps): react_jsx_runtime.JSX.Element;
9
-
10
- export { CreatorAnalytics };
@@ -1,153 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useMemo } from "react";
4
- import {
5
- BarChart,
6
- Bar,
7
- XAxis,
8
- YAxis,
9
- Tooltip,
10
- ResponsiveContainer
11
- } from "recharts";
12
- import { TrendingUp, ShoppingBag, Coins } from "lucide-react";
13
- function parsePrice(formatted) {
14
- if (!formatted) return 0;
15
- return parseFloat(formatted.replace(/[^0-9.]/g, "")) || 0;
16
- }
17
- function buildDailyVolume(sales) {
18
- const buckets = /* @__PURE__ */ new Map();
19
- const now = Date.now();
20
- for (let i = 29; i >= 0; i--) {
21
- const d = new Date(now - i * 864e5);
22
- buckets.set(
23
- d.toLocaleDateString("en-US", { month: "short", day: "numeric" }),
24
- 0
25
- );
26
- }
27
- for (const s of sales) {
28
- const ts = typeof s.timestamp === "number" ? s.timestamp * 1e3 : new Date(s.timestamp).getTime();
29
- if (now - ts > 30 * 864e5) continue;
30
- const label = new Date(ts).toLocaleDateString("en-US", {
31
- month: "short",
32
- day: "numeric"
33
- });
34
- buckets.set(label, (buckets.get(label) ?? 0) + parsePrice(s.price?.formatted));
35
- }
36
- return Array.from(buckets.entries()).map(([label, volume]) => ({ label, volume }));
37
- }
38
- function CreatorAnalytics({ activities, isLoading }) {
39
- const { sales, totalVolume, topCurrency, dailyVolume } = useMemo(() => {
40
- const sales2 = activities.filter((a) => a.type === "sale");
41
- const byCurrency = /* @__PURE__ */ new Map();
42
- for (const s of sales2) {
43
- const cur = s.price?.currency ?? "STRK";
44
- byCurrency.set(cur, (byCurrency.get(cur) ?? 0) + parsePrice(s.price?.formatted));
45
- }
46
- const sorted = [...byCurrency.entries()].sort((a, b) => b[1] - a[1]);
47
- const topCurrency2 = sorted[0]?.[0] ?? "STRK";
48
- const totalVolume2 = sorted[0]?.[1] ?? 0;
49
- const dailyVolume2 = buildDailyVolume(
50
- sales2.filter((s) => (s.price?.currency ?? "STRK") === topCurrency2)
51
- );
52
- return { sales: sales2, totalVolume: totalVolume2, topCurrency: topCurrency2, dailyVolume: dailyVolume2 };
53
- }, [activities]);
54
- if (isLoading) {
55
- return /* @__PURE__ */ jsx("div", { className: "space-y-4 animate-pulse", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx("div", { className: "h-20 rounded-xl bg-muted" }, i)) });
56
- }
57
- if (sales.length === 0) {
58
- return /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-muted-foreground", children: "No sales recorded yet." });
59
- }
60
- const stats = [
61
- {
62
- label: "Total Sales",
63
- value: sales.length.toString(),
64
- icon: ShoppingBag
65
- },
66
- {
67
- label: `Total Volume (${topCurrency})`,
68
- value: totalVolume.toFixed(2),
69
- icon: Coins
70
- },
71
- {
72
- label: "Last 30 Days",
73
- value: `${dailyVolume.filter((d) => d.volume > 0).length} active days`,
74
- icon: TrendingUp
75
- }
76
- ];
77
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
78
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-3", children: stats.map(({ label, value, icon: Icon }) => /* @__PURE__ */ jsxs(
79
- "div",
80
- {
81
- className: "rounded-xl border border-border bg-card/50 p-4 space-y-1",
82
- children: [
83
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-muted-foreground", children: [
84
- /* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5" }),
85
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium uppercase tracking-wide", children: label })
86
- ] }),
87
- /* @__PURE__ */ jsx("p", { className: "text-2xl font-bold tabular-nums", children: value })
88
- ]
89
- },
90
- label
91
- )) }),
92
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-border bg-card/50 p-4 space-y-2", children: [
93
- /* @__PURE__ */ jsxs("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: [
94
- "30-day volume \xB7 ",
95
- topCurrency
96
- ] }),
97
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 140, children: /* @__PURE__ */ jsxs(
98
- BarChart,
99
- {
100
- data: dailyVolume,
101
- margin: { top: 4, right: 4, bottom: 0, left: 0 },
102
- children: [
103
- /* @__PURE__ */ jsx(
104
- XAxis,
105
- {
106
- dataKey: "label",
107
- tick: { fontSize: 10, fill: "hsl(var(--muted-foreground))" },
108
- axisLine: false,
109
- tickLine: false,
110
- interval: 6
111
- }
112
- ),
113
- /* @__PURE__ */ jsx(
114
- YAxis,
115
- {
116
- tick: { fontSize: 10, fill: "hsl(var(--muted-foreground))" },
117
- axisLine: false,
118
- tickLine: false,
119
- width: 40
120
- }
121
- ),
122
- /* @__PURE__ */ jsx(
123
- Tooltip,
124
- {
125
- contentStyle: {
126
- background: "hsl(var(--background))",
127
- border: "1px solid hsl(var(--border))",
128
- borderRadius: "8px",
129
- fontSize: "12px",
130
- color: "hsl(var(--foreground))"
131
- },
132
- formatter: (value) => [`${value} ${topCurrency}`, "Volume"]
133
- }
134
- ),
135
- /* @__PURE__ */ jsx(
136
- Bar,
137
- {
138
- dataKey: "volume",
139
- fill: "hsl(var(--primary))",
140
- radius: [3, 3, 0, 0],
141
- maxBarSize: 24
142
- }
143
- )
144
- ]
145
- }
146
- ) })
147
- ] })
148
- ] });
149
- }
150
- export {
151
- CreatorAnalytics
152
- };
153
- //# sourceMappingURL=creator-analytics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/creator-analytics.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport {\n BarChart,\n Bar,\n XAxis,\n YAxis,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\";\nimport type { ApiActivity } from \"@medialane/sdk\";\nimport { TrendingUp, ShoppingBag, Coins } from \"lucide-react\";\n\ninterface CreatorAnalyticsProps {\n activities: ApiActivity[];\n isLoading: boolean;\n}\n\ninterface DayStat {\n label: string;\n volume: number;\n}\n\nfunction parsePrice(formatted: string | null | undefined): number {\n if (!formatted) return 0;\n return parseFloat(formatted.replace(/[^0-9.]/g, \"\")) || 0;\n}\n\nfunction buildDailyVolume(sales: ApiActivity[]): DayStat[] {\n const buckets = new Map<string, number>();\n const now = Date.now();\n\n for (let i = 29; i >= 0; i--) {\n const d = new Date(now - i * 86_400_000);\n buckets.set(\n d.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\" }),\n 0\n );\n }\n for (const s of sales) {\n const ts =\n typeof s.timestamp === \"number\"\n ? s.timestamp * 1000\n : new Date(s.timestamp).getTime();\n if (now - ts > 30 * 86_400_000) continue;\n const label = new Date(ts).toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n });\n buckets.set(label, (buckets.get(label) ?? 0) + parsePrice(s.price?.formatted));\n }\n return Array.from(buckets.entries()).map(([label, volume]) => ({ label, volume }));\n}\n\nexport function CreatorAnalytics({ activities, isLoading }: CreatorAnalyticsProps) {\n const { sales, totalVolume, topCurrency, dailyVolume } = useMemo(() => {\n const sales = activities.filter((a) => a.type === \"sale\");\n\n const byCurrency = new Map<string, number>();\n for (const s of sales) {\n const cur = s.price?.currency ?? \"STRK\";\n byCurrency.set(cur, (byCurrency.get(cur) ?? 0) + parsePrice(s.price?.formatted));\n }\n const sorted = [...byCurrency.entries()].sort((a, b) => b[1] - a[1]);\n const topCurrency = sorted[0]?.[0] ?? \"STRK\";\n const totalVolume = sorted[0]?.[1] ?? 0;\n\n const dailyVolume = buildDailyVolume(\n sales.filter((s) => (s.price?.currency ?? \"STRK\") === topCurrency)\n );\n\n return { sales, totalVolume, topCurrency, dailyVolume };\n }, [activities]);\n\n if (isLoading) {\n return (\n <div className=\"space-y-4 animate-pulse\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-20 rounded-xl bg-muted\" />\n ))}\n </div>\n );\n }\n\n if (sales.length === 0) {\n return (\n <div className=\"py-12 text-center text-sm text-muted-foreground\">\n No sales recorded yet.\n </div>\n );\n }\n\n const stats = [\n {\n label: \"Total Sales\",\n value: sales.length.toString(),\n icon: ShoppingBag,\n },\n {\n label: `Total Volume (${topCurrency})`,\n value: totalVolume.toFixed(2),\n icon: Coins,\n },\n {\n label: \"Last 30 Days\",\n value: `${dailyVolume.filter((d) => d.volume > 0).length} active days`,\n icon: TrendingUp,\n },\n ];\n\n return (\n <div className=\"space-y-6\">\n\n <div className=\"grid grid-cols-1 sm:grid-cols-3 gap-3\">\n {stats.map(({ label, value, icon: Icon }) => (\n <div\n key={label}\n className=\"rounded-xl border border-border bg-card/50 p-4 space-y-1\"\n >\n <div className=\"flex items-center gap-2 text-muted-foreground\">\n <Icon className=\"h-3.5 w-3.5\" />\n <p className=\"text-xs font-medium uppercase tracking-wide\">{label}</p>\n </div>\n <p className=\"text-2xl font-bold tabular-nums\">{value}</p>\n </div>\n ))}\n </div>\n\n <div className=\"rounded-xl border border-border bg-card/50 p-4 space-y-2\">\n <p className=\"text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n 30-day volume · {topCurrency}\n </p>\n <ResponsiveContainer width=\"100%\" height={140}>\n <BarChart\n data={dailyVolume}\n margin={{ top: 4, right: 4, bottom: 0, left: 0 }}\n >\n <XAxis\n dataKey=\"label\"\n tick={{ fontSize: 10, fill: \"hsl(var(--muted-foreground))\" }}\n axisLine={false}\n tickLine={false}\n interval={6}\n />\n <YAxis\n tick={{ fontSize: 10, fill: \"hsl(var(--muted-foreground))\" }}\n axisLine={false}\n tickLine={false}\n width={40}\n />\n <Tooltip\n contentStyle={{\n background: \"hsl(var(--background))\",\n border: \"1px solid hsl(var(--border))\",\n borderRadius: \"8px\",\n fontSize: \"12px\",\n color: \"hsl(var(--foreground))\",\n }}\n formatter={(value) => [`${value} ${topCurrency}`, \"Volume\"]}\n />\n <Bar\n dataKey=\"volume\"\n fill=\"hsl(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