@contractspec/example.marketplace 3.7.6 → 3.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -131
- package/dist/browser/entities/index.js +470 -470
- package/dist/browser/index.js +945 -944
- package/dist/browser/order/index.js +155 -155
- package/dist/browser/order/order.event.js +1 -1
- package/dist/browser/payout/index.js +71 -71
- package/dist/browser/payout/payout.event.js +1 -1
- package/dist/browser/product/index.js +104 -104
- package/dist/browser/product/product.event.js +1 -1
- package/dist/browser/review/index.js +75 -75
- package/dist/browser/review/review.event.js +1 -1
- package/dist/browser/store/index.js +68 -68
- package/dist/browser/store/store.event.js +1 -1
- package/dist/browser/ui/MarketplaceDashboard.js +35 -35
- package/dist/browser/ui/hooks/index.js +1 -1
- package/dist/browser/ui/hooks/useMarketplaceData.js +1 -1
- package/dist/browser/ui/index.js +285 -284
- package/dist/entities/index.d.ts +110 -110
- package/dist/entities/index.js +470 -470
- package/dist/index.d.ts +3 -3
- package/dist/index.js +945 -944
- package/dist/node/entities/index.js +470 -470
- package/dist/node/index.js +945 -944
- package/dist/node/order/index.js +155 -155
- package/dist/node/order/order.event.js +1 -1
- package/dist/node/payout/index.js +71 -71
- package/dist/node/payout/payout.event.js +1 -1
- package/dist/node/product/index.js +104 -104
- package/dist/node/product/product.event.js +1 -1
- package/dist/node/review/index.js +75 -75
- package/dist/node/review/review.event.js +1 -1
- package/dist/node/store/index.js +68 -68
- package/dist/node/store/store.event.js +1 -1
- package/dist/node/ui/MarketplaceDashboard.js +35 -35
- package/dist/node/ui/hooks/index.js +1 -1
- package/dist/node/ui/hooks/useMarketplaceData.js +1 -1
- package/dist/node/ui/index.js +285 -284
- package/dist/order/index.d.ts +2 -2
- package/dist/order/index.js +155 -155
- package/dist/order/order.event.js +1 -1
- package/dist/payout/index.d.ts +2 -2
- package/dist/payout/index.js +71 -71
- package/dist/payout/payout.event.js +1 -1
- package/dist/product/index.d.ts +2 -2
- package/dist/product/index.js +104 -104
- package/dist/product/product.event.js +1 -1
- package/dist/review/index.d.ts +2 -2
- package/dist/review/index.js +75 -75
- package/dist/review/review.event.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +68 -68
- package/dist/store/store.event.js +1 -1
- package/dist/ui/MarketplaceDashboard.js +35 -35
- package/dist/ui/hooks/index.d.ts +1 -1
- package/dist/ui/hooks/index.js +1 -1
- package/dist/ui/hooks/useMarketplaceData.js +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +285 -284
- package/dist/ui/renderers/index.d.ts +1 -1
- package/package.json +6 -6
package/dist/node/ui/index.js
CHANGED
|
@@ -1,249 +1,6 @@
|
|
|
1
|
-
// src/ui/renderers/marketplace.markdown.ts
|
|
2
|
-
var mockStores = [
|
|
3
|
-
{
|
|
4
|
-
id: "store-1",
|
|
5
|
-
name: "Tech Gadgets Store",
|
|
6
|
-
status: "ACTIVE",
|
|
7
|
-
productCount: 45,
|
|
8
|
-
rating: 4.8
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
id: "store-2",
|
|
12
|
-
name: "Home & Garden",
|
|
13
|
-
status: "ACTIVE",
|
|
14
|
-
productCount: 120,
|
|
15
|
-
rating: 4.5
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: "store-3",
|
|
19
|
-
name: "Fashion Boutique",
|
|
20
|
-
status: "PENDING",
|
|
21
|
-
productCount: 0,
|
|
22
|
-
rating: 0
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
var mockProducts = [
|
|
26
|
-
{
|
|
27
|
-
id: "prod-1",
|
|
28
|
-
name: "Wireless Earbuds",
|
|
29
|
-
storeId: "store-1",
|
|
30
|
-
price: 79.99,
|
|
31
|
-
currency: "USD",
|
|
32
|
-
status: "ACTIVE",
|
|
33
|
-
stock: 150
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
id: "prod-2",
|
|
37
|
-
name: "Smart Watch",
|
|
38
|
-
storeId: "store-1",
|
|
39
|
-
price: 249.99,
|
|
40
|
-
currency: "USD",
|
|
41
|
-
status: "ACTIVE",
|
|
42
|
-
stock: 50
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: "prod-3",
|
|
46
|
-
name: "Garden Tools Set",
|
|
47
|
-
storeId: "store-2",
|
|
48
|
-
price: 89.99,
|
|
49
|
-
currency: "USD",
|
|
50
|
-
status: "ACTIVE",
|
|
51
|
-
stock: 30
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: "prod-4",
|
|
55
|
-
name: "Indoor Plant Kit",
|
|
56
|
-
storeId: "store-2",
|
|
57
|
-
price: 45.99,
|
|
58
|
-
currency: "USD",
|
|
59
|
-
status: "ACTIVE",
|
|
60
|
-
stock: 75
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: "prod-5",
|
|
64
|
-
name: "LED Desk Lamp",
|
|
65
|
-
storeId: "store-1",
|
|
66
|
-
price: 34.99,
|
|
67
|
-
currency: "USD",
|
|
68
|
-
status: "OUT_OF_STOCK",
|
|
69
|
-
stock: 0
|
|
70
|
-
}
|
|
71
|
-
];
|
|
72
|
-
var mockOrders = [
|
|
73
|
-
{
|
|
74
|
-
id: "ord-1",
|
|
75
|
-
storeId: "store-1",
|
|
76
|
-
customerId: "cust-1",
|
|
77
|
-
total: 329.98,
|
|
78
|
-
currency: "USD",
|
|
79
|
-
status: "DELIVERED",
|
|
80
|
-
itemCount: 2,
|
|
81
|
-
createdAt: "2024-01-15T10:00:00Z"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "ord-2",
|
|
85
|
-
storeId: "store-2",
|
|
86
|
-
customerId: "cust-2",
|
|
87
|
-
total: 135.98,
|
|
88
|
-
currency: "USD",
|
|
89
|
-
status: "SHIPPED",
|
|
90
|
-
itemCount: 2,
|
|
91
|
-
createdAt: "2024-01-14T14:00:00Z"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: "ord-3",
|
|
95
|
-
storeId: "store-1",
|
|
96
|
-
customerId: "cust-3",
|
|
97
|
-
total: 79.99,
|
|
98
|
-
currency: "USD",
|
|
99
|
-
status: "PROCESSING",
|
|
100
|
-
itemCount: 1,
|
|
101
|
-
createdAt: "2024-01-16T08:00:00Z"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: "ord-4",
|
|
105
|
-
storeId: "store-2",
|
|
106
|
-
customerId: "cust-4",
|
|
107
|
-
total: 45.99,
|
|
108
|
-
currency: "USD",
|
|
109
|
-
status: "PENDING",
|
|
110
|
-
itemCount: 1,
|
|
111
|
-
createdAt: "2024-01-16T12:00:00Z"
|
|
112
|
-
}
|
|
113
|
-
];
|
|
114
|
-
function formatCurrency(value, currency = "USD") {
|
|
115
|
-
return new Intl.NumberFormat("en-US", {
|
|
116
|
-
style: "currency",
|
|
117
|
-
currency,
|
|
118
|
-
minimumFractionDigits: 2
|
|
119
|
-
}).format(value);
|
|
120
|
-
}
|
|
121
|
-
var marketplaceDashboardMarkdownRenderer = {
|
|
122
|
-
target: "markdown",
|
|
123
|
-
render: async (desc) => {
|
|
124
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "MarketplaceDashboard") {
|
|
125
|
-
throw new Error("marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard");
|
|
126
|
-
}
|
|
127
|
-
const stores = mockStores;
|
|
128
|
-
const products = mockProducts;
|
|
129
|
-
const orders = mockOrders;
|
|
130
|
-
const activeStores = stores.filter((s) => s.status === "ACTIVE");
|
|
131
|
-
const activeProducts = products.filter((p) => p.status === "ACTIVE");
|
|
132
|
-
const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);
|
|
133
|
-
const pendingOrders = orders.filter((o) => o.status === "PENDING" || o.status === "PROCESSING");
|
|
134
|
-
const lines = [
|
|
135
|
-
"# Marketplace Dashboard",
|
|
136
|
-
"",
|
|
137
|
-
"> Two-sided marketplace overview",
|
|
138
|
-
"",
|
|
139
|
-
"## Summary",
|
|
140
|
-
"",
|
|
141
|
-
"| Metric | Value |",
|
|
142
|
-
"|--------|-------|",
|
|
143
|
-
`| Active Stores | ${activeStores.length} |`,
|
|
144
|
-
`| Active Products | ${activeProducts.length} |`,
|
|
145
|
-
`| Total Orders | ${orders.length} |`,
|
|
146
|
-
`| Total Revenue | ${formatCurrency(totalRevenue)} |`,
|
|
147
|
-
`| Pending Orders | ${pendingOrders.length} |`,
|
|
148
|
-
"",
|
|
149
|
-
"## Top Stores",
|
|
150
|
-
"",
|
|
151
|
-
"| Store | Products | Rating | Status |",
|
|
152
|
-
"|-------|----------|--------|--------|"
|
|
153
|
-
];
|
|
154
|
-
for (const store of stores.slice(0, 5)) {
|
|
155
|
-
lines.push(`| ${store.name} | ${store.productCount} | ⭐ ${store.rating || "N/A"} | ${store.status} |`);
|
|
156
|
-
}
|
|
157
|
-
lines.push("");
|
|
158
|
-
lines.push("## Recent Orders");
|
|
159
|
-
lines.push("");
|
|
160
|
-
lines.push("| Order | Items | Total | Status | Date |");
|
|
161
|
-
lines.push("|-------|-------|-------|--------|------|");
|
|
162
|
-
for (const order of orders.slice(0, 10)) {
|
|
163
|
-
const date = new Date(order.createdAt).toLocaleDateString();
|
|
164
|
-
lines.push(`| ${order.id} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
mimeType: "text/markdown",
|
|
168
|
-
body: lines.join(`
|
|
169
|
-
`)
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var productCatalogMarkdownRenderer = {
|
|
174
|
-
target: "markdown",
|
|
175
|
-
render: async (desc) => {
|
|
176
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "ProductCatalog") {
|
|
177
|
-
throw new Error("productCatalogMarkdownRenderer: not ProductCatalog");
|
|
178
|
-
}
|
|
179
|
-
const products = mockProducts;
|
|
180
|
-
const stores = mockStores;
|
|
181
|
-
const lines = [
|
|
182
|
-
"# Product Catalog",
|
|
183
|
-
"",
|
|
184
|
-
"> Browse products across all marketplace stores",
|
|
185
|
-
""
|
|
186
|
-
];
|
|
187
|
-
for (const store of stores.filter((s) => s.status === "ACTIVE")) {
|
|
188
|
-
const storeProducts = products.filter((p) => p.storeId === store.id);
|
|
189
|
-
if (storeProducts.length === 0)
|
|
190
|
-
continue;
|
|
191
|
-
lines.push(`## ${store.name}`);
|
|
192
|
-
lines.push("");
|
|
193
|
-
lines.push("| Product | Price | Stock | Status |");
|
|
194
|
-
lines.push("|---------|-------|-------|--------|");
|
|
195
|
-
for (const product of storeProducts) {
|
|
196
|
-
const stockStatus = product.stock > 0 ? `${product.stock} in stock` : "Out of stock";
|
|
197
|
-
lines.push(`| ${product.name} | ${formatCurrency(product.price, product.currency)} | ${stockStatus} | ${product.status} |`);
|
|
198
|
-
}
|
|
199
|
-
lines.push("");
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
mimeType: "text/markdown",
|
|
203
|
-
body: lines.join(`
|
|
204
|
-
`)
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
var orderListMarkdownRenderer = {
|
|
209
|
-
target: "markdown",
|
|
210
|
-
render: async (desc) => {
|
|
211
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "OrderList") {
|
|
212
|
-
throw new Error("orderListMarkdownRenderer: not OrderList");
|
|
213
|
-
}
|
|
214
|
-
const orders = mockOrders;
|
|
215
|
-
const stores = mockStores;
|
|
216
|
-
const lines = [
|
|
217
|
-
"# Orders",
|
|
218
|
-
"",
|
|
219
|
-
"> Manage marketplace orders",
|
|
220
|
-
"",
|
|
221
|
-
"| Order ID | Store | Items | Total | Status | Created |",
|
|
222
|
-
"|----------|-------|-------|-------|--------|---------|"
|
|
223
|
-
];
|
|
224
|
-
for (const order of orders) {
|
|
225
|
-
const store = stores.find((s) => s.id === order.storeId);
|
|
226
|
-
const date = new Date(order.createdAt).toLocaleDateString();
|
|
227
|
-
lines.push(`| ${order.id} | ${store?.name ?? "Unknown"} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
|
|
228
|
-
}
|
|
229
|
-
lines.push("");
|
|
230
|
-
lines.push("## Order Status Legend");
|
|
231
|
-
lines.push("");
|
|
232
|
-
lines.push("- **PENDING**: Awaiting payment confirmation");
|
|
233
|
-
lines.push("- **PROCESSING**: Being prepared");
|
|
234
|
-
lines.push("- **SHIPPED**: In transit");
|
|
235
|
-
lines.push("- **DELIVERED**: Order completed");
|
|
236
|
-
lines.push("- **CANCELLED**: Order cancelled");
|
|
237
|
-
return {
|
|
238
|
-
mimeType: "text/markdown",
|
|
239
|
-
body: lines.join(`
|
|
240
|
-
`)
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
1
|
// src/ui/hooks/useMarketplaceData.ts
|
|
245
|
-
import { useCallback, useEffect, useState } from "react";
|
|
246
2
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
247
4
|
"use client";
|
|
248
5
|
function useMarketplaceData(projectId = "local-project") {
|
|
249
6
|
const { handlers } = useTemplateRuntime();
|
|
@@ -295,8 +52,10 @@ function useMarketplaceData(projectId = "local-project") {
|
|
|
295
52
|
};
|
|
296
53
|
}
|
|
297
54
|
|
|
55
|
+
// src/ui/hooks/index.ts
|
|
56
|
+
"use client";
|
|
57
|
+
|
|
298
58
|
// src/ui/MarketplaceDashboard.tsx
|
|
299
|
-
import { useState as useState2 } from "react";
|
|
300
59
|
import {
|
|
301
60
|
Button,
|
|
302
61
|
ErrorState,
|
|
@@ -304,6 +63,7 @@ import {
|
|
|
304
63
|
StatCard,
|
|
305
64
|
StatCardGroup
|
|
306
65
|
} from "@contractspec/lib.design-system";
|
|
66
|
+
import { useState as useState2 } from "react";
|
|
307
67
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
308
68
|
"use client";
|
|
309
69
|
var STATUS_COLORS = {
|
|
@@ -319,7 +79,7 @@ var STATUS_COLORS = {
|
|
|
319
79
|
DELIVERED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
320
80
|
CANCELLED: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
|
|
321
81
|
};
|
|
322
|
-
function
|
|
82
|
+
function formatCurrency(value, currency = "USD") {
|
|
323
83
|
return new Intl.NumberFormat("en-US", {
|
|
324
84
|
style: "currency",
|
|
325
85
|
currency,
|
|
@@ -355,7 +115,7 @@ function MarketplaceDashboard() {
|
|
|
355
115
|
className: "flex items-center justify-between",
|
|
356
116
|
children: [
|
|
357
117
|
/* @__PURE__ */ jsxDEV("h2", {
|
|
358
|
-
className: "text-2xl
|
|
118
|
+
className: "font-bold text-2xl",
|
|
359
119
|
children: "Marketplace"
|
|
360
120
|
}, undefined, false, undefined, this),
|
|
361
121
|
/* @__PURE__ */ jsxDEV(Button, {
|
|
@@ -389,20 +149,20 @@ function MarketplaceDashboard() {
|
|
|
389
149
|
}, undefined, false, undefined, this),
|
|
390
150
|
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
391
151
|
label: "Revenue",
|
|
392
|
-
value:
|
|
152
|
+
value: formatCurrency(stats.totalRevenue),
|
|
393
153
|
hint: "total"
|
|
394
154
|
}, undefined, false, undefined, this)
|
|
395
155
|
]
|
|
396
156
|
}, undefined, true, undefined, this),
|
|
397
157
|
/* @__PURE__ */ jsxDEV("nav", {
|
|
398
|
-
className: "
|
|
158
|
+
className: "flex gap-1 rounded-lg bg-muted p-1",
|
|
399
159
|
role: "tablist",
|
|
400
160
|
children: tabs.map((tab) => /* @__PURE__ */ jsxDEV(Button, {
|
|
401
161
|
type: "button",
|
|
402
162
|
role: "tab",
|
|
403
163
|
"aria-selected": activeTab === tab.id,
|
|
404
164
|
onClick: () => setActiveTab(tab.id),
|
|
405
|
-
className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm
|
|
165
|
+
className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
|
|
406
166
|
children: [
|
|
407
167
|
/* @__PURE__ */ jsxDEV("span", {
|
|
408
168
|
children: tab.icon
|
|
@@ -416,35 +176,35 @@ function MarketplaceDashboard() {
|
|
|
416
176
|
role: "tabpanel",
|
|
417
177
|
children: [
|
|
418
178
|
activeTab === "stores" && /* @__PURE__ */ jsxDEV("div", {
|
|
419
|
-
className: "
|
|
179
|
+
className: "rounded-lg border border-border",
|
|
420
180
|
children: /* @__PURE__ */ jsxDEV("table", {
|
|
421
181
|
className: "w-full",
|
|
422
182
|
children: [
|
|
423
183
|
/* @__PURE__ */ jsxDEV("thead", {
|
|
424
|
-
className: "border-border bg-muted/30
|
|
184
|
+
className: "border-border border-b bg-muted/30",
|
|
425
185
|
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
426
186
|
children: [
|
|
427
187
|
/* @__PURE__ */ jsxDEV("th", {
|
|
428
|
-
className: "px-4 py-3 text-left text-sm
|
|
188
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
429
189
|
children: "Store"
|
|
430
190
|
}, undefined, false, undefined, this),
|
|
431
191
|
/* @__PURE__ */ jsxDEV("th", {
|
|
432
|
-
className: "px-4 py-3 text-left text-sm
|
|
192
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
433
193
|
children: "Status"
|
|
434
194
|
}, undefined, false, undefined, this),
|
|
435
195
|
/* @__PURE__ */ jsxDEV("th", {
|
|
436
|
-
className: "px-4 py-3 text-left text-sm
|
|
196
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
437
197
|
children: "Rating"
|
|
438
198
|
}, undefined, false, undefined, this),
|
|
439
199
|
/* @__PURE__ */ jsxDEV("th", {
|
|
440
|
-
className: "px-4 py-3 text-left text-sm
|
|
200
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
441
201
|
children: "Reviews"
|
|
442
202
|
}, undefined, false, undefined, this)
|
|
443
203
|
]
|
|
444
204
|
}, undefined, true, undefined, this)
|
|
445
205
|
}, undefined, false, undefined, this),
|
|
446
206
|
/* @__PURE__ */ jsxDEV("tbody", {
|
|
447
|
-
className: "divide-
|
|
207
|
+
className: "divide-y divide-border",
|
|
448
208
|
children: [
|
|
449
209
|
stores.map((store) => /* @__PURE__ */ jsxDEV("tr", {
|
|
450
210
|
className: "hover:bg-muted/50",
|
|
@@ -465,7 +225,7 @@ function MarketplaceDashboard() {
|
|
|
465
225
|
/* @__PURE__ */ jsxDEV("td", {
|
|
466
226
|
className: "px-4 py-3",
|
|
467
227
|
children: /* @__PURE__ */ jsxDEV("span", {
|
|
468
|
-
className: `inline-flex rounded-full px-2 py-0.5 text-xs
|
|
228
|
+
className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[store.status] ?? ""}`,
|
|
469
229
|
children: store.status
|
|
470
230
|
}, undefined, false, undefined, this)
|
|
471
231
|
}, undefined, false, undefined, this),
|
|
@@ -480,7 +240,7 @@ function MarketplaceDashboard() {
|
|
|
480
240
|
}, undefined, true, undefined, this)
|
|
481
241
|
}, undefined, false, undefined, this),
|
|
482
242
|
/* @__PURE__ */ jsxDEV("td", {
|
|
483
|
-
className: "
|
|
243
|
+
className: "px-4 py-3 text-muted-foreground text-sm",
|
|
484
244
|
children: [
|
|
485
245
|
store.reviewCount,
|
|
486
246
|
" reviews"
|
|
@@ -491,7 +251,7 @@ function MarketplaceDashboard() {
|
|
|
491
251
|
stores.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
492
252
|
children: /* @__PURE__ */ jsxDEV("td", {
|
|
493
253
|
colSpan: 4,
|
|
494
|
-
className: "
|
|
254
|
+
className: "px-4 py-8 text-center text-muted-foreground",
|
|
495
255
|
children: "No stores found"
|
|
496
256
|
}, undefined, false, undefined, this)
|
|
497
257
|
}, undefined, false, undefined, this)
|
|
@@ -501,35 +261,35 @@ function MarketplaceDashboard() {
|
|
|
501
261
|
}, undefined, true, undefined, this)
|
|
502
262
|
}, undefined, false, undefined, this),
|
|
503
263
|
activeTab === "products" && /* @__PURE__ */ jsxDEV("div", {
|
|
504
|
-
className: "
|
|
264
|
+
className: "rounded-lg border border-border",
|
|
505
265
|
children: /* @__PURE__ */ jsxDEV("table", {
|
|
506
266
|
className: "w-full",
|
|
507
267
|
children: [
|
|
508
268
|
/* @__PURE__ */ jsxDEV("thead", {
|
|
509
|
-
className: "border-border bg-muted/30
|
|
269
|
+
className: "border-border border-b bg-muted/30",
|
|
510
270
|
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
511
271
|
children: [
|
|
512
272
|
/* @__PURE__ */ jsxDEV("th", {
|
|
513
|
-
className: "px-4 py-3 text-left text-sm
|
|
273
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
514
274
|
children: "Product"
|
|
515
275
|
}, undefined, false, undefined, this),
|
|
516
276
|
/* @__PURE__ */ jsxDEV("th", {
|
|
517
|
-
className: "px-4 py-3 text-left text-sm
|
|
277
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
518
278
|
children: "Price"
|
|
519
279
|
}, undefined, false, undefined, this),
|
|
520
280
|
/* @__PURE__ */ jsxDEV("th", {
|
|
521
|
-
className: "px-4 py-3 text-left text-sm
|
|
281
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
522
282
|
children: "Stock"
|
|
523
283
|
}, undefined, false, undefined, this),
|
|
524
284
|
/* @__PURE__ */ jsxDEV("th", {
|
|
525
|
-
className: "px-4 py-3 text-left text-sm
|
|
285
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
526
286
|
children: "Status"
|
|
527
287
|
}, undefined, false, undefined, this)
|
|
528
288
|
]
|
|
529
289
|
}, undefined, true, undefined, this)
|
|
530
290
|
}, undefined, false, undefined, this),
|
|
531
291
|
/* @__PURE__ */ jsxDEV("tbody", {
|
|
532
|
-
className: "divide-
|
|
292
|
+
className: "divide-y divide-border",
|
|
533
293
|
children: [
|
|
534
294
|
products.map((product) => /* @__PURE__ */ jsxDEV("tr", {
|
|
535
295
|
className: "hover:bg-muted/50",
|
|
@@ -549,7 +309,7 @@ function MarketplaceDashboard() {
|
|
|
549
309
|
}, undefined, true, undefined, this),
|
|
550
310
|
/* @__PURE__ */ jsxDEV("td", {
|
|
551
311
|
className: "px-4 py-3 font-mono",
|
|
552
|
-
children:
|
|
312
|
+
children: formatCurrency(product.price, product.currency)
|
|
553
313
|
}, undefined, false, undefined, this),
|
|
554
314
|
/* @__PURE__ */ jsxDEV("td", {
|
|
555
315
|
className: "px-4 py-3",
|
|
@@ -558,7 +318,7 @@ function MarketplaceDashboard() {
|
|
|
558
318
|
/* @__PURE__ */ jsxDEV("td", {
|
|
559
319
|
className: "px-4 py-3",
|
|
560
320
|
children: /* @__PURE__ */ jsxDEV("span", {
|
|
561
|
-
className: `inline-flex rounded-full px-2 py-0.5 text-xs
|
|
321
|
+
className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[product.status] ?? ""}`,
|
|
562
322
|
children: product.status
|
|
563
323
|
}, undefined, false, undefined, this)
|
|
564
324
|
}, undefined, false, undefined, this)
|
|
@@ -567,7 +327,7 @@ function MarketplaceDashboard() {
|
|
|
567
327
|
products.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
568
328
|
children: /* @__PURE__ */ jsxDEV("td", {
|
|
569
329
|
colSpan: 4,
|
|
570
|
-
className: "
|
|
330
|
+
className: "px-4 py-8 text-center text-muted-foreground",
|
|
571
331
|
children: "No products found"
|
|
572
332
|
}, undefined, false, undefined, this)
|
|
573
333
|
}, undefined, false, undefined, this)
|
|
@@ -577,39 +337,39 @@ function MarketplaceDashboard() {
|
|
|
577
337
|
}, undefined, true, undefined, this)
|
|
578
338
|
}, undefined, false, undefined, this),
|
|
579
339
|
activeTab === "orders" && /* @__PURE__ */ jsxDEV("div", {
|
|
580
|
-
className: "
|
|
340
|
+
className: "rounded-lg border border-border",
|
|
581
341
|
children: /* @__PURE__ */ jsxDEV("table", {
|
|
582
342
|
className: "w-full",
|
|
583
343
|
children: [
|
|
584
344
|
/* @__PURE__ */ jsxDEV("thead", {
|
|
585
|
-
className: "border-border bg-muted/30
|
|
345
|
+
className: "border-border border-b bg-muted/30",
|
|
586
346
|
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
587
347
|
children: [
|
|
588
348
|
/* @__PURE__ */ jsxDEV("th", {
|
|
589
|
-
className: "px-4 py-3 text-left text-sm
|
|
349
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
590
350
|
children: "Order ID"
|
|
591
351
|
}, undefined, false, undefined, this),
|
|
592
352
|
/* @__PURE__ */ jsxDEV("th", {
|
|
593
|
-
className: "px-4 py-3 text-left text-sm
|
|
353
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
594
354
|
children: "Customer"
|
|
595
355
|
}, undefined, false, undefined, this),
|
|
596
356
|
/* @__PURE__ */ jsxDEV("th", {
|
|
597
|
-
className: "px-4 py-3 text-left text-sm
|
|
357
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
598
358
|
children: "Total"
|
|
599
359
|
}, undefined, false, undefined, this),
|
|
600
360
|
/* @__PURE__ */ jsxDEV("th", {
|
|
601
|
-
className: "px-4 py-3 text-left text-sm
|
|
361
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
602
362
|
children: "Status"
|
|
603
363
|
}, undefined, false, undefined, this),
|
|
604
364
|
/* @__PURE__ */ jsxDEV("th", {
|
|
605
|
-
className: "px-4 py-3 text-left text-sm
|
|
365
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
606
366
|
children: "Date"
|
|
607
367
|
}, undefined, false, undefined, this)
|
|
608
368
|
]
|
|
609
369
|
}, undefined, true, undefined, this)
|
|
610
370
|
}, undefined, false, undefined, this),
|
|
611
371
|
/* @__PURE__ */ jsxDEV("tbody", {
|
|
612
|
-
className: "divide-
|
|
372
|
+
className: "divide-y divide-border",
|
|
613
373
|
children: [
|
|
614
374
|
orders.map((order) => /* @__PURE__ */ jsxDEV("tr", {
|
|
615
375
|
className: "hover:bg-muted/50",
|
|
@@ -624,17 +384,17 @@ function MarketplaceDashboard() {
|
|
|
624
384
|
}, undefined, false, undefined, this),
|
|
625
385
|
/* @__PURE__ */ jsxDEV("td", {
|
|
626
386
|
className: "px-4 py-3 font-mono",
|
|
627
|
-
children:
|
|
387
|
+
children: formatCurrency(order.total, order.currency)
|
|
628
388
|
}, undefined, false, undefined, this),
|
|
629
389
|
/* @__PURE__ */ jsxDEV("td", {
|
|
630
390
|
className: "px-4 py-3",
|
|
631
391
|
children: /* @__PURE__ */ jsxDEV("span", {
|
|
632
|
-
className: `inline-flex rounded-full px-2 py-0.5 text-xs
|
|
392
|
+
className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[order.status] ?? ""}`,
|
|
633
393
|
children: order.status
|
|
634
394
|
}, undefined, false, undefined, this)
|
|
635
395
|
}, undefined, false, undefined, this),
|
|
636
396
|
/* @__PURE__ */ jsxDEV("td", {
|
|
637
|
-
className: "
|
|
397
|
+
className: "px-4 py-3 text-muted-foreground text-sm",
|
|
638
398
|
children: order.createdAt.toLocaleDateString()
|
|
639
399
|
}, undefined, false, undefined, this)
|
|
640
400
|
]
|
|
@@ -642,7 +402,7 @@ function MarketplaceDashboard() {
|
|
|
642
402
|
orders.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
643
403
|
children: /* @__PURE__ */ jsxDEV("td", {
|
|
644
404
|
colSpan: 5,
|
|
645
|
-
className: "
|
|
405
|
+
className: "px-4 py-8 text-center text-muted-foreground",
|
|
646
406
|
children: "No orders found"
|
|
647
407
|
}, undefined, false, undefined, this)
|
|
648
408
|
}, undefined, false, undefined, this)
|
|
@@ -657,8 +417,249 @@ function MarketplaceDashboard() {
|
|
|
657
417
|
}, undefined, true, undefined, this);
|
|
658
418
|
}
|
|
659
419
|
|
|
660
|
-
// src/ui/
|
|
661
|
-
|
|
420
|
+
// src/ui/renderers/marketplace.markdown.ts
|
|
421
|
+
var mockStores = [
|
|
422
|
+
{
|
|
423
|
+
id: "store-1",
|
|
424
|
+
name: "Tech Gadgets Store",
|
|
425
|
+
status: "ACTIVE",
|
|
426
|
+
productCount: 45,
|
|
427
|
+
rating: 4.8
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
id: "store-2",
|
|
431
|
+
name: "Home & Garden",
|
|
432
|
+
status: "ACTIVE",
|
|
433
|
+
productCount: 120,
|
|
434
|
+
rating: 4.5
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "store-3",
|
|
438
|
+
name: "Fashion Boutique",
|
|
439
|
+
status: "PENDING",
|
|
440
|
+
productCount: 0,
|
|
441
|
+
rating: 0
|
|
442
|
+
}
|
|
443
|
+
];
|
|
444
|
+
var mockProducts = [
|
|
445
|
+
{
|
|
446
|
+
id: "prod-1",
|
|
447
|
+
name: "Wireless Earbuds",
|
|
448
|
+
storeId: "store-1",
|
|
449
|
+
price: 79.99,
|
|
450
|
+
currency: "USD",
|
|
451
|
+
status: "ACTIVE",
|
|
452
|
+
stock: 150
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
id: "prod-2",
|
|
456
|
+
name: "Smart Watch",
|
|
457
|
+
storeId: "store-1",
|
|
458
|
+
price: 249.99,
|
|
459
|
+
currency: "USD",
|
|
460
|
+
status: "ACTIVE",
|
|
461
|
+
stock: 50
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: "prod-3",
|
|
465
|
+
name: "Garden Tools Set",
|
|
466
|
+
storeId: "store-2",
|
|
467
|
+
price: 89.99,
|
|
468
|
+
currency: "USD",
|
|
469
|
+
status: "ACTIVE",
|
|
470
|
+
stock: 30
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
id: "prod-4",
|
|
474
|
+
name: "Indoor Plant Kit",
|
|
475
|
+
storeId: "store-2",
|
|
476
|
+
price: 45.99,
|
|
477
|
+
currency: "USD",
|
|
478
|
+
status: "ACTIVE",
|
|
479
|
+
stock: 75
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
id: "prod-5",
|
|
483
|
+
name: "LED Desk Lamp",
|
|
484
|
+
storeId: "store-1",
|
|
485
|
+
price: 34.99,
|
|
486
|
+
currency: "USD",
|
|
487
|
+
status: "OUT_OF_STOCK",
|
|
488
|
+
stock: 0
|
|
489
|
+
}
|
|
490
|
+
];
|
|
491
|
+
var mockOrders = [
|
|
492
|
+
{
|
|
493
|
+
id: "ord-1",
|
|
494
|
+
storeId: "store-1",
|
|
495
|
+
customerId: "cust-1",
|
|
496
|
+
total: 329.98,
|
|
497
|
+
currency: "USD",
|
|
498
|
+
status: "DELIVERED",
|
|
499
|
+
itemCount: 2,
|
|
500
|
+
createdAt: "2024-01-15T10:00:00Z"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
id: "ord-2",
|
|
504
|
+
storeId: "store-2",
|
|
505
|
+
customerId: "cust-2",
|
|
506
|
+
total: 135.98,
|
|
507
|
+
currency: "USD",
|
|
508
|
+
status: "SHIPPED",
|
|
509
|
+
itemCount: 2,
|
|
510
|
+
createdAt: "2024-01-14T14:00:00Z"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
id: "ord-3",
|
|
514
|
+
storeId: "store-1",
|
|
515
|
+
customerId: "cust-3",
|
|
516
|
+
total: 79.99,
|
|
517
|
+
currency: "USD",
|
|
518
|
+
status: "PROCESSING",
|
|
519
|
+
itemCount: 1,
|
|
520
|
+
createdAt: "2024-01-16T08:00:00Z"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: "ord-4",
|
|
524
|
+
storeId: "store-2",
|
|
525
|
+
customerId: "cust-4",
|
|
526
|
+
total: 45.99,
|
|
527
|
+
currency: "USD",
|
|
528
|
+
status: "PENDING",
|
|
529
|
+
itemCount: 1,
|
|
530
|
+
createdAt: "2024-01-16T12:00:00Z"
|
|
531
|
+
}
|
|
532
|
+
];
|
|
533
|
+
function formatCurrency2(value, currency = "USD") {
|
|
534
|
+
return new Intl.NumberFormat("en-US", {
|
|
535
|
+
style: "currency",
|
|
536
|
+
currency,
|
|
537
|
+
minimumFractionDigits: 2
|
|
538
|
+
}).format(value);
|
|
539
|
+
}
|
|
540
|
+
var marketplaceDashboardMarkdownRenderer = {
|
|
541
|
+
target: "markdown",
|
|
542
|
+
render: async (desc) => {
|
|
543
|
+
if (desc.source.type !== "component" || desc.source.componentKey !== "MarketplaceDashboard") {
|
|
544
|
+
throw new Error("marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard");
|
|
545
|
+
}
|
|
546
|
+
const stores = mockStores;
|
|
547
|
+
const products = mockProducts;
|
|
548
|
+
const orders = mockOrders;
|
|
549
|
+
const activeStores = stores.filter((s) => s.status === "ACTIVE");
|
|
550
|
+
const activeProducts = products.filter((p) => p.status === "ACTIVE");
|
|
551
|
+
const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);
|
|
552
|
+
const pendingOrders = orders.filter((o) => o.status === "PENDING" || o.status === "PROCESSING");
|
|
553
|
+
const lines = [
|
|
554
|
+
"# Marketplace Dashboard",
|
|
555
|
+
"",
|
|
556
|
+
"> Two-sided marketplace overview",
|
|
557
|
+
"",
|
|
558
|
+
"## Summary",
|
|
559
|
+
"",
|
|
560
|
+
"| Metric | Value |",
|
|
561
|
+
"|--------|-------|",
|
|
562
|
+
`| Active Stores | ${activeStores.length} |`,
|
|
563
|
+
`| Active Products | ${activeProducts.length} |`,
|
|
564
|
+
`| Total Orders | ${orders.length} |`,
|
|
565
|
+
`| Total Revenue | ${formatCurrency2(totalRevenue)} |`,
|
|
566
|
+
`| Pending Orders | ${pendingOrders.length} |`,
|
|
567
|
+
"",
|
|
568
|
+
"## Top Stores",
|
|
569
|
+
"",
|
|
570
|
+
"| Store | Products | Rating | Status |",
|
|
571
|
+
"|-------|----------|--------|--------|"
|
|
572
|
+
];
|
|
573
|
+
for (const store of stores.slice(0, 5)) {
|
|
574
|
+
lines.push(`| ${store.name} | ${store.productCount} | ⭐ ${store.rating || "N/A"} | ${store.status} |`);
|
|
575
|
+
}
|
|
576
|
+
lines.push("");
|
|
577
|
+
lines.push("## Recent Orders");
|
|
578
|
+
lines.push("");
|
|
579
|
+
lines.push("| Order | Items | Total | Status | Date |");
|
|
580
|
+
lines.push("|-------|-------|-------|--------|------|");
|
|
581
|
+
for (const order of orders.slice(0, 10)) {
|
|
582
|
+
const date = new Date(order.createdAt).toLocaleDateString();
|
|
583
|
+
lines.push(`| ${order.id} | ${order.itemCount} | ${formatCurrency2(order.total, order.currency)} | ${order.status} | ${date} |`);
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
mimeType: "text/markdown",
|
|
587
|
+
body: lines.join(`
|
|
588
|
+
`)
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
var productCatalogMarkdownRenderer = {
|
|
593
|
+
target: "markdown",
|
|
594
|
+
render: async (desc) => {
|
|
595
|
+
if (desc.source.type !== "component" || desc.source.componentKey !== "ProductCatalog") {
|
|
596
|
+
throw new Error("productCatalogMarkdownRenderer: not ProductCatalog");
|
|
597
|
+
}
|
|
598
|
+
const products = mockProducts;
|
|
599
|
+
const stores = mockStores;
|
|
600
|
+
const lines = [
|
|
601
|
+
"# Product Catalog",
|
|
602
|
+
"",
|
|
603
|
+
"> Browse products across all marketplace stores",
|
|
604
|
+
""
|
|
605
|
+
];
|
|
606
|
+
for (const store of stores.filter((s) => s.status === "ACTIVE")) {
|
|
607
|
+
const storeProducts = products.filter((p) => p.storeId === store.id);
|
|
608
|
+
if (storeProducts.length === 0)
|
|
609
|
+
continue;
|
|
610
|
+
lines.push(`## ${store.name}`);
|
|
611
|
+
lines.push("");
|
|
612
|
+
lines.push("| Product | Price | Stock | Status |");
|
|
613
|
+
lines.push("|---------|-------|-------|--------|");
|
|
614
|
+
for (const product of storeProducts) {
|
|
615
|
+
const stockStatus = product.stock > 0 ? `${product.stock} in stock` : "Out of stock";
|
|
616
|
+
lines.push(`| ${product.name} | ${formatCurrency2(product.price, product.currency)} | ${stockStatus} | ${product.status} |`);
|
|
617
|
+
}
|
|
618
|
+
lines.push("");
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
mimeType: "text/markdown",
|
|
622
|
+
body: lines.join(`
|
|
623
|
+
`)
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
var orderListMarkdownRenderer = {
|
|
628
|
+
target: "markdown",
|
|
629
|
+
render: async (desc) => {
|
|
630
|
+
if (desc.source.type !== "component" || desc.source.componentKey !== "OrderList") {
|
|
631
|
+
throw new Error("orderListMarkdownRenderer: not OrderList");
|
|
632
|
+
}
|
|
633
|
+
const orders = mockOrders;
|
|
634
|
+
const stores = mockStores;
|
|
635
|
+
const lines = [
|
|
636
|
+
"# Orders",
|
|
637
|
+
"",
|
|
638
|
+
"> Manage marketplace orders",
|
|
639
|
+
"",
|
|
640
|
+
"| Order ID | Store | Items | Total | Status | Created |",
|
|
641
|
+
"|----------|-------|-------|-------|--------|---------|"
|
|
642
|
+
];
|
|
643
|
+
for (const order of orders) {
|
|
644
|
+
const store = stores.find((s) => s.id === order.storeId);
|
|
645
|
+
const date = new Date(order.createdAt).toLocaleDateString();
|
|
646
|
+
lines.push(`| ${order.id} | ${store?.name ?? "Unknown"} | ${order.itemCount} | ${formatCurrency2(order.total, order.currency)} | ${order.status} | ${date} |`);
|
|
647
|
+
}
|
|
648
|
+
lines.push("");
|
|
649
|
+
lines.push("## Order Status Legend");
|
|
650
|
+
lines.push("");
|
|
651
|
+
lines.push("- **PENDING**: Awaiting payment confirmation");
|
|
652
|
+
lines.push("- **PROCESSING**: Being prepared");
|
|
653
|
+
lines.push("- **SHIPPED**: In transit");
|
|
654
|
+
lines.push("- **DELIVERED**: Order completed");
|
|
655
|
+
lines.push("- **CANCELLED**: Order cancelled");
|
|
656
|
+
return {
|
|
657
|
+
mimeType: "text/markdown",
|
|
658
|
+
body: lines.join(`
|
|
659
|
+
`)
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
};
|
|
662
663
|
export {
|
|
663
664
|
useMarketplaceData,
|
|
664
665
|
productCatalogMarkdownRenderer,
|