@actuate-media/plugin-commerce 0.0.1
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/dist/admin/CommerceDashboard.d.ts +35 -0
- package/dist/admin/CommerceDashboard.d.ts.map +1 -0
- package/dist/admin/CommerceDashboard.js +20 -0
- package/dist/admin/CommerceDashboard.js.map +1 -0
- package/dist/admin/DiscountManager.d.ts +24 -0
- package/dist/admin/DiscountManager.d.ts.map +1 -0
- package/dist/admin/DiscountManager.js +53 -0
- package/dist/admin/DiscountManager.js.map +1 -0
- package/dist/admin/OrderDetail.d.ts +62 -0
- package/dist/admin/OrderDetail.d.ts.map +1 -0
- package/dist/admin/OrderDetail.js +26 -0
- package/dist/admin/OrderDetail.js.map +1 -0
- package/dist/admin/OrderList.d.ts +29 -0
- package/dist/admin/OrderList.d.ts.map +1 -0
- package/dist/admin/OrderList.js +30 -0
- package/dist/admin/OrderList.js.map +1 -0
- package/dist/admin/ProductEdit.d.ts +43 -0
- package/dist/admin/ProductEdit.d.ts.map +1 -0
- package/dist/admin/ProductEdit.js +58 -0
- package/dist/admin/ProductEdit.js.map +1 -0
- package/dist/admin/ProductList.d.ts +21 -0
- package/dist/admin/ProductList.d.ts.map +1 -0
- package/dist/admin/ProductList.js +29 -0
- package/dist/admin/ProductList.js.map +1 -0
- package/dist/client.d.ts +107 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +70 -0
- package/dist/client.js.map +1 -0
- package/dist/collections.d.ts +4 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +341 -0
- package/dist/collections.js.map +1 -0
- package/dist/fields.d.ts +4 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +3 -0
- package/dist/fields.js.map +1 -0
- package/dist/hooks.d.ts +5 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +32 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/stripe/checkout.d.ts +29 -0
- package/dist/stripe/checkout.d.ts.map +1 -0
- package/dist/stripe/checkout.js +48 -0
- package/dist/stripe/checkout.js.map +1 -0
- package/dist/stripe/customer.d.ts +11 -0
- package/dist/stripe/customer.d.ts.map +1 -0
- package/dist/stripe/customer.js +22 -0
- package/dist/stripe/customer.js.map +1 -0
- package/dist/stripe/products.d.ts +25 -0
- package/dist/stripe/products.d.ts.map +1 -0
- package/dist/stripe/products.js +27 -0
- package/dist/stripe/products.js.map +1 -0
- package/dist/stripe/webhooks.d.ts +8 -0
- package/dist/stripe/webhooks.d.ts.map +1 -0
- package/dist/stripe/webhooks.js +52 -0
- package/dist/stripe/webhooks.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface RevenueData {
|
|
3
|
+
totalRevenue: number;
|
|
4
|
+
revenueToday: number;
|
|
5
|
+
revenueThisWeek: number;
|
|
6
|
+
revenueThisMonth: number;
|
|
7
|
+
currency: string;
|
|
8
|
+
dailyRevenue: Array<{
|
|
9
|
+
date: string;
|
|
10
|
+
amount: number;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export interface OrderStats {
|
|
14
|
+
totalOrders: number;
|
|
15
|
+
pendingOrders: number;
|
|
16
|
+
processingOrders: number;
|
|
17
|
+
shippedOrders: number;
|
|
18
|
+
averageOrderValue: number;
|
|
19
|
+
conversionRate: number;
|
|
20
|
+
}
|
|
21
|
+
export interface TopProduct {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
unitsSold: number;
|
|
25
|
+
revenue: number;
|
|
26
|
+
image?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CommerceDashboardProps {
|
|
29
|
+
revenue: RevenueData;
|
|
30
|
+
orders: OrderStats;
|
|
31
|
+
topProducts: TopProduct[];
|
|
32
|
+
}
|
|
33
|
+
/** Commerce overview dashboard with revenue metrics, order stats, and top products. */
|
|
34
|
+
export declare function CommerceDashboard({ revenue, orders, topProducts, }: CommerceDashboardProps): React.ReactElement;
|
|
35
|
+
//# sourceMappingURL=CommerceDashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommerceDashboard.d.ts","sourceRoot":"","sources":["../../src/admin/CommerceDashboard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAgBD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,WAAW,GACZ,EAAE,sBAAsB,GAAG,KAAK,CAAC,YAAY,CAyF7C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
function formatCurrency(amount, currency) {
|
|
4
|
+
return new Intl.NumberFormat("en-US", { style: "currency", currency }).format(amount);
|
|
5
|
+
}
|
|
6
|
+
function StatCard({ label, value, subtext }) {
|
|
7
|
+
return (_jsxs("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 8, padding: 16 }, children: [_jsx("div", { style: { fontSize: 13, color: "#6b7280", marginBottom: 4 }, children: label }), _jsx("div", { style: { fontSize: 24, fontWeight: 700 }, children: value }), subtext && _jsx("div", { style: { fontSize: 12, color: "#9ca3af", marginTop: 4 }, children: subtext })] }));
|
|
8
|
+
}
|
|
9
|
+
/** Commerce overview dashboard with revenue metrics, order stats, and top products. */
|
|
10
|
+
export function CommerceDashboard({ revenue, orders, topProducts, }) {
|
|
11
|
+
const maxDailyRevenue = Math.max(...revenue.dailyRevenue.map((d) => d.amount), 1);
|
|
12
|
+
return (_jsxs("div", { children: [_jsx("h2", { style: { marginBottom: 24 }, children: "Commerce Dashboard" }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16, marginBottom: 32 }, children: [_jsx(StatCard, { label: "Total Revenue", value: formatCurrency(revenue.totalRevenue, revenue.currency) }), _jsx(StatCard, { label: "Today", value: formatCurrency(revenue.revenueToday, revenue.currency) }), _jsx(StatCard, { label: "This Week", value: formatCurrency(revenue.revenueThisWeek, revenue.currency) }), _jsx(StatCard, { label: "This Month", value: formatCurrency(revenue.revenueThisMonth, revenue.currency) })] }), _jsxs("div", { style: { border: "1px solid #e5e7eb", borderRadius: 8, padding: 16, marginBottom: 32 }, children: [_jsx("h3", { style: { marginTop: 0 }, children: "Daily Revenue" }), _jsx("div", { style: { display: "flex", alignItems: "flex-end", gap: 4, height: 120 }, children: revenue.dailyRevenue.map((day) => (_jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", alignItems: "center" }, children: [_jsx("div", { style: {
|
|
13
|
+
width: "100%",
|
|
14
|
+
background: "#3b82f6",
|
|
15
|
+
borderRadius: "4px 4px 0 0",
|
|
16
|
+
height: `${(day.amount / maxDailyRevenue) * 100}px`,
|
|
17
|
+
minHeight: 2,
|
|
18
|
+
}, title: `${day.date}: ${formatCurrency(day.amount, revenue.currency)}` }), _jsx("div", { style: { fontSize: 9, color: "#9ca3af", marginTop: 4, transform: "rotate(-45deg)", whiteSpace: "nowrap" }, children: day.date.slice(5) })] }, day.date))) })] }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16, marginBottom: 32 }, children: [_jsx(StatCard, { label: "Total Orders", value: String(orders.totalOrders) }), _jsx(StatCard, { label: "Avg Order Value", value: formatCurrency(orders.averageOrderValue, revenue.currency) }), _jsx(StatCard, { label: "Conversion Rate", value: `${(orders.conversionRate * 100).toFixed(1)}%` }), _jsx(StatCard, { label: "Pending", value: String(orders.pendingOrders) }), _jsx(StatCard, { label: "Processing", value: String(orders.processingOrders) }), _jsx(StatCard, { label: "Shipped", value: String(orders.shippedOrders) })] }), _jsxs("div", { style: { border: "1px solid #e5e7eb", borderRadius: 8, padding: 16 }, children: [_jsx("h3", { style: { marginTop: 0 }, children: "Top Products" }), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", padding: 8 }, children: "Product" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Units Sold" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Revenue" })] }) }), _jsx("tbody", { children: topProducts.map((product, index) => (_jsxs("tr", { style: { borderTop: "1px solid #f3f4f6" }, children: [_jsx("td", { style: { padding: 8 }, children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [_jsxs("span", { style: { fontWeight: 600, color: "#6b7280", width: 20 }, children: [index + 1, "."] }), product.image && (_jsx("img", { src: product.image, alt: product.name, style: { width: 32, height: 32, borderRadius: 4, objectFit: "cover" } })), _jsx("span", { style: { fontWeight: 500 }, children: product.name })] }) }), _jsx("td", { style: { textAlign: "right", padding: 8 }, children: product.unitsSold }), _jsx("td", { style: { textAlign: "right", padding: 8, fontWeight: 500 }, children: formatCurrency(product.revenue, revenue.currency) })] }, product.id))) })] })] })] }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=CommerceDashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommerceDashboard.js","sourceRoot":"","sources":["../../src/admin/CommerceDashboard.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAoCb,SAAS,cAAc,CAAC,MAAc,EAAE,QAAgB;IACtD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACxF,CAAC;AAED,SAAS,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAsD;IAC7F,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,aAC3F,cAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,EAAE,YAAG,KAAK,GAAO,EAC9E,cAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,YAAG,KAAK,GAAO,EAC3D,OAAO,IAAI,cAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,YAAG,OAAO,GAAO,IACrF,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vB,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC3D,gBAAM,KAAK,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,aAAG,KAAK,GAAG,CAAC,SAAS,EACjF,OAAO,CAAC,KAAK,IAAI,CAChB,cAAK,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,GAAI,CACtH,EACD,eAAM,KAAK,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,YAAG,OAAO,CAAC,IAAI,GAAQ,IACnD,GACH,EACL,aAAI,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,YAAG,OAAO,CAAC,SAAS,GAAM,EACvE,aAAI,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,YAC3D,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,GAC/C,KAbE,OAAO,CAAC,EAAE,CAcd,CACN,CAAC,GACI,IACF,IACJ,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DiscountData {
|
|
3
|
+
id: string;
|
|
4
|
+
code: string;
|
|
5
|
+
type: "percentage" | "fixed_amount" | "free_shipping";
|
|
6
|
+
value: number;
|
|
7
|
+
minPurchase?: number;
|
|
8
|
+
maxUses?: number;
|
|
9
|
+
usedCount: number;
|
|
10
|
+
startsAt?: string;
|
|
11
|
+
expiresAt?: string;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
applicableTo: "all" | "specific_products" | "specific_categories";
|
|
14
|
+
}
|
|
15
|
+
export interface DiscountManagerProps {
|
|
16
|
+
discounts: DiscountData[];
|
|
17
|
+
onCreate: (data: Omit<DiscountData, "id" | "usedCount">) => void;
|
|
18
|
+
onEdit: (id: string, data: Partial<DiscountData>) => void;
|
|
19
|
+
onDelete: (id: string) => void;
|
|
20
|
+
onToggle: (id: string, active: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
/** Manages discount codes with creation, editing, toggling, and deletion. */
|
|
23
|
+
export declare function DiscountManager({ discounts, onCreate, onEdit: _onEdit, onDelete, onToggle, }: DiscountManagerProps): React.ReactElement;
|
|
24
|
+
//# sourceMappingURL=DiscountManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscountManager.d.ts","sourceRoot":"","sources":["../../src/admin/DiscountManager.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,KAAK,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;CACnE;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,WAAW,CAAC,KAAK,IAAI,CAAC;IACjE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAC1D,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD;AAaD,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,QAAQ,EACR,MAAM,EAAE,OAAO,EACf,QAAQ,EACR,QAAQ,GACT,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAmI3C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
function formatValue(type, value) {
|
|
5
|
+
switch (type) {
|
|
6
|
+
case "percentage":
|
|
7
|
+
return `${value}%`;
|
|
8
|
+
case "fixed_amount":
|
|
9
|
+
return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(value);
|
|
10
|
+
case "free_shipping":
|
|
11
|
+
return "Free shipping";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Manages discount codes with creation, editing, toggling, and deletion. */
|
|
15
|
+
export function DiscountManager({ discounts, onCreate, onEdit: _onEdit, onDelete, onToggle, }) {
|
|
16
|
+
const [showCreate, setShowCreate] = useState(false);
|
|
17
|
+
const [newCode, setNewCode] = useState("");
|
|
18
|
+
const [newType, setNewType] = useState("percentage");
|
|
19
|
+
const [newValue, setNewValue] = useState(0);
|
|
20
|
+
const [newMinPurchase, setNewMinPurchase] = useState();
|
|
21
|
+
const [newMaxUses, setNewMaxUses] = useState();
|
|
22
|
+
const handleCreate = () => {
|
|
23
|
+
onCreate({
|
|
24
|
+
code: newCode,
|
|
25
|
+
type: newType,
|
|
26
|
+
value: newValue,
|
|
27
|
+
minPurchase: newMinPurchase,
|
|
28
|
+
maxUses: newMaxUses,
|
|
29
|
+
isActive: true,
|
|
30
|
+
applicableTo: "all",
|
|
31
|
+
});
|
|
32
|
+
setShowCreate(false);
|
|
33
|
+
setNewCode("");
|
|
34
|
+
setNewValue(0);
|
|
35
|
+
};
|
|
36
|
+
const sectionStyle = {
|
|
37
|
+
border: "1px solid #e5e7eb",
|
|
38
|
+
borderRadius: 8,
|
|
39
|
+
padding: 16,
|
|
40
|
+
marginBottom: 16,
|
|
41
|
+
};
|
|
42
|
+
return (_jsxs("div", { children: [_jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 16 }, children: [_jsxs("h2", { children: ["Discounts (", discounts.length, ")"] }), _jsx("button", { onClick: () => setShowCreate(!showCreate), style: { background: "#2563eb", color: "#fff", padding: "8px 16px", borderRadius: 6, border: "none", cursor: "pointer" }, children: showCreate ? "Cancel" : "Create Discount" })] }), showCreate && (_jsxs("div", { style: sectionStyle, children: [_jsx("h3", { children: "New Discount" }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 12, marginBottom: 12 }, children: [_jsxs("div", { children: [_jsx("label", { style: { display: "block", marginBottom: 4 }, children: "Code" }), _jsx("input", { value: newCode, onChange: (e) => setNewCode(e.target.value.toUpperCase()), placeholder: "e.g. SAVE20", style: { width: "100%" } })] }), _jsxs("div", { children: [_jsx("label", { style: { display: "block", marginBottom: 4 }, children: "Type" }), _jsxs("select", { value: newType, onChange: (e) => setNewType(e.target.value), style: { width: "100%" }, children: [_jsx("option", { value: "percentage", children: "Percentage" }), _jsx("option", { value: "fixed_amount", children: "Fixed Amount" }), _jsx("option", { value: "free_shipping", children: "Free Shipping" })] })] }), _jsxs("div", { children: [_jsx("label", { style: { display: "block", marginBottom: 4 }, children: "Value" }), _jsx("input", { type: "number", value: newValue, onChange: (e) => setNewValue(parseFloat(e.target.value) || 0), style: { width: "100%" } })] })] }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 12, marginBottom: 12 }, children: [_jsxs("div", { children: [_jsx("label", { style: { display: "block", marginBottom: 4 }, children: "Min. Purchase" }), _jsx("input", { type: "number", value: newMinPurchase ?? "", onChange: (e) => setNewMinPurchase(parseFloat(e.target.value) || undefined), style: { width: "100%" } })] }), _jsxs("div", { children: [_jsx("label", { style: { display: "block", marginBottom: 4 }, children: "Max Uses" }), _jsx("input", { type: "number", value: newMaxUses ?? "", onChange: (e) => setNewMaxUses(parseInt(e.target.value) || undefined), style: { width: "100%" } })] })] }), _jsx("button", { onClick: handleCreate, disabled: !newCode, style: { background: "#059669", color: "#fff", padding: "6px 14px", borderRadius: 6, border: "none", cursor: "pointer" }, children: "Create" })] })), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", padding: 8 }, children: "Code" }), _jsx("th", { style: { textAlign: "left", padding: 8 }, children: "Type" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Value" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Usage" }), _jsx("th", { style: { textAlign: "center", padding: 8 }, children: "Status" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Expires" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Actions" })] }) }), _jsx("tbody", { children: discounts.map((discount) => (_jsxs("tr", { style: { borderTop: "1px solid #e5e7eb" }, children: [_jsx("td", { style: { padding: 8, fontWeight: 600, fontFamily: "monospace" }, children: discount.code }), _jsx("td", { style: { padding: 8, textTransform: "capitalize" }, children: discount.type.replace("_", " ") }), _jsx("td", { style: { textAlign: "right", padding: 8 }, children: formatValue(discount.type, discount.value) }), _jsxs("td", { style: { textAlign: "right", padding: 8 }, children: [discount.usedCount, discount.maxUses ? ` / ${discount.maxUses}` : ""] }), _jsx("td", { style: { textAlign: "center", padding: 8 }, children: _jsx("button", { onClick: () => onToggle(discount.id, !discount.isActive), style: {
|
|
43
|
+
padding: "2px 10px",
|
|
44
|
+
borderRadius: 9999,
|
|
45
|
+
fontSize: 12,
|
|
46
|
+
fontWeight: 500,
|
|
47
|
+
border: "none",
|
|
48
|
+
cursor: "pointer",
|
|
49
|
+
background: discount.isActive ? "#d1fae5" : "#fee2e2",
|
|
50
|
+
color: discount.isActive ? "#065f46" : "#991b1b",
|
|
51
|
+
}, children: discount.isActive ? "Active" : "Inactive" }) }), _jsx("td", { style: { textAlign: "right", padding: 8, fontSize: 13, color: "#6b7280" }, children: discount.expiresAt ? new Date(discount.expiresAt).toLocaleDateString() : "—" }), _jsx("td", { style: { textAlign: "right", padding: 8 }, children: _jsx("button", { onClick: () => onDelete(discount.id), style: { color: "#dc2626", cursor: "pointer", background: "none", border: "none" }, children: "Delete" }) })] }, discount.id))) })] })] }));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=DiscountManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscountManager.js","sourceRoot":"","sources":["../../src/admin/DiscountManager.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAwBxC,SAAS,WAAW,CAAC,IAA0B,EAAE,KAAa;IAC5D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,GAAG,KAAK,GAAG,CAAC;QACrB,KAAK,cAAc;YACjB,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9F,KAAK,eAAe;YAClB,OAAO,eAAe,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,eAAe,CAAC,EAC9B,SAAS,EACT,QAAQ,EACR,MAAM,EAAE,OAAO,EACf,QAAQ,EACR,QAAQ,GAC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1E,EACL,aAAI,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,YAC3C,iBAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,uBAEvH,GACN,KA/BE,QAAQ,CAAC,EAAE,CAgCf,CACN,CAAC,GACI,IACF,IACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type OrderStatus = "pending" | "confirmed" | "processing" | "shipped" | "delivered" | "cancelled" | "refunded";
|
|
3
|
+
export interface Address {
|
|
4
|
+
line1: string;
|
|
5
|
+
line2?: string;
|
|
6
|
+
city: string;
|
|
7
|
+
state: string;
|
|
8
|
+
postalCode: string;
|
|
9
|
+
country: string;
|
|
10
|
+
}
|
|
11
|
+
export interface OrderDetailData {
|
|
12
|
+
id: string;
|
|
13
|
+
orderNumber: string;
|
|
14
|
+
status: OrderStatus;
|
|
15
|
+
customerName: string;
|
|
16
|
+
customerEmail: string;
|
|
17
|
+
shippingAddress: Address;
|
|
18
|
+
billingAddress: Address;
|
|
19
|
+
subtotal: number;
|
|
20
|
+
taxAmount: number;
|
|
21
|
+
shippingAmount: number;
|
|
22
|
+
discountAmount: number;
|
|
23
|
+
total: number;
|
|
24
|
+
currency: string;
|
|
25
|
+
notes?: string;
|
|
26
|
+
placedAt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface OrderItemData {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
sku: string;
|
|
32
|
+
quantity: number;
|
|
33
|
+
unitPrice: number;
|
|
34
|
+
totalPrice: number;
|
|
35
|
+
variantName?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PaymentData {
|
|
38
|
+
id: string;
|
|
39
|
+
stripePaymentIntentId: string;
|
|
40
|
+
amount: number;
|
|
41
|
+
currency: string;
|
|
42
|
+
status: "pending" | "succeeded" | "failed" | "refunded";
|
|
43
|
+
method: string;
|
|
44
|
+
paidAt?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface TimelineEvent {
|
|
47
|
+
id: string;
|
|
48
|
+
type: "status_change" | "payment" | "note" | "email";
|
|
49
|
+
description: string;
|
|
50
|
+
timestamp: string;
|
|
51
|
+
actor?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface OrderDetailProps {
|
|
54
|
+
order: OrderDetailData;
|
|
55
|
+
items: OrderItemData[];
|
|
56
|
+
payments: PaymentData[];
|
|
57
|
+
timeline: TimelineEvent[];
|
|
58
|
+
}
|
|
59
|
+
/** Renders a full order detail view with timeline, items, payments, and address info. */
|
|
60
|
+
export declare function OrderDetail({ order, items, payments, timeline, }: OrderDetailProps): React.ReactElement;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=OrderDetail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderDetail.d.ts","sourceRoot":"","sources":["../../src/admin/OrderDetail.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,WAAW,GACZ,SAAS,GACT,WAAW,GACX,YAAY,GACZ,SAAS,GACT,WAAW,GACX,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IAC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AE,WAAW,EAAE,CAAC;IACxB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAoBD,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAqJvC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
function formatCurrency(amount, currency) {
|
|
4
|
+
return new Intl.NumberFormat("en-US", { style: "currency", currency }).format(amount);
|
|
5
|
+
}
|
|
6
|
+
function AddressBlock({ address, title }) {
|
|
7
|
+
return (_jsxs("div", { children: [_jsx("h4", { style: { margin: "0 0 4px" }, children: title }), _jsxs("div", { style: { fontSize: 14, color: "#374151" }, children: [_jsx("div", { children: address.line1 }), address.line2 && _jsx("div", { children: address.line2 }), _jsxs("div", { children: [address.city, ", ", address.state, " ", address.postalCode] }), _jsx("div", { children: address.country })] })] }));
|
|
8
|
+
}
|
|
9
|
+
/** Renders a full order detail view with timeline, items, payments, and address info. */
|
|
10
|
+
export function OrderDetail({ order, items, payments, timeline, }) {
|
|
11
|
+
const sectionStyle = {
|
|
12
|
+
border: "1px solid #e5e7eb",
|
|
13
|
+
borderRadius: 8,
|
|
14
|
+
padding: 16,
|
|
15
|
+
marginBottom: 24,
|
|
16
|
+
};
|
|
17
|
+
return (_jsxs("div", { children: [_jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 24 }, children: [_jsxs("div", { children: [_jsxs("h2", { style: { margin: 0 }, children: ["Order ", order.orderNumber] }), _jsxs("span", { style: { color: "#6b7280", fontSize: 14 }, children: ["Placed ", new Date(order.placedAt).toLocaleString()] })] }), _jsx("span", { style: {
|
|
18
|
+
padding: "4px 12px",
|
|
19
|
+
borderRadius: 9999,
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
fontWeight: 500,
|
|
22
|
+
background: "#dbeafe",
|
|
23
|
+
color: "#1e40af",
|
|
24
|
+
}, children: order.status })] }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Customer" }), _jsxs("div", { style: { marginBottom: 12 }, children: [_jsx("div", { style: { fontWeight: 500 }, children: order.customerName }), _jsx("div", { style: { fontSize: 14, color: "#6b7280" }, children: order.customerEmail })] }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 16 }, children: [_jsx(AddressBlock, { address: order.shippingAddress, title: "Shipping" }), _jsx(AddressBlock, { address: order.billingAddress, title: "Billing" })] })] }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Items" }), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", padding: 6 }, children: "Product" }), _jsx("th", { style: { textAlign: "left", padding: 6 }, children: "SKU" }), _jsx("th", { style: { textAlign: "right", padding: 6 }, children: "Qty" }), _jsx("th", { style: { textAlign: "right", padding: 6 }, children: "Unit Price" }), _jsx("th", { style: { textAlign: "right", padding: 6 }, children: "Total" })] }) }), _jsx("tbody", { children: items.map((item) => (_jsxs("tr", { style: { borderTop: "1px solid #f3f4f6" }, children: [_jsxs("td", { style: { padding: 6 }, children: [item.name, item.variantName && (_jsxs("span", { style: { color: "#6b7280", fontSize: 12 }, children: [" \u2014 ", item.variantName] }))] }), _jsx("td", { style: { padding: 6, color: "#6b7280", fontSize: 13 }, children: item.sku }), _jsx("td", { style: { textAlign: "right", padding: 6 }, children: item.quantity }), _jsx("td", { style: { textAlign: "right", padding: 6 }, children: formatCurrency(item.unitPrice, order.currency) }), _jsx("td", { style: { textAlign: "right", padding: 6, fontWeight: 500 }, children: formatCurrency(item.totalPrice, order.currency) })] }, item.id))) })] }), _jsxs("div", { style: { marginTop: 12, borderTop: "1px solid #e5e7eb", paddingTop: 12 }, children: [_jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [_jsx("span", { children: "Subtotal" }), _jsx("span", { children: formatCurrency(order.subtotal, order.currency) })] }), _jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [_jsx("span", { children: "Tax" }), _jsx("span", { children: formatCurrency(order.taxAmount, order.currency) })] }), _jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [_jsx("span", { children: "Shipping" }), _jsx("span", { children: formatCurrency(order.shippingAmount, order.currency) })] }), order.discountAmount > 0 && (_jsxs("div", { style: { display: "flex", justifyContent: "space-between", color: "#059669" }, children: [_jsx("span", { children: "Discount" }), _jsxs("span", { children: ["-", formatCurrency(order.discountAmount, order.currency)] })] })), _jsxs("div", { style: { display: "flex", justifyContent: "space-between", fontWeight: 700, fontSize: 16, marginTop: 8, paddingTop: 8, borderTop: "2px solid #111827" }, children: [_jsx("span", { children: "Total" }), _jsx("span", { children: formatCurrency(order.total, order.currency) })] })] })] }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Payments" }), payments.length === 0 ? (_jsx("p", { style: { color: "#6b7280" }, children: "No payments recorded." })) : (payments.map((payment) => (_jsxs("div", { style: { display: "flex", justifyContent: "space-between", padding: "8px 0", borderBottom: "1px solid #f3f4f6" }, children: [_jsxs("div", { children: [_jsx("div", { style: { fontWeight: 500 }, children: formatCurrency(payment.amount, payment.currency) }), _jsxs("div", { style: { fontSize: 12, color: "#6b7280" }, children: [payment.method, " \u2014 ", payment.stripePaymentIntentId] })] }), _jsxs("div", { style: { textAlign: "right" }, children: [_jsx("span", { style: { padding: "2px 8px", borderRadius: 9999, fontSize: 12, background: payment.status === "succeeded" ? "#d1fae5" : "#fef3c7", color: payment.status === "succeeded" ? "#065f46" : "#92400e" }, children: payment.status }), payment.paidAt && (_jsx("div", { style: { fontSize: 12, color: "#6b7280", marginTop: 4 }, children: new Date(payment.paidAt).toLocaleString() }))] })] }, payment.id))))] }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Timeline" }), timeline.map((event) => (_jsxs("div", { style: { display: "flex", gap: 12, padding: "8px 0", borderBottom: "1px solid #f3f4f6" }, children: [_jsx("div", { style: { width: 8, height: 8, borderRadius: "50%", background: "#6b7280", marginTop: 6, flexShrink: 0 } }), _jsxs("div", { children: [_jsx("div", { style: { fontSize: 14 }, children: event.description }), _jsxs("div", { style: { fontSize: 12, color: "#9ca3af" }, children: [new Date(event.timestamp).toLocaleString(), event.actor && ` — ${event.actor}`] })] })] }, event.id)))] }), order.notes && (_jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Notes" }), _jsx("p", { style: { whiteSpace: "pre-wrap", color: "#374151" }, children: order.notes })] }))] }));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=OrderDetail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderDetail.js","sourceRoot":"","sources":["../../src/admin/OrderDetail.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AA2Eb,SAAS,cAAc,CAAC,MAAc,EAAE,QAAgB;IACtD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACxF,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,OAAO,EAAE,KAAK,EAAuC;IAC3E,OAAO,CACL,0BACE,aAAI,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAAG,KAAK,GAAM,EAC9C,eAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,aAC5C,wBAAM,OAAO,CAAC,KAAK,GAAO,EACzB,OAAO,CAAC,KAAK,IAAI,wBAAM,OAAO,CAAC,KAAK,GAAO,EAC5C,0BAAM,OAAO,CAAC,IAAI,QAAI,OAAO,CAAC,KAAK,OAAG,OAAO,CAAC,UAAU,IAAO,EAC/D,wBAAM,OAAO,CAAC,OAAO,G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AC,SAAS,CAAC,CAAC,cAAc,EAAE,EAC1C,KAAK,CAAC,KAAK,IAAI,MAAM,KAAK,CAAC,KAAK,EAAE,IAC/B,IACF,KARE,KAAK,CAAC,EAAE,CASZ,CACP,CAAC,IACM,EAGT,KAAK,CAAC,KAAK,IAAI,CACd,mBAAS,KAAK,EAAE,YAAY,aAC1B,iCAAc,EACd,YAAG,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,YAAG,KAAK,CAAC,KAAK,GAAK,IACjE,CACX,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type OrderStatus = "pending" | "confirmed" | "processing" | "shipped" | "delivered" | "cancelled" | "refunded";
|
|
3
|
+
export interface OrderListItem {
|
|
4
|
+
id: string;
|
|
5
|
+
orderNumber: string;
|
|
6
|
+
customerName: string;
|
|
7
|
+
customerEmail: string;
|
|
8
|
+
status: OrderStatus;
|
|
9
|
+
total: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
itemCount: number;
|
|
12
|
+
placedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export interface OrderFilters {
|
|
15
|
+
status?: OrderStatus;
|
|
16
|
+
dateFrom?: string;
|
|
17
|
+
dateTo?: string;
|
|
18
|
+
search?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OrderListProps {
|
|
21
|
+
orders: OrderListItem[];
|
|
22
|
+
onView: (id: string) => void;
|
|
23
|
+
onStatusChange: (id: string, status: OrderStatus) => void;
|
|
24
|
+
filters?: OrderFilters;
|
|
25
|
+
}
|
|
26
|
+
/** Renders a filterable order list with status badges and quick actions. */
|
|
27
|
+
export declare function OrderList({ orders, onView, onStatusChange, filters: _filters, }: OrderListProps): React.ReactElement;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=OrderList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderList.d.ts","sourceRoot":"","sources":["../../src/admin/OrderList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,WAAW,GACZ,SAAS,GACT,WAAW,GACX,YAAY,GACZ,SAAS,GACT,WAAW,GACX,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1D,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAgBD,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,EAAE,QAAQ,GAClB,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CA4ErC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const STATUS_COLORS = {
|
|
4
|
+
pending: { bg: "#fef3c7", fg: "#92400e" },
|
|
5
|
+
confirmed: { bg: "#dbeafe", fg: "#1e40af" },
|
|
6
|
+
processing: { bg: "#e0e7ff", fg: "#3730a3" },
|
|
7
|
+
shipped: { bg: "#cffafe", fg: "#155e75" },
|
|
8
|
+
delivered: { bg: "#d1fae5", fg: "#065f46" },
|
|
9
|
+
cancelled: { bg: "#fee2e2", fg: "#991b1b" },
|
|
10
|
+
refunded: { bg: "#f3e8ff", fg: "#6b21a8" },
|
|
11
|
+
};
|
|
12
|
+
function formatCurrency(amount, currency) {
|
|
13
|
+
return new Intl.NumberFormat("en-US", { style: "currency", currency }).format(amount);
|
|
14
|
+
}
|
|
15
|
+
/** Renders a filterable order list with status badges and quick actions. */
|
|
16
|
+
export function OrderList({ orders, onView, onStatusChange, filters: _filters, }) {
|
|
17
|
+
return (_jsxs("div", { children: [_jsx("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 16 }, children: _jsxs("h2", { children: ["Orders (", orders.length, ")"] }) }), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", padding: 8 }, children: "Order" }), _jsx("th", { style: { textAlign: "left", padding: 8 }, children: "Customer" }), _jsx("th", { style: { textAlign: "center", padding: 8 }, children: "Status" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Items" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Total" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Date" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Actions" })] }) }), _jsx("tbody", { children: orders.map((order) => {
|
|
18
|
+
const colors = STATUS_COLORS[order.status];
|
|
19
|
+
return (_jsxs("tr", { style: { borderTop: "1px solid #e5e7eb" }, children: [_jsx("td", { style: { padding: 8, fontWeight: 500 }, children: order.orderNumber }), _jsxs("td", { style: { padding: 8 }, children: [_jsx("div", { children: order.customerName }), _jsx("div", { style: { fontSize: 12, color: "#6b7280" }, children: order.customerEmail })] }), _jsx("td", { style: { textAlign: "center", padding: 8 }, children: _jsx("span", { style: {
|
|
20
|
+
display: "inline-block",
|
|
21
|
+
padding: "2px 10px",
|
|
22
|
+
borderRadius: 9999,
|
|
23
|
+
fontSize: 12,
|
|
24
|
+
fontWeight: 500,
|
|
25
|
+
background: colors.bg,
|
|
26
|
+
color: colors.fg,
|
|
27
|
+
}, children: order.status }) }), _jsx("td", { style: { textAlign: "right", padding: 8 }, children: order.itemCount }), _jsx("td", { style: { textAlign: "right", padding: 8, fontWeight: 500 }, children: formatCurrency(order.total, order.currency) }), _jsx("td", { style: { textAlign: "right", padding: 8, fontSize: 13, color: "#6b7280" }, children: new Date(order.placedAt).toLocaleDateString() }), _jsxs("td", { style: { textAlign: "right", padding: 8 }, children: [_jsx("button", { onClick: () => onView(order.id), style: { marginRight: 8, cursor: "pointer" }, children: "View" }), _jsxs("select", { value: order.status, onChange: (e) => onStatusChange(order.id, e.target.value), style: { fontSize: 12, padding: "2px 4px" }, children: [_jsx("option", { value: "pending", children: "Pending" }), _jsx("option", { value: "confirmed", children: "Confirmed" }), _jsx("option", { value: "processing", children: "Processing" }), _jsx("option", { value: "shipped", children: "Shipped" }), _jsx("option", { value: "delivered", children: "Delivered" }), _jsx("option", { value: "cancelled", children: "Cancelled" }), _jsx("option", { value: "refunded", children: "Refunded" })] })] })] }, order.id));
|
|
28
|
+
}) })] })] }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=OrderList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderList.js","sourceRoot":"","sources":["../../src/admin/OrderList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAuCb,MAAM,aAAa,GAAoD;IACrE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE;IACzC,SAAS,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE;IAC3C,UA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Z,CACN,CAAC;wBACJ,CAAC,CAAC,GACI,IACF,IACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ProductFormData {
|
|
3
|
+
id?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
description: string;
|
|
7
|
+
status: "draft" | "active" | "archived";
|
|
8
|
+
price: number;
|
|
9
|
+
compareAtPrice?: number;
|
|
10
|
+
sku: string;
|
|
11
|
+
barcode?: string;
|
|
12
|
+
trackInventory: boolean;
|
|
13
|
+
inventoryCount: number;
|
|
14
|
+
weight?: number;
|
|
15
|
+
weightUnit?: "kg" | "lb" | "oz" | "g";
|
|
16
|
+
taxable: boolean;
|
|
17
|
+
categoryId?: string;
|
|
18
|
+
tags: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface VariantFormData {
|
|
21
|
+
id?: string;
|
|
22
|
+
name: string;
|
|
23
|
+
sku: string;
|
|
24
|
+
price: number;
|
|
25
|
+
inventoryCount: number;
|
|
26
|
+
options: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface ImageData {
|
|
29
|
+
id: string;
|
|
30
|
+
url: string;
|
|
31
|
+
alt: string;
|
|
32
|
+
sortOrder: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ProductEditProps {
|
|
35
|
+
product?: ProductFormData;
|
|
36
|
+
variants?: VariantFormData[];
|
|
37
|
+
images?: ImageData[];
|
|
38
|
+
onSave: (data: ProductFormData, variants: VariantFormData[], images: ImageData[]) => void;
|
|
39
|
+
onCancel: () => void;
|
|
40
|
+
}
|
|
41
|
+
/** Full product editor with sections for details, pricing, inventory, variants, and images. */
|
|
42
|
+
export declare function ProductEdit({ product, variants, images, onSave, onCancel, }: ProductEditProps): React.ReactElement;
|
|
43
|
+
//# sourceMappingURL=ProductEdit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductEdit.d.ts","s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AAE,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC1F,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAeD,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,QAAa,EACb,MAAW,EACX,MAAM,EACN,QAAQ,GACT,EAAE,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAmLvC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
const DEFAULT_PRODUCT = {
|
|
5
|
+
name: "",
|
|
6
|
+
slug: "",
|
|
7
|
+
description: "",
|
|
8
|
+
status: "draft",
|
|
9
|
+
price: 0,
|
|
10
|
+
sku: "",
|
|
11
|
+
trackInventory: false,
|
|
12
|
+
inventoryCount: 0,
|
|
13
|
+
taxable: true,
|
|
14
|
+
tags: [],
|
|
15
|
+
};
|
|
16
|
+
/** Full product editor with sections for details, pricing, inventory, variants, and images. */
|
|
17
|
+
export function ProductEdit({ product, variants = [], images = [], onSave, onCancel, }) {
|
|
18
|
+
const [form, setForm] = useState(product ?? DEFAULT_PRODUCT);
|
|
19
|
+
const [variantList, setVariantList] = useState(variants);
|
|
20
|
+
const [imageList, setImageList] = useState(images);
|
|
21
|
+
const updateField = (key, value) => {
|
|
22
|
+
setForm((prev) => ({ ...prev, [key]: value }));
|
|
23
|
+
};
|
|
24
|
+
const handleSubmit = (e) => {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
onSave(form, variantList, imageList);
|
|
27
|
+
};
|
|
28
|
+
const sectionStyle = {
|
|
29
|
+
border: "1px solid #e5e7eb",
|
|
30
|
+
borderRadius: 8,
|
|
31
|
+
padding: 16,
|
|
32
|
+
marginBottom: 24,
|
|
33
|
+
};
|
|
34
|
+
const fieldRow = {
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: "column",
|
|
37
|
+
gap: 4,
|
|
38
|
+
marginBottom: 12,
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs("form", { onSubmit: handleSubmit, children: [_jsx("h2", { children: product?.id ? "Edit Product" : "New Product" }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Details" }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Name" }), _jsx("input", { value: form.name, onChange: (e) => updateField("name", e.target.value), required: true })] }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Slug" }), _jsx("input", { value: form.slug, onChange: (e) => updateField("slug", e.target.value) })] }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Description" }), _jsx("textarea", { value: form.description, onChange: (e) => updateField("description", e.target.value), rows: 4 })] }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Status" }), _jsxs("select", { value: form.status, onChange: (e) => updateField("status", e.target.value), children: [_jsx("option", { value: "draft", children: "Draft" }), _jsx("option", { value: "active", children: "Active" }), _jsx("option", { value: "archived", children: "Archived" })] })] })] }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Pricing" }), _jsxs("div", { style: { display: "flex", gap: 16 }, children: [_jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Price" }), _jsx("input", { type: "number", step: "0.01", min: "0", value: form.price, onChange: (e) => updateField("price", parseFloat(e.target.value) || 0) })] }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Compare at Price" }), _jsx("input", { type: "number", step: "0.01", min: "0", value: form.compareAtPrice ?? "", onChange: (e) => updateField("compareAtPrice", parseFloat(e.target.value) || undefined) })] })] }), _jsx("div", { style: fieldRow, children: _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: form.taxable, onChange: (e) => updateField("taxable", e.target.checked) }), " ", "Charge tax on this product"] }) })] }), _jsxs("section", { style: sectionStyle, children: [_jsx("h3", { children: "Inventory" }), _jsxs("div", { style: { display: "flex", gap: 16 }, children: [_jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "SKU" }), _jsx("input", { value: form.sku, onChange: (e) => updateField("sku", e.target.value) })] }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Barcode" }), _jsx("input", { value: form.barcode ?? "", onChange: (e) => updateField("barcode", e.target.value) })] })] }), _jsx("div", { style: fieldRow, children: _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: form.trackInventory, onChange: (e) => updateField("trackInventory", e.target.checked) }), " ", "Track inventory"] }) }), form.trackInventory && (_jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Inventory Count" }), _jsx("input", { type: "number", min: "0", value: form.inventoryCount, onChange: (e) => updateField("inventoryCount", parseInt(e.target.value) || 0) })] })), _jsxs("div", { style: { display: "flex", gap: 16 }, children: [_jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Weight" }), _jsx("input", { type: "number", step: "0.01", value: form.weight ?? "", onChange: (e) => updateField("weight", parseFloat(e.target.value) || undefined) })] }), _jsxs("div", { style: fieldRow, children: [_jsx("label", { children: "Unit" }), _jsxs("select", { value: form.weightUnit ?? "kg", onChange: (e) => updateField("weightUnit", e.target.value), children: [_jsx("option", { value: "kg", children: "kg" }), _jsx("option", { value: "lb", children: "lb" }), _jsx("option", { value: "oz", children: "oz" }), _jsx("option", { value: "g", children: "g" })] })] })] })] }), _jsxs("section", { style: sectionStyle, children: [_jsxs("h3", { children: ["Variants (", variantList.length, ")"] }), variantList.map((variant, index) => (_jsx("div", { style: { borderBottom: "1px solid #f3f4f6", paddingBottom: 8, marginBottom: 8 }, children: _jsxs("div", { style: { display: "flex", gap: 12 }, children: [_jsx("input", { placeholder: "Name", value: variant.name, onChange: (e) => {
|
|
41
|
+
const updated = [...variantList];
|
|
42
|
+
updated[index] = { ...variant, name: e.target.value };
|
|
43
|
+
setVariantList(updated);
|
|
44
|
+
} }), _jsx("input", { placeholder: "SKU", value: variant.sku, onChange: (e) => {
|
|
45
|
+
const updated = [...variantList];
|
|
46
|
+
updated[index] = { ...variant, sku: e.target.value };
|
|
47
|
+
setVariantList(updated);
|
|
48
|
+
} }), _jsx("input", { type: "number", placeholder: "Price", step: "0.01", value: variant.price, onChange: (e) => {
|
|
49
|
+
const updated = [...variantList];
|
|
50
|
+
updated[index] = { ...variant, price: parseFloat(e.target.value) || 0 };
|
|
51
|
+
setVariantList(updated);
|
|
52
|
+
} }), _jsx("button", { type: "button", onClick: () => setVariantList(variantList.filter((_, i) => i !== index)), children: "Remove" })] }) }, variant.id ?? index))), _jsx("button", { type: "button", onClick: () => setVariantList([...variantList, { name: "", sku: "", price: 0, inventoryCount: 0, options: {} }]), children: "Add Variant" })] }), _jsxs("section", { style: sectionStyle, children: [_jsxs("h3", { children: ["Images (", imageList.length, ")"] }), imageList.map((img, index) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 }, children: [_jsx("img", { src: img.url, alt: img.alt, style: { width: 48, height: 48, objectFit: "cover", borderRadius: 4 } }), _jsx("input", { placeholder: "Alt text", value: img.alt, onChange: (e) => {
|
|
53
|
+
const updated = [...imageList];
|
|
54
|
+
updated[index] = { ...img, alt: e.target.value };
|
|
55
|
+
setImageList(updated);
|
|
56
|
+
} }), _jsx("button", { type: "button", onClick: () => setImageList(imageList.filter((_, i) => i !== index)), children: "Remove" })] }, img.id)))] }), _jsxs("div", { style: { display: "flex", gap: 12, justifyContent: "flex-end" }, children: [_jsx("button", { type: "button", onClick: onCancel, children: "Cancel" }), _jsx("button", { type: "submit", style: { background: "#2563eb", color: "#fff", padding: "8px 16px", borderRadius: 6, border: "none", cursor: "pointer" }, children: product?.id ? "Save Product" : "Create Product" })] })] }));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=ProductEdit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductEdit.js","sourceRoot":"","sources":["../../src/admin/ProductEdit.tsx"],"names":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C,OAAO,EAAE,QAAQ,uBAAiB,EACxD,iBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAC3I,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gBAAgB,GACzC,IACL,IACD,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ProductListItem {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
price: number;
|
|
7
|
+
compareAtPrice?: number;
|
|
8
|
+
status: "draft" | "active" | "archived";
|
|
9
|
+
inventoryCount: number;
|
|
10
|
+
image?: string;
|
|
11
|
+
category?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProductListProps {
|
|
14
|
+
products: ProductListItem[];
|
|
15
|
+
onEdit: (id: string) => void;
|
|
16
|
+
onDelete: (id: string) => void;
|
|
17
|
+
onStatusChange: (id: string, status: ProductListItem["status"]) => void;
|
|
18
|
+
}
|
|
19
|
+
/** Renders a searchable product list with inline status controls. */
|
|
20
|
+
export declare function ProductList({ products, onEdit, onDelete, onStatusChange, }: ProductListProps): React.ReactElement;
|
|
21
|
+
//# sourceMappingURL=ProductList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductList.d.ts","sourceRoot":"","sources":["../../src/admin/ProductList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzE;AAeD,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,cAAc,GACf,EAAE,gBAAgB,GAAG,KAAK,CAAC,YAAY,CA2EvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const STATUS_STYLES = {
|
|
4
|
+
draft: "background: #fef3c7; color: #92400e",
|
|
5
|
+
active: "background: #d1fae5; color: #065f46",
|
|
6
|
+
archived: "background: #e5e7eb; color: #374151",
|
|
7
|
+
};
|
|
8
|
+
function formatCurrency(amount) {
|
|
9
|
+
return new Intl.NumberFormat("en-US", {
|
|
10
|
+
style: "currency",
|
|
11
|
+
currency: "USD",
|
|
12
|
+
}).format(amount);
|
|
13
|
+
}
|
|
14
|
+
/** Renders a searchable product list with inline status controls. */
|
|
15
|
+
export function ProductList({ products, onEdit, onDelete, onStatusChange, }) {
|
|
16
|
+
return (_jsxs("div", { children: [_jsx("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 16 }, children: _jsxs("h2", { children: ["Products (", products.length, ")"] }) }), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", padding: 8 }, children: "Product" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Price" }), _jsx("th", { style: { textAlign: "center", padding: 8 }, children: "Status" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Inventory" }), _jsx("th", { style: { textAlign: "right", padding: 8 }, children: "Actions" })] }) }), _jsx("tbody", { children: products.map((product) => (_jsxs("tr", { style: { borderTop: "1px solid #e5e7eb" }, children: [_jsx("td", { style: { padding: 8 }, children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [product.image && (_jsx("img", { src: product.image, alt: product.name, style: { width: 40, height: 40, objectFit: "cover", borderRadius: 4 } })), _jsxs("div", { children: [_jsx("div", { style: { fontWeight: 500 }, children: product.name }), _jsx("div", { style: { fontSize: 12, color: "#6b7280" }, children: product.slug })] })] }) }), _jsxs("td", { style: { textAlign: "right", padding: 8 }, children: [_jsx("span", { children: formatCurrency(product.price) }), product.compareAtPrice !== undefined && product.compareAtPrice > product.price && (_jsx("span", { style: { textDecoration: "line-through", color: "#9ca3af", marginLeft: 4, fontSize: 12 }, children: formatCurrency(product.compareAtPrice) }))] }), _jsx("td", { style: { textAlign: "center", padding: 8 }, children: _jsxs("select", { value: product.status, onChange: (e) => onStatusChange(product.id, e.target.value), style: { padding: "2px 8px", borderRadius: 4, border: "1px solid #d1d5db", ...parseStyle(STATUS_STYLES[product.status]) }, children: [_jsx("option", { value: "draft", children: "Draft" }), _jsx("option", { value: "active", children: "Active" }), _jsx("option", { value: "archived", children: "Archived" })] }) }), _jsx("td", { style: { textAlign: "right", padding: 8 }, children: _jsx("span", { style: { color: product.inventoryCount <= 5 ? "#dc2626" : "#111827" }, children: product.inventoryCount }) }), _jsxs("td", { style: { textAlign: "right", padding: 8 }, children: [_jsx("button", { onClick: () => onEdit(product.id), style: { marginRight: 8, cursor: "pointer" }, children: "Edit" }), _jsx("button", { onClick: () => onDelete(product.id), style: { color: "#dc2626", cursor: "pointer" }, children: "Delete" })] })] }, product.id))) })] })] }));
|
|
17
|
+
}
|
|
18
|
+
function parseStyle(cssText) {
|
|
19
|
+
const style = {};
|
|
20
|
+
for (const declaration of cssText.split(";")) {
|
|
21
|
+
const [prop, val] = declaration.split(":").map((s) => s.trim());
|
|
22
|
+
if (prop && val) {
|
|
23
|
+
const camel = prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
24
|
+
style[camel] = val;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return style;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ProductList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductList.js","sourceRoot":"","sources":["../../src/admin/ProductList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAuBb,MAAM,aAAa,GAA8C;IAC/D,KAAK,EAAE,qCAAqC;IAC5C,MAAM,EAAE,qCAAqC;IAC7C,QAAQ,EAAE,qCAAqC;CAChD,CAAC;AAEF,SAAS,cAAc,CAAC,MAAc;IACpC,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACpC,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAC,EAC1B,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,cAAc,GACG;IACjB,OAAO,CACL,0BACE,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,EAAE,YAChF,uCAAe,QAAQ,CAAC,MAAM,SAAO,GACjC,EAEN,iBAAO,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,aACzD,0BACE,yBACE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