@cedros/pay-react 1.1.25 → 1.1.26

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.
Files changed (94) hide show
  1. package/dist/{AISettingsSection-Dg1kazTI.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
  2. package/dist/{AISettingsSection-BvSSiK2G.js → AISettingsSection-DELur7D2.js} +1 -1
  3. package/dist/{AutosaveIndicator-BHfkV59p.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-D2l7U8R1.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
  5. package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
  6. package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
  7. package/dist/{ComplianceSection-BSE2f3Wo.mjs → ComplianceSection-CemgfDrL.mjs} +282 -166
  8. package/dist/ComplianceSection-DP2a9-S0.js +1 -0
  9. package/dist/CustomersSection-CBwy_waO.js +1 -0
  10. package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
  11. package/dist/DisputesSection-BLjIk60n.js +1 -0
  12. package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
  13. package/dist/{FAQSection-uZG5V3pJ.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
  14. package/dist/{FAQSection-6nGI0FK9.js → FAQSection-wNeH0i6Q.js} +1 -1
  15. package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
  16. package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
  17. package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
  18. package/dist/InventorySection-zV6lTmue.js +1 -0
  19. package/dist/{MessagingSection-M0lj5yo4.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
  20. package/dist/{MessagingSection-DrXb578q.js → MessagingSection-B_wdFR0j.js} +1 -1
  21. package/dist/{OrdersSection-DteItv_O.mjs → OrdersSection-Bj8bPdg8.mjs} +1 -1
  22. package/dist/{OrdersSection-_-rIw6XW.js → OrdersSection-Dw2FX-1d.js} +1 -1
  23. package/dist/{PaymentSettingsSection-enTbUI95.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
  24. package/dist/{PaymentSettingsSection-CdtdLFTg.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
  25. package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
  26. package/dist/ReturnsSection-D_pJVxuG.js +1 -0
  27. package/dist/{SettingsSection-mcT4LEhO.mjs → SettingsSection-KYdEizq_.mjs} +1 -1
  28. package/dist/{SettingsSection-DUTEd6uV.js → SettingsSection-vdYFSNxB.js} +1 -1
  29. package/dist/ShippingSection-1DRSTu49.js +1 -0
  30. package/dist/ShippingSection-BOgto6_9.mjs +434 -0
  31. package/dist/{SingleCategorySettings-D2LVM5mn.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
  32. package/dist/{SingleCategorySettings-BvHBVfSe.mjs → SingleCategorySettings-suJ8z9d8.mjs} +2 -2
  33. package/dist/{StorefrontSection-BqQ36JIS.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
  34. package/dist/{StorefrontSection-Du7hV2Gc.js → StorefrontSection-RumGkb3C.js} +1 -1
  35. package/dist/{SubscriptionsSection-C4BRN1dP.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
  36. package/dist/{SubscriptionsSection-BYiCBwKZ.mjs → SubscriptionsSection-D60qrX9a.mjs} +1 -1
  37. package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
  38. package/dist/TaxSection-Dt1DnM51.js +1 -0
  39. package/dist/{Token22Section-BHvOhz5d.mjs → Token22Section-CrHLQ0EB.mjs} +1 -1
  40. package/dist/{Token22Section-0c22NM5G.js → Token22Section-DY3mUwTY.js} +1 -1
  41. package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
  42. package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
  43. package/dist/crypto-only.js +1 -1
  44. package/dist/crypto-only.mjs +1 -1
  45. package/dist/index-C0g-JxJk.js +84 -0
  46. package/dist/{index-BkDimQDF.mjs → index-DXnuQp5x.mjs} +7068 -6768
  47. package/dist/index.js +1 -1
  48. package/dist/index.mjs +1 -1
  49. package/dist/{sections-By4H1baL.mjs → sections-C1NpK7hk.mjs} +2 -2
  50. package/dist/{sections-5jO2aHAo.js → sections-DVVSZBhW.js} +1 -1
  51. package/dist/src/components/ComplianceGatePage.d.ts +3 -1
  52. package/dist/src/components/ComplianceGatePage.d.ts.map +1 -1
  53. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  54. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  55. package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
  56. package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
  57. package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
  58. package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
  59. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
  60. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
  61. package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -1
  62. package/dist/src/components/admin/CustomersSection.d.ts +3 -0
  63. package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
  64. package/dist/src/components/admin/DisputesSection.d.ts +3 -0
  65. package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
  66. package/dist/src/components/admin/ImagesSection.d.ts +3 -0
  67. package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
  68. package/dist/src/components/admin/InventorySection.d.ts +3 -0
  69. package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
  70. package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
  71. package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
  72. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  73. package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
  74. package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
  75. package/dist/src/components/admin/ShippingSection.d.ts +3 -0
  76. package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
  77. package/dist/src/components/admin/TaxSection.d.ts +3 -0
  78. package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
  79. package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
  80. package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
  81. package/dist/src/components/admin/complianceTypes.d.ts +15 -1
  82. package/dist/src/components/admin/complianceTypes.d.ts.map +1 -1
  83. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
  84. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  85. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  86. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
  87. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  88. package/dist/src/ecommerce/index.d.ts +2 -2
  89. package/dist/src/ecommerce/index.d.ts.map +1 -1
  90. package/dist/src/hooks/useComplianceCheck.d.ts +1 -1
  91. package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -1
  92. package/package.json +1 -1
  93. package/dist/ComplianceSection-D6ETKG6b.js +0 -1
  94. package/dist/index-C7MWL6O8.js +0 -84
@@ -0,0 +1,216 @@
1
+ import { jsxs as l, jsx as t, Fragment as R } from "react/jsx-runtime";
2
+ import { useState as h, useRef as j, useCallback as U } from "react";
3
+ import { E as z, I as u, k as B } from "./index-DXnuQp5x.mjs";
4
+ import { i as I } from "./CedrosContext-CY6zvjvJ.mjs";
5
+ async function W(r, n, i, c) {
6
+ const d = new FormData();
7
+ if (d.append("file", c), i?.isAuthenticated())
8
+ return i.fetchWithAuth(
9
+ "/admin/images/upload",
10
+ { method: "POST", body: d, headers: {} }
11
+ );
12
+ const o = {};
13
+ n && (o["X-API-Key"] = n);
14
+ const s = await fetch(`${r}/admin/images/upload`, {
15
+ method: "POST",
16
+ headers: o,
17
+ body: d
18
+ });
19
+ if (!s.ok) throw new Error(`Upload failed: ${s.status}`);
20
+ return s.json();
21
+ }
22
+ async function P(r, n, i, c) {
23
+ const d = JSON.stringify({ url: c });
24
+ if (i?.isAuthenticated()) {
25
+ await i.fetchWithAuth("/admin/images", {
26
+ method: "DELETE",
27
+ body: d
28
+ });
29
+ return;
30
+ }
31
+ const o = { "Content-Type": "application/json" };
32
+ n && (o["X-API-Key"] = n);
33
+ const s = await fetch(`${r}/admin/images`, {
34
+ method: "DELETE",
35
+ headers: o,
36
+ body: d
37
+ });
38
+ if (!s.ok) throw new Error(`Delete failed: ${s.status}`);
39
+ }
40
+ function q({ serverUrl: r, apiKey: n, authManager: i }) {
41
+ const [c, d] = h([]), [o, s] = h(!1), [v, D] = h(null), [S, m] = h(null), [w, C] = h(null), [f, g] = h(!1), [p, y] = h(null), b = j(null), N = U(async (e) => {
42
+ s(!0), m(null);
43
+ try {
44
+ const a = await W(r, n, i, e);
45
+ d((_) => [
46
+ { url: a.url, thumbUrl: a.thumbUrl, uploadedAt: (/* @__PURE__ */ new Date()).toISOString() },
47
+ ..._
48
+ ]), y(null), b.current && (b.current.value = "");
49
+ } catch (a) {
50
+ I().error("[ImagesSection] Upload failed:", a, {
51
+ serverUrl: r.slice(0, 20) + "..."
52
+ }), m("Upload failed. Check file type and try again.");
53
+ } finally {
54
+ s(!1);
55
+ }
56
+ }, [r, n, i]), k = (e) => {
57
+ const a = e.target.files?.[0] ?? null;
58
+ y(a), m(null);
59
+ }, x = () => {
60
+ p && N(p);
61
+ }, T = (e) => {
62
+ e.preventDefault(), g(!0);
63
+ }, E = () => g(!1), A = (e) => {
64
+ e.preventDefault(), g(!1);
65
+ const a = e.dataTransfer.files?.[0];
66
+ a && a.type.startsWith("image/") ? (y(a), m(null)) : a && m("Only image files are accepted.");
67
+ }, L = U(async (e) => {
68
+ D(e), m(null);
69
+ try {
70
+ await P(r, n, i, e), d((a) => a.filter((_) => _.url !== e));
71
+ } catch (a) {
72
+ I().error("[ImagesSection] Delete failed:", a, {
73
+ serverUrl: r.slice(0, 20) + "..."
74
+ }), m("Failed to delete image.");
75
+ } finally {
76
+ D(null);
77
+ }
78
+ }, [r, n, i]), O = async (e) => {
79
+ try {
80
+ await navigator.clipboard.writeText(e), C(e), setTimeout(() => C(null), 2e3);
81
+ } catch {
82
+ m("Could not copy to clipboard.");
83
+ }
84
+ }, F = [
85
+ "cedros-admin__drop-zone",
86
+ f ? "cedros-admin__drop-zone--active" : ""
87
+ ].filter(Boolean).join(" ");
88
+ return /* @__PURE__ */ l("div", { className: "cedros-admin__page", children: [
89
+ /* @__PURE__ */ t(z, { message: S }),
90
+ /* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Image Upload" }) }),
91
+ /* @__PURE__ */ l(
92
+ "div",
93
+ {
94
+ className: F,
95
+ onDragOver: T,
96
+ onDragLeave: E,
97
+ onDrop: A,
98
+ role: "region",
99
+ "aria-label": "Image drop zone",
100
+ style: {
101
+ border: "2px dashed",
102
+ borderColor: f ? "var(--cedros-accent, #6366f1)" : "var(--cedros-border, #e2e8f0)",
103
+ borderRadius: "0.5rem",
104
+ padding: "1.5rem",
105
+ textAlign: "center",
106
+ marginBottom: "1rem",
107
+ transition: "border-color 0.15s",
108
+ backgroundColor: f ? "var(--cedros-accent-subtle, rgba(99,102,241,0.06))" : void 0
109
+ },
110
+ children: [
111
+ /* @__PURE__ */ t("p", { style: { marginBottom: "0.75rem", fontSize: "0.9rem", opacity: 0.7 }, children: "Drag and drop an image here, or select a file below" }),
112
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.5rem", justifyContent: "center", alignItems: "center", flexWrap: "wrap" }, children: [
113
+ /* @__PURE__ */ t(
114
+ "input",
115
+ {
116
+ ref: b,
117
+ id: "cedros-image-file-input",
118
+ type: "file",
119
+ accept: "image/*",
120
+ className: "cedros-admin__input",
121
+ style: { maxWidth: 260 },
122
+ onChange: k,
123
+ "aria-label": "Select image file"
124
+ }
125
+ ),
126
+ /* @__PURE__ */ t(
127
+ "button",
128
+ {
129
+ type: "button",
130
+ className: "cedros-admin__button cedros-admin__button--primary",
131
+ onClick: x,
132
+ disabled: !p || o,
133
+ "aria-busy": o,
134
+ children: o ? /* @__PURE__ */ l(R, { children: [
135
+ u.loading,
136
+ " Uploading..."
137
+ ] }) : "Upload"
138
+ }
139
+ )
140
+ ] }),
141
+ p && !o && /* @__PURE__ */ l("p", { style: { marginTop: "0.5rem", fontSize: "0.8rem", opacity: 0.65 }, children: [
142
+ "Selected: ",
143
+ p.name,
144
+ " (",
145
+ (p.size / 1024).toFixed(1),
146
+ " KB)"
147
+ ] })
148
+ ]
149
+ }
150
+ ),
151
+ /* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ l("h3", { className: "cedros-admin__section-title", children: [
152
+ "Uploaded This Session",
153
+ c.length > 0 && /* @__PURE__ */ t("span", { className: "cedros-admin__section-badge", style: { marginLeft: "0.5rem" }, children: c.length })
154
+ ] }) }),
155
+ c.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No images uploaded yet." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ l("table", { className: "cedros-admin__table", children: [
156
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ l("tr", { children: [
157
+ /* @__PURE__ */ t("th", { children: "Preview" }),
158
+ /* @__PURE__ */ t("th", { children: "URL" }),
159
+ /* @__PURE__ */ t("th", { children: "Uploaded" }),
160
+ /* @__PURE__ */ t("th", { children: "Actions" })
161
+ ] }) }),
162
+ /* @__PURE__ */ t("tbody", { children: c.map((e) => /* @__PURE__ */ l("tr", { children: [
163
+ /* @__PURE__ */ t("td", { style: { width: 72 }, children: /* @__PURE__ */ t(
164
+ "img",
165
+ {
166
+ src: e.thumbUrl,
167
+ alt: "Thumbnail preview",
168
+ style: {
169
+ width: 56,
170
+ height: 56,
171
+ objectFit: "cover",
172
+ borderRadius: "0.25rem",
173
+ display: "block"
174
+ }
175
+ }
176
+ ) }),
177
+ /* @__PURE__ */ t("td", { style: { maxWidth: 320, wordBreak: "break-all" }, children: /* @__PURE__ */ t("code", { style: { fontSize: "0.8rem" }, children: e.url }) }),
178
+ /* @__PURE__ */ t("td", { style: { whiteSpace: "nowrap" }, children: B(e.uploadedAt) }),
179
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.4rem" }, children: [
180
+ /* @__PURE__ */ l(
181
+ "button",
182
+ {
183
+ type: "button",
184
+ className: "cedros-admin__button cedros-admin__button--ghost",
185
+ onClick: () => O(e.url),
186
+ "aria-label": "Copy URL to clipboard",
187
+ title: "Copy URL",
188
+ children: [
189
+ w === e.url ? u.check : u.eye,
190
+ w === e.url ? "Copied" : "Copy URL"
191
+ ]
192
+ }
193
+ ),
194
+ /* @__PURE__ */ l(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ className: "cedros-admin__button cedros-admin__button--destructive",
199
+ onClick: () => L(e.url),
200
+ disabled: v === e.url,
201
+ "aria-label": "Delete image",
202
+ title: "Delete",
203
+ children: [
204
+ v === e.url ? u.loading : u.trash,
205
+ "Delete"
206
+ ]
207
+ }
208
+ )
209
+ ] }) })
210
+ ] }, e.url)) })
211
+ ] }) })
212
+ ] });
213
+ }
214
+ export {
215
+ q as ImagesSection
216
+ };
@@ -0,0 +1,150 @@
1
+ import { jsxs as n, jsx as t, Fragment as P } from "react/jsx-runtime";
2
+ import { useState as r, useCallback as S, useEffect as w } from "react";
3
+ import { E as R, I as j, k as T } from "./index-DXnuQp5x.mjs";
4
+ import { i as E } from "./CedrosContext-CY6zvjvJ.mjs";
5
+ const a = 50;
6
+ function X({ serverUrl: o, apiKey: h, authManager: f }) {
7
+ const [g, I] = r([]), [C, v] = r(!0), [$, b] = r(null), [i, x] = r(""), [c, p] = r([]), [F, N] = r(!1), [L, _] = r(null), [l, y] = r(0), m = S(async (e) => {
8
+ if (f?.isAuthenticated())
9
+ return f.fetchWithAuth(e);
10
+ const s = { "Content-Type": "application/json" };
11
+ h && (s["X-API-Key"] = h);
12
+ const d = await fetch(`${o}${e}`, { headers: s });
13
+ if (!d.ok) throw new Error(`Request failed: ${d.status}`);
14
+ return d.json();
15
+ }, [o, h, f]);
16
+ w(() => {
17
+ let e = !1;
18
+ return v(!0), b(null), m("/admin/products?limit=100&offset=0").then((s) => {
19
+ if (e) return;
20
+ const d = Array.isArray(s) ? s : s.products ?? [];
21
+ I(d);
22
+ }).catch((s) => {
23
+ e || (E().error("[InventorySection] Failed to load products:", s, {
24
+ serverUrl: o.slice(0, 20) + "..."
25
+ }), b("Failed to load products"));
26
+ }).finally(() => {
27
+ e || v(!1);
28
+ }), () => {
29
+ e = !0;
30
+ };
31
+ }, [m, o]);
32
+ const A = S(async (e, s) => {
33
+ if (e) {
34
+ N(!0), _(null);
35
+ try {
36
+ const d = `/admin/products/${encodeURIComponent(e)}/inventory/adjustments?limit=${a}&offset=${s}`, q = await m(d);
37
+ p(q.adjustments ?? []);
38
+ } catch (d) {
39
+ E().error("[InventorySection] Failed to load adjustments:", d, {
40
+ productId: e,
41
+ serverUrl: o.slice(0, 20) + "..."
42
+ }), _("Failed to load inventory adjustments"), p([]);
43
+ } finally {
44
+ N(!1);
45
+ }
46
+ }
47
+ }, [m, o]);
48
+ w(() => {
49
+ i && A(i, l);
50
+ }, [A, i, l]);
51
+ const k = (e) => {
52
+ x(e), y(0), p([]), _(null);
53
+ }, B = () => y((e) => Math.max(0, e - a)), D = () => y((e) => e + a), u = g.find((e) => e.id === i);
54
+ return /* @__PURE__ */ n("div", { className: "cedros-admin__page", children: [
55
+ /* @__PURE__ */ t(R, { message: $ ?? L }),
56
+ /* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Inventory Adjustments" }) }),
57
+ /* @__PURE__ */ t("div", { className: "cedros-admin__add-form", style: { marginBottom: "1rem" }, children: /* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ n("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
58
+ /* @__PURE__ */ t("label", { htmlFor: "inventory-product-select", className: "cedros-admin__field-label", children: "Select Product" }),
59
+ C ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
60
+ j.loading,
61
+ " Loading products..."
62
+ ] }) : /* @__PURE__ */ n(
63
+ "select",
64
+ {
65
+ id: "inventory-product-select",
66
+ className: "cedros-admin__input",
67
+ value: i,
68
+ onChange: (e) => k(e.target.value),
69
+ "aria-label": "Select product to view inventory adjustments",
70
+ children: [
71
+ /* @__PURE__ */ t("option", { value: "", children: "-- Choose a product --" }),
72
+ g.map((e) => /* @__PURE__ */ t("option", { value: e.id, children: e.title ?? e.description ?? e.id }, e.id))
73
+ ]
74
+ }
75
+ )
76
+ ] }) }) }),
77
+ i ? F ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
78
+ j.loading,
79
+ " Loading adjustments..."
80
+ ] }) : /* @__PURE__ */ n(P, { children: [
81
+ u && /* @__PURE__ */ n("p", { style: { marginBottom: "0.75rem", fontSize: "0.9rem", opacity: 0.7 }, children: [
82
+ "Showing adjustments for: ",
83
+ /* @__PURE__ */ t("strong", { children: u.title ?? u.description ?? u.id })
84
+ ] }),
85
+ c.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No inventory adjustments found." }) : /* @__PURE__ */ n(P, { children: [
86
+ /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
87
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ n("tr", { children: [
88
+ /* @__PURE__ */ t("th", { children: "Date" }),
89
+ /* @__PURE__ */ t("th", { children: "Delta" }),
90
+ /* @__PURE__ */ t("th", { children: "Before" }),
91
+ /* @__PURE__ */ t("th", { children: "After" }),
92
+ /* @__PURE__ */ t("th", { children: "Reason" }),
93
+ /* @__PURE__ */ t("th", { children: "Actor" })
94
+ ] }) }),
95
+ /* @__PURE__ */ t("tbody", { children: c.map((e) => /* @__PURE__ */ n("tr", { children: [
96
+ /* @__PURE__ */ t("td", { style: { whiteSpace: "nowrap" }, children: T(e.createdAt) }),
97
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t(
98
+ "span",
99
+ {
100
+ style: {
101
+ fontWeight: 600,
102
+ color: e.delta > 0 ? "var(--cedros-success, #16a34a)" : e.delta < 0 ? "var(--cedros-danger, #dc2626)" : void 0
103
+ },
104
+ "aria-label": `Delta: ${e.delta > 0 ? "plus" : ""}${e.delta}`,
105
+ children: e.delta > 0 ? `+${e.delta}` : e.delta
106
+ }
107
+ ) }),
108
+ /* @__PURE__ */ t("td", { children: e.quantityBefore }),
109
+ /* @__PURE__ */ t("td", { children: e.quantityAfter }),
110
+ /* @__PURE__ */ t("td", { children: e.reason ?? /* @__PURE__ */ t("span", { style: { opacity: 0.45 }, children: "—" }) }),
111
+ /* @__PURE__ */ t("td", { children: e.actor ?? /* @__PURE__ */ t("span", { style: { opacity: 0.45 }, children: "—" }) })
112
+ ] }, e.id)) })
113
+ ] }) }),
114
+ /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "0.75rem", fontSize: "0.85rem" }, children: [
115
+ /* @__PURE__ */ t(
116
+ "button",
117
+ {
118
+ type: "button",
119
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
120
+ disabled: l === 0,
121
+ onClick: B,
122
+ children: "Previous"
123
+ }
124
+ ),
125
+ /* @__PURE__ */ n("span", { children: [
126
+ "Page ",
127
+ Math.floor(l / a) + 1,
128
+ " · ",
129
+ c.length,
130
+ " record",
131
+ c.length !== 1 ? "s" : ""
132
+ ] }),
133
+ /* @__PURE__ */ t(
134
+ "button",
135
+ {
136
+ type: "button",
137
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
138
+ disabled: c.length < a,
139
+ onClick: D,
140
+ children: "Next"
141
+ }
142
+ )
143
+ ] })
144
+ ] })
145
+ ] }) : /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "Select a product to view its inventory adjustments." })
146
+ ] });
147
+ }
148
+ export {
149
+ X as InventorySection
150
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),m=require("./index-C0g-JxJk.js"),S=require("./CedrosContext-C2RjHLaQ.js"),c=50;function q({serverUrl:d,apiKey:h,authManager:j}){const[_,N]=s.useState([]),[A,g]=s.useState(!0),[P,p]=s.useState(null),[o,C]=s.useState(""),[i,x]=s.useState([]),[w,v]=s.useState(!1),[I,f]=s.useState(null),[a,y]=s.useState(0),l=s.useCallback(async t=>{if(j?.isAuthenticated())return j.fetchWithAuth(t);const n={"Content-Type":"application/json"};h&&(n["X-API-Key"]=h);const r=await fetch(`${d}${t}`,{headers:n});if(!r.ok)throw new Error(`Request failed: ${r.status}`);return r.json()},[d,h,j]);s.useEffect(()=>{let t=!1;return g(!0),p(null),l("/admin/products?limit=100&offset=0").then(n=>{if(t)return;const r=Array.isArray(n)?n:n.products??[];N(r)}).catch(n=>{t||(S.getLogger().error("[InventorySection] Failed to load products:",n,{serverUrl:d.slice(0,20)+"..."}),p("Failed to load products"))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[l,d]);const b=s.useCallback(async(t,n)=>{if(t){v(!0),f(null);try{const r=`/admin/products/${encodeURIComponent(t)}/inventory/adjustments?limit=${c}&offset=${n}`,L=await l(r);x(L.adjustments??[])}catch(r){S.getLogger().error("[InventorySection] Failed to load adjustments:",r,{productId:t,serverUrl:d.slice(0,20)+"..."}),f("Failed to load inventory adjustments"),x([])}finally{v(!1)}}},[l,d]);s.useEffect(()=>{o&&b(o,a)},[b,o,a]);const E=t=>{C(t),y(0),x([]),f(null)},$=()=>y(t=>Math.max(0,t-c)),F=()=>y(t=>t+c),u=_.find(t=>t.id===o);return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(m.ErrorBanner,{message:P??I}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Inventory Adjustments"})}),e.jsx("div",{className:"cedros-admin__add-form",style:{marginBottom:"1rem"},children:e.jsx("div",{className:"cedros-admin__form-row",children:e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{htmlFor:"inventory-product-select",className:"cedros-admin__field-label",children:"Select Product"}),A?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading products..."]}):e.jsxs("select",{id:"inventory-product-select",className:"cedros-admin__input",value:o,onChange:t=>E(t.target.value),"aria-label":"Select product to view inventory adjustments",children:[e.jsx("option",{value:"",children:"-- Choose a product --"}),_.map(t=>e.jsx("option",{value:t.id,children:t.title??t.description??t.id},t.id))]})]})})}),o?w?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading adjustments..."]}):e.jsxs(e.Fragment,{children:[u&&e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:["Showing adjustments for: ",e.jsx("strong",{children:u.title??u.description??u.id})]}),i.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No inventory adjustments found."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Delta"}),e.jsx("th",{children:"Before"}),e.jsx("th",{children:"After"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:m.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{style:{fontWeight:600,color:t.delta>0?"var(--cedros-success, #16a34a)":t.delta<0?"var(--cedros-danger, #dc2626)":void 0},"aria-label":`Delta: ${t.delta>0?"plus":""}${t.delta}`,children:t.delta>0?`+${t.delta}`:t.delta})}),e.jsx("td",{children:t.quantityBefore}),e.jsx("td",{children:t.quantityAfter}),e.jsx("td",{children:t.reason??e.jsx("span",{style:{opacity:.45},children:"—"})}),e.jsx("td",{children:t.actor??e.jsx("span",{style:{opacity:.45},children:"—"})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:a===0,onClick:$,children:"Previous"}),e.jsxs("span",{children:["Page ",Math.floor(a/c)+1," · ",i.length," record",i.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:i.length<c,onClick:F,children:"Next"})]})]})]}):e.jsx("div",{className:"cedros-admin__empty",children:"Select a product to view its inventory adjustments."})]})}exports.InventorySection=q;
@@ -1,9 +1,9 @@
1
1
  import { jsxs as i, jsx as e, Fragment as R } from "react/jsx-runtime";
2
2
  import { useState as _, useCallback as k, useEffect as U } from "react";
3
- import { I as $, E as q } from "./index-BkDimQDF.mjs";
3
+ import { I as $, E as q } from "./index-DXnuQp5x.mjs";
4
4
  import { T as C } from "./Toggle-DAxIdpY4.mjs";
5
5
  import { u as F } from "./useAutosave-YwMqRzqy.mjs";
6
- import { A as j } from "./AutosaveIndicator-BHfkV59p.mjs";
6
+ import { A as j } from "./AutosaveIndicator-Bed0-ekg.mjs";
7
7
  const u = {
8
8
  mailgun: { label: "Mailgun", host: "smtp.mailgun.org", username: "", credentialLabel: "SMTP Password", showUsername: !0, usernameEqualsPassword: !1 },
9
9
  sendgrid: { label: "SendGrid", host: "smtp.sendgrid.net", username: "apikey", credentialLabel: "API Key", showUsername: !1, usernameEqualsPassword: !1 },
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),y=require("./index-C7MWL6O8.js"),S=require("./Toggle-CsPSF8Dr.js"),q=require("./useAutosave-B2p6iwh8.js"),z=require("./AutosaveIndicator-D2l7U8R1.js"),p={mailgun:{label:"Mailgun",host:"smtp.mailgun.org",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1},sendgrid:{label:"SendGrid",host:"smtp.sendgrid.net",username:"apikey",credentialLabel:"API Key",showUsername:!1,usernameEqualsPassword:!1},postmark:{label:"Postmark",host:"smtp.postmarkapp.com",username:"",credentialLabel:"Server API Token",showUsername:!1,usernameEqualsPassword:!0},ses:{label:"AWS SES",host:"email-smtp.us-east-1.amazonaws.com",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1},resend:{label:"Resend",host:"smtp.resend.com",username:"resend",credentialLabel:"API Key",showUsername:!1,usernameEqualsPassword:!1},custom:{label:"Custom SMTP",host:"",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1}};function R(c){if(!c)return"custom";for(const[d,n]of Object.entries(p))if(n.host&&c===n.host)return d;return"custom"}const v={email_enabled:!1,email_provider:"custom",smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",from_email:"",from_name:"",webhook_enabled:!1,webhook_url:"",webhook_secret:"",webhook_timeout:30};function W({serverUrl:c,apiKey:d,authManager:n}){const[m,b]=l.useState("messages"),[a,h]=l.useState(v),[N,k]=l.useState(!0),[C,E]=l.useState(!0),[P,f]=l.useState(null),[_,j]=l.useState(new Set),g=l.useCallback(async()=>{try{f(null);let s;const t="/admin/config/messaging";if(n?.isAuthenticated())s=await n.fetchWithAuth(t);else{const o={"Content-Type":"application/json"};d&&(o["X-API-Key"]=d);const u=await fetch(`${c}${t}`,{headers:o});if(!u.ok)throw new Error(`Failed to fetch: ${u.status}`);s=await u.json()}const i={...v,...s.config};i.email_provider||(i.email_provider=R(i.smtp_host)),h(i)}catch{h(v),f("Could not load saved settings. Showing defaults.")}finally{k(!1),setTimeout(()=>E(!1),100)}},[c,d,n]);l.useEffect(()=>{g()},[g]);const T=l.useCallback(async s=>{const t="/admin/config/messaging",i={...s};_.has("smtp_password")||delete i.smtp_password,_.has("webhook_secret")||delete i.webhook_secret;const o=JSON.stringify({config:i});try{if(n?.isAuthenticated())await n.fetchWithAuth(t,{method:"PUT",body:o});else{const u={"Content-Type":"application/json"};d&&(u["X-API-Key"]=d);const w=await fetch(`${c}${t}`,{method:"PUT",headers:u,body:o});if(!w.ok)throw new Error(`Failed to save: ${w.status}`)}}catch{throw f("Failed to save messaging settings"),new Error("Save failed")}},[c,d,n,_]),{status:A,error:I}=q.useAutosave({data:a,onSave:T,debounceMs:1500,enabled:!C}),r=(s,t)=>{(s==="smtp_password"||s==="webhook_secret")&&j(i=>new Set(i).add(s)),h(i=>({...i,[s]:t}))},L=s=>{const t=p[s];h(i=>({...i,email_provider:s,smtp_host:t.host||i.smtp_host,smtp_port:587,smtp_username:t.username||(t.showUsername?i.smtp_username:"")}))},M=s=>{const t=a.email_provider||"custom",i=p[t];j(o=>new Set(o).add("smtp_password")),i.usernameEqualsPassword?h(o=>({...o,smtp_password:s,smtp_username:s})):h(o=>({...o,smtp_password:s}))},x=p[a.email_provider||"custom"]??p.custom;return N?e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__loading",style:{marginTop:"1rem"},children:[y.Icons.loading," Loading message settings..."]})]}):e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="messages"?"cedros-admin__tab--active":""}`,onClick:()=>b("messages"),children:"Messages"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="email"?"cedros-admin__tab--active":""}`,onClick:()=>b("email"),children:"Email"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="webhooks"?"cedros-admin__tab--active":""}`,onClick:()=>b("webhooks"),children:"Webhooks"}),e.jsx("div",{style:{flex:1}}),e.jsx(z.AutosaveIndicator,{status:A,error:I})]}),e.jsx(y.ErrorBanner,{message:P,onRetry:g}),e.jsxs("div",{className:"cedros-admin__tab-content",style:{marginTop:"1rem"},children:[m==="messages"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Enable or disable notification types. Configure the delivery settings in the Email or Webhooks tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(S.Toggle,{checked:a.email_enabled,onChange:s=>r("email_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Email Confirmation"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send order confirmation emails to customers after successful purchase."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Email configuration"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(S.Toggle,{checked:a.webhook_enabled,onChange:s=>r("webhook_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Admin Purchase Notification"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send webhook notifications to your server when a purchase is completed."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Webhook configuration"})]})]})]})]}),m==="email"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Select your email service provider for automatic configuration."}),!a.email_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Email notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.email_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Email Provider"}),e.jsx("select",{className:"cedros-admin__input",value:a.email_provider||"custom",onChange:s=>L(s.target.value),disabled:!a.email_enabled,children:Object.entries(p).map(([s,{label:t}])=>e.jsx("option",{value:s,children:t},s))})]}),a.email_provider==="custom"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Host"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_host,onChange:s=>r("smtp_host",s.target.value),placeholder:"smtp.example.com",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Port"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.smtp_port,onChange:s=>r("smtp_port",parseInt(s.target.value)||587),placeholder:"587",disabled:!a.email_enabled,style:{maxWidth:120}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Common: 587 (TLS), 465 (SSL), 25 (unencrypted)."})]})]}),x.showUsername&&e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Username"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_username,onChange:s=>r("smtp_username",s.target.value),placeholder:a.email_provider==="mailgun"?"postmaster@your-domain.com":"username",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:x.credentialLabel}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:_.has("smtp_password")?a.smtp_password:"",onChange:s=>M(s.target.value),placeholder:a.smtp_password?"••••••••":`Enter ${x.credentialLabel.toLowerCase()}`,disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Email"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.from_email,onChange:s=>r("from_email",s.target.value),placeholder:"noreply@example.com",disabled:!a.email_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Default sender email address."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Name"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.from_name,onChange:s=>r("from_name",s.target.value),placeholder:"Your Store",disabled:!a.email_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Default sender display name."})]})]})]}),m==="webhooks"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Configure webhook endpoint for receiving purchase notifications."}),!a.webhook_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Webhook notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.webhook_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook URL"}),e.jsx("input",{type:"url",className:"cedros-admin__input",value:a.webhook_url,onChange:s=>r("webhook_url",s.target.value),placeholder:"https://api.yoursite.com/webhooks/orders",disabled:!a.webhook_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook Secret"}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:_.has("webhook_secret")?a.webhook_secret:"",onChange:s=>r("webhook_secret",s.target.value),placeholder:a.webhook_secret?"••••••••":"Enter secret for HMAC-SHA256",disabled:!a.webhook_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Used for HMAC-SHA256 signature verification"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Timeout (seconds)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.webhook_timeout,onChange:s=>r("webhook_timeout",parseInt(s.target.value)||30),placeholder:"30",disabled:!a.webhook_enabled,style:{maxWidth:120}})]})]})]})]})]})}exports.MessagingSection=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),y=require("./index-C0g-JxJk.js"),S=require("./Toggle-CsPSF8Dr.js"),q=require("./useAutosave-B2p6iwh8.js"),z=require("./AutosaveIndicator-Dn_qA2hK.js"),p={mailgun:{label:"Mailgun",host:"smtp.mailgun.org",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1},sendgrid:{label:"SendGrid",host:"smtp.sendgrid.net",username:"apikey",credentialLabel:"API Key",showUsername:!1,usernameEqualsPassword:!1},postmark:{label:"Postmark",host:"smtp.postmarkapp.com",username:"",credentialLabel:"Server API Token",showUsername:!1,usernameEqualsPassword:!0},ses:{label:"AWS SES",host:"email-smtp.us-east-1.amazonaws.com",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1},resend:{label:"Resend",host:"smtp.resend.com",username:"resend",credentialLabel:"API Key",showUsername:!1,usernameEqualsPassword:!1},custom:{label:"Custom SMTP",host:"",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1}};function R(c){if(!c)return"custom";for(const[d,n]of Object.entries(p))if(n.host&&c===n.host)return d;return"custom"}const v={email_enabled:!1,email_provider:"custom",smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",from_email:"",from_name:"",webhook_enabled:!1,webhook_url:"",webhook_secret:"",webhook_timeout:30};function W({serverUrl:c,apiKey:d,authManager:n}){const[m,b]=l.useState("messages"),[a,h]=l.useState(v),[N,k]=l.useState(!0),[C,E]=l.useState(!0),[P,f]=l.useState(null),[_,j]=l.useState(new Set),g=l.useCallback(async()=>{try{f(null);let s;const t="/admin/config/messaging";if(n?.isAuthenticated())s=await n.fetchWithAuth(t);else{const o={"Content-Type":"application/json"};d&&(o["X-API-Key"]=d);const u=await fetch(`${c}${t}`,{headers:o});if(!u.ok)throw new Error(`Failed to fetch: ${u.status}`);s=await u.json()}const i={...v,...s.config};i.email_provider||(i.email_provider=R(i.smtp_host)),h(i)}catch{h(v),f("Could not load saved settings. Showing defaults.")}finally{k(!1),setTimeout(()=>E(!1),100)}},[c,d,n]);l.useEffect(()=>{g()},[g]);const T=l.useCallback(async s=>{const t="/admin/config/messaging",i={...s};_.has("smtp_password")||delete i.smtp_password,_.has("webhook_secret")||delete i.webhook_secret;const o=JSON.stringify({config:i});try{if(n?.isAuthenticated())await n.fetchWithAuth(t,{method:"PUT",body:o});else{const u={"Content-Type":"application/json"};d&&(u["X-API-Key"]=d);const w=await fetch(`${c}${t}`,{method:"PUT",headers:u,body:o});if(!w.ok)throw new Error(`Failed to save: ${w.status}`)}}catch{throw f("Failed to save messaging settings"),new Error("Save failed")}},[c,d,n,_]),{status:A,error:I}=q.useAutosave({data:a,onSave:T,debounceMs:1500,enabled:!C}),r=(s,t)=>{(s==="smtp_password"||s==="webhook_secret")&&j(i=>new Set(i).add(s)),h(i=>({...i,[s]:t}))},L=s=>{const t=p[s];h(i=>({...i,email_provider:s,smtp_host:t.host||i.smtp_host,smtp_port:587,smtp_username:t.username||(t.showUsername?i.smtp_username:"")}))},M=s=>{const t=a.email_provider||"custom",i=p[t];j(o=>new Set(o).add("smtp_password")),i.usernameEqualsPassword?h(o=>({...o,smtp_password:s,smtp_username:s})):h(o=>({...o,smtp_password:s}))},x=p[a.email_provider||"custom"]??p.custom;return N?e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__loading",style:{marginTop:"1rem"},children:[y.Icons.loading," Loading message settings..."]})]}):e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="messages"?"cedros-admin__tab--active":""}`,onClick:()=>b("messages"),children:"Messages"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="email"?"cedros-admin__tab--active":""}`,onClick:()=>b("email"),children:"Email"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="webhooks"?"cedros-admin__tab--active":""}`,onClick:()=>b("webhooks"),children:"Webhooks"}),e.jsx("div",{style:{flex:1}}),e.jsx(z.AutosaveIndicator,{status:A,error:I})]}),e.jsx(y.ErrorBanner,{message:P,onRetry:g}),e.jsxs("div",{className:"cedros-admin__tab-content",style:{marginTop:"1rem"},children:[m==="messages"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Enable or disable notification types. Configure the delivery settings in the Email or Webhooks tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(S.Toggle,{checked:a.email_enabled,onChange:s=>r("email_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Email Confirmation"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send order confirmation emails to customers after successful purchase."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Email configuration"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(S.Toggle,{checked:a.webhook_enabled,onChange:s=>r("webhook_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Admin Purchase Notification"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send webhook notifications to your server when a purchase is completed."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Webhook configuration"})]})]})]})]}),m==="email"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Select your email service provider for automatic configuration."}),!a.email_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Email notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.email_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Email Provider"}),e.jsx("select",{className:"cedros-admin__input",value:a.email_provider||"custom",onChange:s=>L(s.target.value),disabled:!a.email_enabled,children:Object.entries(p).map(([s,{label:t}])=>e.jsx("option",{value:s,children:t},s))})]}),a.email_provider==="custom"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Host"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_host,onChange:s=>r("smtp_host",s.target.value),placeholder:"smtp.example.com",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Port"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.smtp_port,onChange:s=>r("smtp_port",parseInt(s.target.value)||587),placeholder:"587",disabled:!a.email_enabled,style:{maxWidth:120}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Common: 587 (TLS), 465 (SSL), 25 (unencrypted)."})]})]}),x.showUsername&&e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Username"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_username,onChange:s=>r("smtp_username",s.target.value),placeholder:a.email_provider==="mailgun"?"postmaster@your-domain.com":"username",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:x.credentialLabel}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:_.has("smtp_password")?a.smtp_password:"",onChange:s=>M(s.target.value),placeholder:a.smtp_password?"••••••••":`Enter ${x.credentialLabel.toLowerCase()}`,disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Email"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.from_email,onChange:s=>r("from_email",s.target.value),placeholder:"noreply@example.com",disabled:!a.email_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Default sender email address."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Name"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.from_name,onChange:s=>r("from_name",s.target.value),placeholder:"Your Store",disabled:!a.email_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Default sender display name."})]})]})]}),m==="webhooks"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Configure webhook endpoint for receiving purchase notifications."}),!a.webhook_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Webhook notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.webhook_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook URL"}),e.jsx("input",{type:"url",className:"cedros-admin__input",value:a.webhook_url,onChange:s=>r("webhook_url",s.target.value),placeholder:"https://api.yoursite.com/webhooks/orders",disabled:!a.webhook_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook Secret"}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:_.has("webhook_secret")?a.webhook_secret:"",onChange:s=>r("webhook_secret",s.target.value),placeholder:a.webhook_secret?"••••••••":"Enter secret for HMAC-SHA256",disabled:!a.webhook_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Used for HMAC-SHA256 signature verification"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Timeout (seconds)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.webhook_timeout,onChange:s=>r("webhook_timeout",parseInt(s.target.value)||30),placeholder:"30",disabled:!a.webhook_enabled,style:{maxWidth:120}})]})]})]})]})]})}exports.MessagingSection=W;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as e, Fragment as $ } from "react/jsx-runtime";
2
2
  import { useState as r, useCallback as N, useEffect as U } from "react";
3
- import { I as z, E as G, k as F, s as L } from "./index-BkDimQDF.mjs";
3
+ import { I as z, E as G, k as F, s as L } from "./index-DXnuQp5x.mjs";
4
4
  function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
5
5
  const [c, t] = r([]), [o, y] = r(0), [R, x] = r(!0), [S, C] = r(null), [h, k] = r(null), [D, v] = r(null), [E, b] = r([]), [O, w] = r(!1), [f, T] = r(""), g = N(async (n, d) => {
6
6
  if (l?.isAuthenticated())
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),u=require("./index-C7MWL6O8.js");function A({serverUrl:n,apiKey:d,pageSize:o=20,authManager:r}){const[l,s]=a.useState([]),[c,p]=a.useState(0),[w,v]=a.useState(!0),[b,S]=a.useState(null),[h,N]=a.useState(null),[L,_]=a.useState(null),[R,y]=a.useState([]),[$,C]=a.useState(!1),[j,F]=a.useState(""),x=a.useCallback(async(t,i)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,i);const f={"Content-Type":"application/json"};d&&(f["X-API-Key"]=d);const m=await fetch(`${n}${t}`,{...i,headers:{...f,...i?.headers}});if(!m.ok){const I=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(I)}return m.json()},[n,d,r]),g=a.useCallback(async()=>{v(!0);try{S(null);const t=new URLSearchParams({limit:String(o)});j&&t.set("status",j);const i=await x(`/admin/orders?${t}`);s(i.orders),p(i.total)}catch{S("Failed to load orders")}finally{v(!1)}},[x,o,j]);a.useEffect(()=>{g()},[g]);const O=a.useCallback(async t=>{C(!0);try{const[i,f]=await Promise.all([x(`/admin/orders/${encodeURIComponent(t)}`),x("/admin/gift-card-redemptions?limit=50").catch(()=>[])]);_(i),y(f.filter(m=>m.orderId===t))}catch{_(null),y([])}finally{C(!1)}},[x]),T=t=>{h===t?(N(null),_(null),y([])):(N(t),O(t))},D=(t,i)=>i==="USD"||i==="usd"?`$${(t/100).toFixed(2)}`:`${t} ${i}`;return e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h2",{className:"cedros-admin__section-title",children:"Orders"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",style:{width:"auto",minWidth:"120px"},value:j,onChange:t=>F(t.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"paid",children:"Paid"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"fulfilled",children:"Fulfilled"}),e.jsx("option",{value:"shipped",children:"Shipped"}),e.jsx("option",{value:"delivered",children:"Delivered"}),e.jsx("option",{value:"cancelled",children:"Cancelled"}),e.jsx("option",{value:"refunded",children:"Refunded"})]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:g,children:[u.Icons.refresh," Refresh"]})]})]}),b?e.jsx(u.ErrorBanner,{message:b,onRetry:g}):null,w?e.jsx("div",{className:"cedros-admin__loading-text",children:"Loading orders..."}):l.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No orders found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__table-info",children:[c," order",c===1?"":"s"," total"]}),e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Customer"}),e.jsx("th",{children:"Date"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsx(E,{order:t,expanded:h===t.id,detail:h===t.id?L:null,redemptions:h===t.id?R:[],detailLoading:h===t.id&&$,onToggle:()=>T(t.id),formatAmount:D},t.id))})]})]})]})}function E({order:n,expanded:d,detail:o,redemptions:r,detailLoading:l,onToggle:s,formatAmount:c}){const p=n.metadata?.recipient_email||r.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:s,style:{cursor:"pointer"},className:d?"cedros-admin__table-row--active":"",children:[e.jsxs("td",{children:[e.jsxs("span",{className:"cedros-admin__mono",children:[n.id.slice(0,12),"..."]}),p?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Gift Card"}):null]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(n.status)}`,children:n.status})}),e.jsx("td",{children:c(n.amount,n.amountAsset)}),e.jsx("td",{children:n.source}),e.jsx("td",{children:n.customerEmail||n.customerName||"—"}),e.jsx("td",{children:u.formatDateTime(n.createdAt)})]}),d?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:0},children:e.jsx(P,{detail:o,redemptions:r,loading:l,formatAmount:c,metadata:n.metadata})})}):null]})}function P({detail:n,redemptions:d,loading:o,formatAmount:r,metadata:l}){return o?e.jsx("div",{style:{padding:"1rem"},className:"cedros-admin__loading-text",children:"Loading details..."}):e.jsxs("div",{style:{padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)"},children:[Object.keys(l).length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Order Metadata"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",fontSize:"0.8125rem"},children:Object.entries(l).map(([s,c])=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--cedros-admin-text-muted)"},children:s}),e.jsx("span",{children:c})]},s))})]}):null,d.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Gift Card Fulfillment"}),d.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",padding:"0.5rem",border:"1px solid var(--cedros-admin-border)",borderRadius:"0.5rem",marginBottom:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("span",{children:["Face value: ",r(s.faceValueCents,s.currency)]}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${s.creditsIssued>0?"success":"warning"}`,children:s.creditsIssued>0?"Credits issued":"Pending"})]}),e.jsxs("div",{style:{marginTop:"0.25rem",color:"var(--cedros-admin-text-muted)"},children:["Recipient: ",s.recipientUserId||"—",s.tokenMinted?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Token minted"}):null]})]},s.id))]}):null,n?.fulfillments&&n.fulfillments.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Fulfillments"}),n.fulfillments.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(s.status)}`,children:s.status}),s.carrier?e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.carrier}):null,s.trackingNumber?u.safeHref(s.trackingUrl)?e.jsx("a",{href:u.safeHref(s.trackingUrl),target:"_blank",rel:"noreferrer",style:{marginLeft:"0.5rem"},children:s.trackingNumber}):e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.trackingNumber}):null]},s.id))]}):null,n?.history&&n.history.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__label",children:"Status History"}),n.history.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{style:{color:"var(--cedros-admin-text-muted)"},children:u.formatDateTime(s.createdAt)})," ",s.fromStatus," → ",s.toStatus,s.note?e.jsx("span",{style:{marginLeft:"0.5rem",fontStyle:"italic"},children:s.note}):null]},s.id))]}):null]})}function k(n){switch(n){case"paid":case"fulfilled":case"delivered":case"success":return"success";case"processing":case"shipped":case"pending":return"warning";case"cancelled":case"refunded":case"failed":return"error";default:return"default"}}exports.OrdersSection=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),u=require("./index-C0g-JxJk.js");function A({serverUrl:n,apiKey:d,pageSize:o=20,authManager:r}){const[l,s]=a.useState([]),[c,p]=a.useState(0),[w,v]=a.useState(!0),[b,S]=a.useState(null),[h,N]=a.useState(null),[L,_]=a.useState(null),[R,y]=a.useState([]),[$,C]=a.useState(!1),[j,F]=a.useState(""),x=a.useCallback(async(t,i)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,i);const f={"Content-Type":"application/json"};d&&(f["X-API-Key"]=d);const m=await fetch(`${n}${t}`,{...i,headers:{...f,...i?.headers}});if(!m.ok){const I=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(I)}return m.json()},[n,d,r]),g=a.useCallback(async()=>{v(!0);try{S(null);const t=new URLSearchParams({limit:String(o)});j&&t.set("status",j);const i=await x(`/admin/orders?${t}`);s(i.orders),p(i.total)}catch{S("Failed to load orders")}finally{v(!1)}},[x,o,j]);a.useEffect(()=>{g()},[g]);const O=a.useCallback(async t=>{C(!0);try{const[i,f]=await Promise.all([x(`/admin/orders/${encodeURIComponent(t)}`),x("/admin/gift-card-redemptions?limit=50").catch(()=>[])]);_(i),y(f.filter(m=>m.orderId===t))}catch{_(null),y([])}finally{C(!1)}},[x]),T=t=>{h===t?(N(null),_(null),y([])):(N(t),O(t))},D=(t,i)=>i==="USD"||i==="usd"?`$${(t/100).toFixed(2)}`:`${t} ${i}`;return e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h2",{className:"cedros-admin__section-title",children:"Orders"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",style:{width:"auto",minWidth:"120px"},value:j,onChange:t=>F(t.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"paid",children:"Paid"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"fulfilled",children:"Fulfilled"}),e.jsx("option",{value:"shipped",children:"Shipped"}),e.jsx("option",{value:"delivered",children:"Delivered"}),e.jsx("option",{value:"cancelled",children:"Cancelled"}),e.jsx("option",{value:"refunded",children:"Refunded"})]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:g,children:[u.Icons.refresh," Refresh"]})]})]}),b?e.jsx(u.ErrorBanner,{message:b,onRetry:g}):null,w?e.jsx("div",{className:"cedros-admin__loading-text",children:"Loading orders..."}):l.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No orders found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__table-info",children:[c," order",c===1?"":"s"," total"]}),e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Customer"}),e.jsx("th",{children:"Date"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsx(E,{order:t,expanded:h===t.id,detail:h===t.id?L:null,redemptions:h===t.id?R:[],detailLoading:h===t.id&&$,onToggle:()=>T(t.id),formatAmount:D},t.id))})]})]})]})}function E({order:n,expanded:d,detail:o,redemptions:r,detailLoading:l,onToggle:s,formatAmount:c}){const p=n.metadata?.recipient_email||r.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:s,style:{cursor:"pointer"},className:d?"cedros-admin__table-row--active":"",children:[e.jsxs("td",{children:[e.jsxs("span",{className:"cedros-admin__mono",children:[n.id.slice(0,12),"..."]}),p?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Gift Card"}):null]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(n.status)}`,children:n.status})}),e.jsx("td",{children:c(n.amount,n.amountAsset)}),e.jsx("td",{children:n.source}),e.jsx("td",{children:n.customerEmail||n.customerName||"—"}),e.jsx("td",{children:u.formatDateTime(n.createdAt)})]}),d?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:0},children:e.jsx(P,{detail:o,redemptions:r,loading:l,formatAmount:c,metadata:n.metadata})})}):null]})}function P({detail:n,redemptions:d,loading:o,formatAmount:r,metadata:l}){return o?e.jsx("div",{style:{padding:"1rem"},className:"cedros-admin__loading-text",children:"Loading details..."}):e.jsxs("div",{style:{padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)"},children:[Object.keys(l).length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Order Metadata"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",fontSize:"0.8125rem"},children:Object.entries(l).map(([s,c])=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--cedros-admin-text-muted)"},children:s}),e.jsx("span",{children:c})]},s))})]}):null,d.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Gift Card Fulfillment"}),d.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",padding:"0.5rem",border:"1px solid var(--cedros-admin-border)",borderRadius:"0.5rem",marginBottom:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("span",{children:["Face value: ",r(s.faceValueCents,s.currency)]}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${s.creditsIssued>0?"success":"warning"}`,children:s.creditsIssued>0?"Credits issued":"Pending"})]}),e.jsxs("div",{style:{marginTop:"0.25rem",color:"var(--cedros-admin-text-muted)"},children:["Recipient: ",s.recipientUserId||"—",s.tokenMinted?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Token minted"}):null]})]},s.id))]}):null,n?.fulfillments&&n.fulfillments.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Fulfillments"}),n.fulfillments.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(s.status)}`,children:s.status}),s.carrier?e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.carrier}):null,s.trackingNumber?u.safeHref(s.trackingUrl)?e.jsx("a",{href:u.safeHref(s.trackingUrl),target:"_blank",rel:"noreferrer",style:{marginLeft:"0.5rem"},children:s.trackingNumber}):e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.trackingNumber}):null]},s.id))]}):null,n?.history&&n.history.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__label",children:"Status History"}),n.history.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{style:{color:"var(--cedros-admin-text-muted)"},children:u.formatDateTime(s.createdAt)})," ",s.fromStatus," → ",s.toStatus,s.note?e.jsx("span",{style:{marginLeft:"0.5rem",fontStyle:"italic"},children:s.note}):null]},s.id))]}):null]})}function k(n){switch(n){case"paid":case"fulfilled":case"delivered":case"success":return"success";case"processing":case"shipped":case"pending":return"warning";case"cancelled":case"refunded":case"failed":return"error";default:return"default"}}exports.OrdersSection=A;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),p=require("./SingleCategorySettings-D2LVM5mn.js");function r({href:s,children:n}){return e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:n})}const a=[{id:"stripe",label:"Stripe",category:"stripe",description:e.jsxs(e.Fragment,{children:["Configure your Stripe integration for card payments. Get your API keys from the"," ",e.jsx(r,{href:"https://dashboard.stripe.com/apikeys",children:"Stripe Dashboard"}),"."]})},{id:"crypto",label:"Crypto",category:"x402",description:e.jsxs(e.Fragment,{children:["Configure Solana wallet and token settings for crypto payments. Get a fast RPC endpoint from"," ",e.jsx(r,{href:"https://www.helius.dev",children:"Helius"})," or"," ",e.jsx(r,{href:"https://www.quicknode.com/chains/sol",children:"QuickNode"}),". Set up a payment address using"," ",e.jsx(r,{href:"https://phantom.app",children:"Phantom"})," or"," ",e.jsx(r,{href:"https://solflare.com",children:"Solflare"})," wallet."]})},{id:"credits",label:"Credits",category:"cedros_login",description:e.jsxs(e.Fragment,{children:["Configure Cedros Login integration for credits payments. See the"," ",e.jsx(r,{href:"https://docs.cedros.dev/credits",children:"Credits API documentation"}),"."]})}];function h({serverUrl:s,apiKey:n,authManager:c}){const[o,d]=l.useState("stripe"),i=a.find(t=>t.id===o);return e.jsxs("div",{className:"cedros-admin__payment-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Payment Options"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure payment methods including Stripe, crypto, and credits."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:a.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${o===t.id?"cedros-admin__tab--active":""}`,onClick:()=>d(t.id),children:t.label},t.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(p.SingleCategorySettings,{serverUrl:s,apiKey:n,authManager:c,category:i.category,title:`${i.label} Settings`,description:i.description,showEnabledToggle:!0},i.category)})]})}exports.PaymentSettingsSection=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),p=require("./SingleCategorySettings-DwCnBdRf.js");function r({href:s,children:n}){return e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:n})}const a=[{id:"stripe",label:"Stripe",category:"stripe",description:e.jsxs(e.Fragment,{children:["Configure your Stripe integration for card payments. Get your API keys from the"," ",e.jsx(r,{href:"https://dashboard.stripe.com/apikeys",children:"Stripe Dashboard"}),"."]})},{id:"crypto",label:"Crypto",category:"x402",description:e.jsxs(e.Fragment,{children:["Configure Solana wallet and token settings for crypto payments. Get a fast RPC endpoint from"," ",e.jsx(r,{href:"https://www.helius.dev",children:"Helius"})," or"," ",e.jsx(r,{href:"https://www.quicknode.com/chains/sol",children:"QuickNode"}),". Set up a payment address using"," ",e.jsx(r,{href:"https://phantom.app",children:"Phantom"})," or"," ",e.jsx(r,{href:"https://solflare.com",children:"Solflare"})," wallet."]})},{id:"credits",label:"Credits",category:"cedros_login",description:e.jsxs(e.Fragment,{children:["Configure Cedros Login integration for credits payments. See the"," ",e.jsx(r,{href:"https://docs.cedros.dev/credits",children:"Credits API documentation"}),"."]})}];function h({serverUrl:s,apiKey:n,authManager:c}){const[o,d]=l.useState("stripe"),i=a.find(t=>t.id===o);return e.jsxs("div",{className:"cedros-admin__payment-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Payment Options"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure payment methods including Stripe, crypto, and credits."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:a.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${o===t.id?"cedros-admin__tab--active":""}`,onClick:()=>d(t.id),children:t.label},t.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(p.SingleCategorySettings,{serverUrl:s,apiKey:n,authManager:c,category:i.category,title:`${i.label} Settings`,description:i.description,showEnabledToggle:!0},i.category)})]})}exports.PaymentSettingsSection=h;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as e, Fragment as s } from "react/jsx-runtime";
2
2
  import { useState as h } from "react";
3
- import { S as m } from "./SingleCategorySettings-BvHBVfSe.mjs";
3
+ import { S as m } from "./SingleCategorySettings-suJ8z9d8.mjs";
4
4
  function r({ href: o, children: a }) {
5
5
  return /* @__PURE__ */ e(
6
6
  "a",