@cedros/pay-react 1.1.27 → 1.1.29
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/{AISettingsSection-DELur7D2.js → AISettingsSection-B7qrycfY.js} +2 -2
- package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-DtAgMsDw.mjs} +6 -4
- package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-BEvABoKU.mjs} +1 -1
- package/dist/AutosaveIndicator-DiyeAg93.js +1 -0
- package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
- package/dist/CedrosContext-CCakH2SZ.js +3 -0
- package/dist/CedrosPayAdminDashboard-CAwEvn66.js +1 -0
- package/dist/CedrosPayAdminDashboard-CBuvNAtB.mjs +250 -0
- package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-Ber5o8hF.mjs} +19 -17
- package/dist/ChatLogsSection-DLxMMi9I.js +1 -0
- package/dist/ComplianceSection-Buu0zTiL.js +1 -0
- package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-ZCr0wsvw.mjs} +18 -15
- package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
- package/dist/CryptoButton-DxFCYDlJ.js +1 -0
- package/dist/CustomersSection-BywmMLur.js +1 -0
- package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-D9UknSKC.mjs} +21 -19
- package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-C_eySK-W.mjs} +19 -17
- package/dist/DisputesSection-DwkHGv2a.js +1 -0
- package/dist/Dropdown-B90Zabxr.mjs +111 -0
- package/dist/Dropdown-CtY91emj.js +1 -0
- package/dist/ErrorBanner-CZXsHi3H.mjs +22 -0
- package/dist/ErrorBanner-Cx2dUhps.js +1 -0
- package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Bv_Hdt8B.mjs} +8 -6
- package/dist/FAQSection-DlPLnIJD.js +1 -0
- package/dist/ImagesSection-B4Jzet79.js +1 -0
- package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-DpdXQ6qu.mjs} +6 -4
- package/dist/InventorySection-BgRdpn1l.js +1 -0
- package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-DZMu9DMw.mjs} +25 -23
- package/dist/MessagingSection-CxV-pf-f.js +1 -0
- package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-D_cOBfFt.mjs} +5 -4
- package/dist/OrdersSection-BbAX79Ff.js +1 -0
- package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-wfPavit9.mjs} +27 -24
- package/dist/PaymentSettingsSection-BdBDgaRg.js +1 -0
- package/dist/PaymentSettingsSection-DunzBo9n.mjs +648 -0
- package/dist/ReturnsSection-7k4LZ8yp.js +1 -0
- package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-B4FL7bUv.mjs} +11 -9
- package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-Cz2Yjdhr.js} +1 -1
- package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-DoeNDbqd.mjs} +1 -1
- package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-BlVsYC6B.mjs} +5 -3
- package/dist/ShippingSection-C-HI8rOb.js +1 -0
- package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-B406nnF-.mjs} +143 -140
- package/dist/SingleCategorySettings-BqC2UXt3.js +3 -0
- package/dist/StatsBar-D4v-I_Dj.mjs +25 -0
- package/dist/StatsBar-m6GSRNxs.js +1 -0
- package/dist/StorefrontSection-Axvh_KeS.js +1 -0
- package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-BK_rhrAi.mjs} +121 -119
- package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-D8V9RBv-.mjs} +11 -9
- package/dist/SubscriptionsSection-EeULMWIB.js +1 -0
- package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-Cj6TXL6x.mjs} +23 -21
- package/dist/TaxSection-CzHPhaHl.js +1 -0
- package/dist/ThemeContext-CFXyYx7A.js +1 -0
- package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
- package/dist/Token22Section-DqRKVG_G.js +1 -0
- package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DtYAcT54.mjs} +7 -6
- package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
- package/dist/WalletManager-DXChB9LA.js +1 -0
- package/dist/WebhooksSection-D--iPZuM.js +1 -0
- package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-DBAIxtBy.mjs} +40 -38
- package/dist/admin.d.ts +2 -0
- package/dist/admin.js +1 -0
- package/dist/admin.mjs +8 -0
- package/dist/configApi-BS5UJfzm.js +1 -0
- package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +214 -202
- package/dist/dateHelpers-BKW_lGND.js +1 -0
- package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
- package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
- package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
- package/dist/index-9QF_UfSN.mjs +18668 -0
- package/dist/index-Cq9ya93W.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +74 -64
- package/dist/safeHref-DqJPLPl5.mjs +12 -0
- package/dist/safeHref-DyHIpVjY.js +1 -0
- package/dist/sectionIds-B_tFiNvF.js +1 -0
- package/dist/sectionIds-DBavltrL.mjs +359 -0
- package/dist/sections-BHph7CYj.mjs +9 -0
- package/dist/sections-C2zEJr5G.js +1 -0
- package/dist/sections-more-C1VNVwkp.js +1 -0
- package/dist/sections-more-CMFgfU4d.mjs +3082 -0
- package/dist/src/admin/index.d.ts +3 -3
- package/dist/src/admin/index.d.ts.map +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/admin/types.d.ts +2 -6
- package/dist/src/admin/types.d.ts.map +1 -1
- package/dist/src/admin.d.ts +9 -0
- package/dist/src/admin.d.ts.map +1 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
- package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/configApi.d.ts +1 -1
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +3 -50
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/index.d.ts +1 -1
- package/dist/src/components/admin/index.d.ts.map +1 -1
- package/dist/src/components/admin/types.d.ts +43 -0
- package/dist/src/components/admin/types.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts +2 -0
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
- package/dist/src/ecommerce/config/context.d.ts +2 -0
- package/dist/src/ecommerce/config/context.d.ts.map +1 -1
- package/dist/src/ecommerce/config/types.d.ts +2 -0
- package/dist/src/ecommerce/config/types.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +2 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/featureFlags.d.ts +41 -0
- package/dist/src/featureFlags.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts +1 -0
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +47 -1
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/validateConfig.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +35 -33
- package/dist/styles--fxb3lCl.js +1 -0
- package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
- package/dist/tokenMintValidator-DNBhoefh.js +4 -0
- package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
- package/dist/walletPool-BjTXX6Vn.js +1 -0
- package/package.json +6 -5
- package/dist/AutosaveIndicator-Dn_qA2hK.js +0 -1
- package/dist/CedrosContext-C2RjHLaQ.js +0 -6
- package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
- package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
- package/dist/ComplianceSection-DP2a9-S0.js +0 -1
- package/dist/CryptoButton-DpiCnyXE.js +0 -1
- package/dist/CustomersSection-CBwy_waO.js +0 -1
- package/dist/DisputesSection-BLjIk60n.js +0 -1
- package/dist/FAQSection-wNeH0i6Q.js +0 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
- package/dist/InventorySection-zV6lTmue.js +0 -1
- package/dist/MessagingSection-B_wdFR0j.js +0 -1
- package/dist/OrdersSection-Dw2FX-1d.js +0 -1
- package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
- package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
- package/dist/ReturnsSection-D_pJVxuG.js +0 -1
- package/dist/ShippingSection-1DRSTu49.js +0 -1
- package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
- package/dist/StorefrontSection-RumGkb3C.js +0 -1
- package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
- package/dist/TaxSection-Dt1DnM51.js +0 -1
- package/dist/Token22Section-DY3mUwTY.js +0 -1
- package/dist/WalletManager-B3UdQ5pQ.js +0 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
- package/dist/configApi-DkduMQg1.js +0 -1
- package/dist/index-C0g-JxJk.js +0 -84
- package/dist/index-DXnuQp5x.mjs +0 -22128
- package/dist/sections-C1NpK7hk.mjs +0 -9
- package/dist/sections-DVVSZBhW.js +0 -1
- package/dist/styles-BT4bhFey.js +0 -1
- package/dist/walletPool-IS7R3MR1.js +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useRef as b, useEffect as u } from "react";
|
|
3
|
+
import { I as _ } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
function L({ value: s, onChange: f, options: i, placeholder: h = "Filter", disabled: t }) {
|
|
5
|
+
const [n, c] = v(!1), m = b(null), l = i.find((e) => e.value === s)?.label || h;
|
|
6
|
+
return u(() => {
|
|
7
|
+
const e = (p) => {
|
|
8
|
+
m.current && !m.current.contains(p.target) && c(!1);
|
|
9
|
+
};
|
|
10
|
+
if (n)
|
|
11
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
12
|
+
}, [n]), u(() => {
|
|
13
|
+
const e = (p) => {
|
|
14
|
+
p.key === "Escape" && c(!1);
|
|
15
|
+
};
|
|
16
|
+
if (n)
|
|
17
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
18
|
+
}, [n]), /* @__PURE__ */ a("div", { className: "cedros-admin__dropdown", ref: m, children: [
|
|
19
|
+
/* @__PURE__ */ a(
|
|
20
|
+
"button",
|
|
21
|
+
{
|
|
22
|
+
type: "button",
|
|
23
|
+
className: "cedros-admin__dropdown-trigger",
|
|
24
|
+
onClick: () => !t && c(!n),
|
|
25
|
+
"aria-expanded": n,
|
|
26
|
+
"aria-haspopup": "listbox",
|
|
27
|
+
disabled: t,
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ r("span", { children: l }),
|
|
30
|
+
/* @__PURE__ */ r("span", { className: `cedros-admin__dropdown-chevron ${n ? "cedros-admin__dropdown-chevron--open" : ""}`, children: _.chevronDown })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
n && /* @__PURE__ */ r("div", { className: "cedros-admin__dropdown-menu", role: "listbox", children: i.map((e) => /* @__PURE__ */ a(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
type: "button",
|
|
38
|
+
className: `cedros-admin__dropdown-item ${e.value === s ? "cedros-admin__dropdown-item--selected" : ""}`,
|
|
39
|
+
onClick: () => {
|
|
40
|
+
e.disabled || (f(e.value), c(!1));
|
|
41
|
+
},
|
|
42
|
+
role: "option",
|
|
43
|
+
"aria-selected": e.value === s,
|
|
44
|
+
disabled: e.disabled,
|
|
45
|
+
children: [
|
|
46
|
+
e.label,
|
|
47
|
+
e.value === s && /* @__PURE__ */ r("span", { className: "cedros-admin__dropdown-check", children: _.check })
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
e.value
|
|
51
|
+
)) })
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
function O({ value: s, onChange: f, options: i, label: h, description: t, disabled: n, className: c, style: m }) {
|
|
55
|
+
const [o, l] = v(!1), e = b(null), k = i.find((d) => d.value === s)?.label || "Select...";
|
|
56
|
+
return u(() => {
|
|
57
|
+
const d = (w) => {
|
|
58
|
+
e.current && !e.current.contains(w.target) && l(!1);
|
|
59
|
+
};
|
|
60
|
+
if (o)
|
|
61
|
+
return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
|
|
62
|
+
}, [o]), u(() => {
|
|
63
|
+
const d = (w) => {
|
|
64
|
+
w.key === "Escape" && l(!1);
|
|
65
|
+
};
|
|
66
|
+
if (o)
|
|
67
|
+
return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
|
|
68
|
+
}, [o]), /* @__PURE__ */ a("div", { className: `cedros-admin__field ${c || ""}`, style: m, children: [
|
|
69
|
+
/* @__PURE__ */ r("label", { className: "cedros-admin__field-label", children: h }),
|
|
70
|
+
/* @__PURE__ */ a("div", { className: "cedros-admin__dropdown cedros-admin__dropdown--form", ref: e, children: [
|
|
71
|
+
/* @__PURE__ */ a(
|
|
72
|
+
"button",
|
|
73
|
+
{
|
|
74
|
+
type: "button",
|
|
75
|
+
className: "cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",
|
|
76
|
+
onClick: () => !n && l(!o),
|
|
77
|
+
"aria-expanded": o,
|
|
78
|
+
"aria-haspopup": "listbox",
|
|
79
|
+
disabled: n,
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ r("span", { children: k }),
|
|
82
|
+
/* @__PURE__ */ r("span", { className: `cedros-admin__dropdown-chevron ${o ? "cedros-admin__dropdown-chevron--open" : ""}`, children: _.chevronDown })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
o && /* @__PURE__ */ r("div", { className: "cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form", role: "listbox", children: i.map((d) => /* @__PURE__ */ a(
|
|
87
|
+
"button",
|
|
88
|
+
{
|
|
89
|
+
type: "button",
|
|
90
|
+
className: `cedros-admin__dropdown-item ${d.value === s ? "cedros-admin__dropdown-item--selected" : ""}`,
|
|
91
|
+
onClick: () => {
|
|
92
|
+
d.disabled || (f(d.value), l(!1));
|
|
93
|
+
},
|
|
94
|
+
role: "option",
|
|
95
|
+
"aria-selected": d.value === s,
|
|
96
|
+
disabled: d.disabled,
|
|
97
|
+
children: [
|
|
98
|
+
d.label,
|
|
99
|
+
d.value === s && /* @__PURE__ */ r("span", { className: "cedros-admin__dropdown-check", children: _.check })
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
d.value
|
|
103
|
+
)) })
|
|
104
|
+
] }),
|
|
105
|
+
t && /* @__PURE__ */ r("p", { className: "cedros-admin__field-description", children: t })
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
O as F,
|
|
110
|
+
L as a
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("react/jsx-runtime"),c=require("react"),p=require("./sectionIds-B_tFiNvF.js");function v({value:r,onChange:_,options:i,placeholder:f="Filter",disabled:l}){const[s,a]=c.useState(!1),m=c.useRef(null),t=i.find(e=>e.value===r)?.label||f;return c.useEffect(()=>{const e=u=>{m.current&&!m.current.contains(u.target)&&a(!1)};if(s)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]),c.useEffect(()=>{const e=u=>{u.key==="Escape"&&a(!1)};if(s)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s]),d.jsxs("div",{className:"cedros-admin__dropdown",ref:m,children:[d.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!l&&a(!s),"aria-expanded":s,"aria-haspopup":"listbox",disabled:l,children:[d.jsx("span",{children:t}),d.jsx("span",{className:`cedros-admin__dropdown-chevron ${s?"cedros-admin__dropdown-chevron--open":""}`,children:p.Icons.chevronDown})]}),s&&d.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:i.map(e=>d.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${e.value===r?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{e.disabled||(_(e.value),a(!1))},role:"option","aria-selected":e.value===r,disabled:e.disabled,children:[e.label,e.value===r&&d.jsx("span",{className:"cedros-admin__dropdown-check",children:p.Icons.check})]},e.value))})]})}function b({value:r,onChange:_,options:i,label:f,description:l,disabled:s,className:a,style:m}){const[o,t]=c.useState(!1),e=c.useRef(null),h=i.find(n=>n.value===r)?.label||"Select...";return c.useEffect(()=>{const n=w=>{e.current&&!e.current.contains(w.target)&&t(!1)};if(o)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]),c.useEffect(()=>{const n=w=>{w.key==="Escape"&&t(!1)};if(o)return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[o]),d.jsxs("div",{className:`cedros-admin__field ${a||""}`,style:m,children:[d.jsx("label",{className:"cedros-admin__field-label",children:f}),d.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:e,children:[d.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!s&&t(!o),"aria-expanded":o,"aria-haspopup":"listbox",disabled:s,children:[d.jsx("span",{children:h}),d.jsx("span",{className:`cedros-admin__dropdown-chevron ${o?"cedros-admin__dropdown-chevron--open":""}`,children:p.Icons.chevronDown})]}),o&&d.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:i.map(n=>d.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${n.value===r?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{n.disabled||(_(n.value),t(!1))},role:"option","aria-selected":n.value===r,disabled:n.disabled,children:[n.label,n.value===r&&d.jsx("span",{className:"cedros-admin__dropdown-check",children:p.Icons.check})]},n.value))})]}),l&&d.jsx("p",{className:"cedros-admin__field-description",children:l})]})}exports.FilterDropdown=v;exports.FormDropdown=b;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs as e, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { I as s } from "./sectionIds-DBavltrL.mjs";
|
|
3
|
+
function i({ message: r, onRetry: n }) {
|
|
4
|
+
return r ? /* @__PURE__ */ e("div", { className: "cedros-admin__error-banner", children: [
|
|
5
|
+
/* @__PURE__ */ o("span", { children: r }),
|
|
6
|
+
n && /* @__PURE__ */ e(
|
|
7
|
+
"button",
|
|
8
|
+
{
|
|
9
|
+
type: "button",
|
|
10
|
+
className: "cedros-admin__error-banner-retry",
|
|
11
|
+
onClick: n,
|
|
12
|
+
children: [
|
|
13
|
+
s.refresh,
|
|
14
|
+
" Retry"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
] }) : null;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
i as E
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),s=require("./sectionIds-B_tFiNvF.js");function t({message:n,onRetry:e}){return n?r.jsxs("div",{className:"cedros-admin__error-banner",children:[r.jsx("span",{children:n}),e&&r.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:e,children:[s.Icons.refresh," Retry"]})]}):null}exports.ErrorBanner=t;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as r, useCallback as R, useEffect as V, useMemo as G } from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { I as l } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as H } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { S as Y } from "./StatsBar-D4v-I_Dj.mjs";
|
|
6
|
+
function te({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
|
|
7
|
+
const [_, F] = r([]), [S, C] = r(!0), [E, N] = r(!1), [v, k] = r(null), [Q, I] = r(!1), [y, $] = r(""), [f, x] = r("all"), [q, w] = r(null), [T, b] = r(null), [n, m] = r({
|
|
6
8
|
question: "",
|
|
7
9
|
answer: "",
|
|
8
10
|
keywordsCsv: "",
|
|
@@ -180,7 +182,7 @@ function M({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
|
|
|
180
182
|
}
|
|
181
183
|
)
|
|
182
184
|
] }),
|
|
183
|
-
|
|
185
|
+
E && /* @__PURE__ */ t("div", { className: "cedros-admin__form-container", style: { marginBottom: "1.5rem" }, children: /* @__PURE__ */ a("form", { onSubmit: D, className: "cedros-admin__form", children: [
|
|
184
186
|
/* @__PURE__ */ a("div", { className: "cedros-admin__form-header", children: [
|
|
185
187
|
/* @__PURE__ */ t("h4", { children: v ? "Edit FAQ" : "Add New FAQ" }),
|
|
186
188
|
/* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button--icon", onClick: g, children: l.close })
|
|
@@ -283,7 +285,7 @@ function M({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
|
|
|
283
285
|
)
|
|
284
286
|
] })
|
|
285
287
|
] }) }),
|
|
286
|
-
|
|
288
|
+
S ? /* @__PURE__ */ a("div", { className: "cedros-admin__loading", children: [
|
|
287
289
|
l.loading,
|
|
288
290
|
/* @__PURE__ */ t("span", { children: "Loading FAQs..." })
|
|
289
291
|
] }) : P.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: /* @__PURE__ */ t("p", { children: y || f !== "all" ? "No FAQs match your filters." : "No FAQs yet. Add one to get started." }) }) : /* @__PURE__ */ t("div", { className: "cedros-admin__faq-list", children: P.map((e) => /* @__PURE__ */ a(
|
|
@@ -362,5 +364,5 @@ function M({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
|
|
|
362
364
|
] });
|
|
363
365
|
}
|
|
364
366
|
export {
|
|
365
|
-
|
|
367
|
+
te as FAQSection
|
|
366
368
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),r=require("./sectionIds-B_tFiNvF.js"),R=require("./ErrorBanner-Cx2dUhps.js"),U=require("./StatsBar-m6GSRNxs.js");function V({serverUrl:h,apiKey:d,pageSize:g=20,authManager:o}){const[u,N]=c.useState([]),[Q,w]=c.useState(!0),[S,f]=c.useState(!1),[p,A]=c.useState(null),[F,C]=c.useState(!1),[x,P]=c.useState(""),[v,O]=c.useState("all"),[q,b]=c.useState(null),[E,j]=c.useState(null),[n,l]=c.useState({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),_=c.useCallback(async()=>{w(!0);try{j(null);let s;const t=`/admin/faqs?limit=${g}`;if(o?.isAuthenticated())s=await o.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const a=await fetch(`${h}${t}`,{headers:i});if(!a.ok)throw new Error(`Failed to fetch FAQs: ${a.status}`);s=await a.json()}N(s.faqs||[])}catch{N([]),j("Failed to load FAQs")}finally{w(!1)}},[h,d,g,o]);c.useEffect(()=>{_()},[_]);const $=async s=>{if(s.preventDefault(),!(!n.question.trim()||!n.answer.trim())){C(!0);try{const t=n.keywordsCsv.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),i={question:n.question.trim(),answer:n.answer.trim(),keywords:t,active:n.active,useInChat:n.useInChat,displayOnPage:n.displayOnPage};if(p){const a=`/admin/faqs/${p.id}`;if(o?.isAuthenticated())await o.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};d&&(m["X-API-Key"]=d);const I=await fetch(`${h}${a}`,{method:"PUT",headers:m,body:JSON.stringify(i)});if(!I.ok)throw new Error(`Failed to update FAQ: ${I.status}`)}}else if(o?.isAuthenticated())await o.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};d&&(a["X-API-Key"]=d);const m=await fetch(`${h}/admin/faqs`,{method:"POST",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to create FAQ: ${m.status}`)}y(),_()}catch{j(p?"Failed to update FAQ":"Failed to create FAQ")}finally{C(!1)}}},T=async s=>{try{const t=`/admin/faqs/${s}`;if(o?.isAuthenticated())await o.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const a=await fetch(`${h}${t}`,{method:"DELETE",headers:i});if(!a.ok)throw new Error(`Failed to delete FAQ: ${a.status}`)}_()}catch{j("Failed to delete FAQ")}b(null)},D=async s=>{try{const t=`/admin/faqs/${s.id}`,i={...s,active:!s.active};if(o?.isAuthenticated())await o.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};d&&(a["X-API-Key"]=d);const m=await fetch(`${h}${t}`,{method:"PUT",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to update FAQ: ${m.status}`)}_()}catch{j("Failed to update FAQ status")}},y=()=>{l({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),A(null),f(!1)},L=s=>{l({question:s.question,answer:s.answer,keywordsCsv:s.keywords.join(", "),active:s.active,useInChat:s.useInChat??!0,displayOnPage:s.displayOnPage??!0}),A(s),f(!0)},B=u.length,W=u.filter(s=>s.active).length,J=u.filter(s=>s.active&&s.useInChat).length,X=u.filter(s=>s.active&&s.displayOnPage).length,k=c.useMemo(()=>u.filter(s=>{if(v==="active"&&!s.active||v==="inactive"&&s.active)return!1;if(x){const t=x.toLowerCase();return s.question.toLowerCase().includes(t)||s.answer.toLowerCase().includes(t)||s.keywords.some(i=>i.includes(t))}return!0}),[u,v,x]);return e.jsxs("div",{className:"cedros-admin__faqs",children:[e.jsx(R.ErrorBanner,{message:E,onRetry:_}),e.jsx(U.StatsBar,{stats:[{label:"Total FAQs",value:B},{label:"Active",value:W,variant:"success"},{label:"In Chat",value:J},{label:"On Page",value:X}]}),e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{className:"cedros-admin__section-header-left",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Knowledge Base"}),e.jsx("p",{className:"cedros-admin__section-subtitle",children:"Manage FAQs for the AI chat assistant and public FAQ page."})]}),e.jsx("div",{className:"cedros-admin__section-header-right",children:e.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{y(),f(!0)},children:[r.Icons.plus," Add FAQ"]})})]}),e.jsxs("div",{className:"cedros-admin__filters",style:{display:"flex",gap:"1rem",marginBottom:"1rem"},children:[e.jsx("input",{type:"text",placeholder:"Search FAQs...",value:x,onChange:s=>P(s.target.value),className:"cedros-admin__input",style:{flex:1,maxWidth:300}}),e.jsxs("select",{value:v,onChange:s=>O(s.target.value),className:"cedros-admin__select",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"active",children:"Active Only"}),e.jsx("option",{value:"inactive",children:"Inactive Only"})]})]}),S&&e.jsx("div",{className:"cedros-admin__form-container",style:{marginBottom:"1.5rem"},children:e.jsxs("form",{onSubmit:$,className:"cedros-admin__form",children:[e.jsxs("div",{className:"cedros-admin__form-header",children:[e.jsx("h4",{children:p?"Edit FAQ":"Add New FAQ"}),e.jsx("button",{type:"button",className:"cedros-admin__button--icon",onClick:y,children:r.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Question *"}),e.jsx("input",{type:"text",value:n.question,onChange:s=>l(t=>({...t,question:s.target.value})),className:"cedros-admin__input",placeholder:"What is your return policy?",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Answer *"}),e.jsx("textarea",{value:n.answer,onChange:s=>l(t=>({...t,answer:s.target.value})),className:"cedros-admin__textarea",placeholder:"We accept returns within 30 days...",rows:4,required:!0}),e.jsx("span",{className:"cedros-admin__hint",children:"Supports markdown formatting."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Keywords"}),e.jsx("input",{type:"text",value:n.keywordsCsv,onChange:s=>l(t=>({...t,keywordsCsv:s.target.value})),className:"cedros-admin__input",placeholder:"returns, refund, policy"}),e.jsx("span",{className:"cedros-admin__hint",children:"Comma-separated keywords to help AI find this FAQ."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:s=>l(t=>({...t,active:s.target.checked}))}),e.jsx("span",{children:"Active"})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Inactive FAQs won't appear anywhere."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Visibility"}),e.jsxs("div",{className:"cedros-admin__checkbox-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.useInChat,onChange:s=>l(t=>({...t,useInChat:s.target.checked}))}),e.jsx("span",{children:"Use in AI Chat"})]}),e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.displayOnPage,onChange:s=>l(t=>({...t,displayOnPage:s.target.checked}))}),e.jsx("span",{children:"Display on FAQ Page"})]})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Choose where this FAQ should appear."})]}),e.jsxs("div",{className:"cedros-admin__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-admin__button",onClick:y,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:F||!n.question.trim()||!n.answer.trim(),children:F?r.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[r.Icons.loading,e.jsx("span",{children:"Loading FAQs..."})]}):k.length===0?e.jsx("div",{className:"cedros-admin__empty",children:e.jsx("p",{children:x||v!=="all"?"No FAQs match your filters.":"No FAQs yet. Add one to get started."})}):e.jsx("div",{className:"cedros-admin__faq-list",children:k.map(s=>e.jsxs("div",{className:`cedros-admin__faq-item ${s.active?"":"cedros-admin__faq-item--inactive"}`,children:[e.jsxs("div",{className:"cedros-admin__faq-content",children:[e.jsxs("div",{className:"cedros-admin__faq-question",children:[e.jsx("span",{className:`cedros-admin__status-dot ${s.active?"cedros-admin__status-dot--active":"cedros-admin__status-dot--inactive"}`}),s.question]}),e.jsx("div",{className:"cedros-admin__faq-answer",children:s.answer}),e.jsxs("div",{className:"cedros-admin__faq-meta",children:[s.keywords.length>0&&e.jsx("div",{className:"cedros-admin__faq-keywords",children:s.keywords.map(t=>e.jsx("span",{className:"cedros-admin__tag",children:t},t))}),e.jsxs("div",{className:"cedros-admin__faq-visibility",children:[s.useInChat&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--chat",title:"Used in AI Chat",children:[r.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[r.Icons.globe," Page"]})]})]})]}),e.jsxs("div",{className:"cedros-admin__faq-actions",children:[e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>D(s),title:s.active?"Deactivate":"Activate",children:s.active?r.Icons.eyeOff:r.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:r.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:r.Icons.trash})]}),q===s.id&&e.jsx("div",{className:"cedros-admin__confirm-overlay",children:e.jsxs("div",{className:"cedros-admin__confirm-dialog",children:[e.jsx("p",{children:"Delete this FAQ?"}),e.jsxs("div",{className:"cedros-admin__confirm-actions",children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>b(null),children:"Cancel"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger",onClick:()=>T(s.id),children:"Delete"})]})]})})]},s.id))})]})]})}exports.FAQSection=V;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),h=require("./sectionIds-B_tFiNvF.js"),A=require("./ErrorBanner-Cx2dUhps.js"),O=require("./dateHelpers-BKW_lGND.js"),v=require("./fetchWithTimeout-CG0EKbhf.js");async function R(a,n,l,c){const o=new FormData;if(o.append("file",c),l?.isAuthenticated())return l.fetchWithAuth("/admin/images/upload",{method:"POST",body:o,headers:{}});const r={};n&&(r["X-API-Key"]=n);const d=await fetch(`${a}/admin/images/upload`,{method:"POST",headers:r,body:o});if(!d.ok)throw new Error(`Upload failed: ${d.status}`);return d.json()}async function F(a,n,l,c){const o=JSON.stringify({url:c});if(l?.isAuthenticated()){await l.fetchWithAuth("/admin/images",{method:"DELETE",body:o});return}const r={"Content-Type":"application/json"};n&&(r["X-API-Key"]=n);const d=await fetch(`${a}/admin/images`,{method:"DELETE",headers:r,body:o});if(!d.ok)throw new Error(`Delete failed: ${d.status}`)}function z({serverUrl:a,apiKey:n,authManager:l}){const[c,o]=i.useState([]),[r,d]=i.useState(!1),[x,j]=i.useState(null),[D,m]=i.useState(null),[_,S]=i.useState(null),[p,f]=i.useState(!1),[u,g]=i.useState(null),b=i.useRef(null),w=i.useCallback(async t=>{d(!0),m(null);try{const s=await R(a,n,l,t);o(y=>[{url:s.url,thumbUrl:s.thumbUrl,uploadedAt:new Date().toISOString()},...y]),g(null),b.current&&(b.current.value="")}catch(s){v.getLogger().error("[ImagesSection] Upload failed:",s,{serverUrl:a.slice(0,20)+"..."}),m("Upload failed. Check file type and try again.")}finally{d(!1)}},[a,n,l]),I=t=>{const s=t.target.files?.[0]??null;g(s),m(null)},C=()=>{u&&w(u)},U=t=>{t.preventDefault(),f(!0)},N=()=>f(!1),k=t=>{t.preventDefault(),f(!1);const s=t.dataTransfer.files?.[0];s&&s.type.startsWith("image/")?(g(s),m(null)):s&&m("Only image files are accepted.")},T=i.useCallback(async t=>{j(t),m(null);try{await F(a,n,l,t),o(s=>s.filter(y=>y.url!==t))}catch(s){v.getLogger().error("[ImagesSection] Delete failed:",s,{serverUrl:a.slice(0,20)+"..."}),m("Failed to delete image.")}finally{j(null)}},[a,n,l]),E=async t=>{try{await navigator.clipboard.writeText(t),S(t),setTimeout(()=>S(null),2e3)}catch{m("Could not copy to clipboard.")}},L=["cedros-admin__drop-zone",p?"cedros-admin__drop-zone--active":""].filter(Boolean).join(" ");return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(A.ErrorBanner,{message:D}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Image Upload"})}),e.jsxs("div",{className:L,onDragOver:U,onDragLeave:N,onDrop:k,role:"region","aria-label":"Image drop zone",style:{border:"2px dashed",borderColor:p?"var(--cedros-accent, #6366f1)":"var(--cedros-border, #e2e8f0)",borderRadius:"0.5rem",padding:"1.5rem",textAlign:"center",marginBottom:"1rem",transition:"border-color 0.15s",backgroundColor:p?"var(--cedros-accent-subtle, rgba(99,102,241,0.06))":void 0},children:[e.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:"Drag and drop an image here, or select a file below"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"center",alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{ref:b,id:"cedros-image-file-input",type:"file",accept:"image/*",className:"cedros-admin__input",style:{maxWidth:260},onChange:I,"aria-label":"Select image file"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:!u||r,"aria-busy":r,children:r?e.jsxs(e.Fragment,{children:[h.Icons.loading," Uploading..."]}):"Upload"})]}),u&&!r&&e.jsxs("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",opacity:.65},children:["Selected: ",u.name," (",(u.size/1024).toFixed(1)," KB)"]})]}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Uploaded This Session",c.length>0&&e.jsx("span",{className:"cedros-admin__section-badge",style:{marginLeft:"0.5rem"},children:c.length})]})}),c.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No images uploaded yet."}):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:"Preview"}),e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Uploaded"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:c.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{width:72},children:e.jsx("img",{src:t.thumbUrl,alt:"Thumbnail preview",style:{width:56,height:56,objectFit:"cover",borderRadius:"0.25rem",display:"block"}})}),e.jsx("td",{style:{maxWidth:320,wordBreak:"break-all"},children:e.jsx("code",{style:{fontSize:"0.8rem"},children:t.url})}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:O.formatDateTime(t.uploadedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem"},children:[e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>E(t.url),"aria-label":"Copy URL to clipboard",title:"Copy URL",children:[_===t.url?h.Icons.check:h.Icons.eye,_===t.url?"Copied":"Copy URL"]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--destructive",onClick:()=>T(t.url),disabled:x===t.url,"aria-label":"Delete image",title:"Delete",children:[x===t.url?h.Icons.loading:h.Icons.trash,"Delete"]})]})})]},t.url))})]})})]})}exports.ImagesSection=z;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsxs as l, jsx as t, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import { useState as h, useRef as j, useCallback as U } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { I as u } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as z } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { f as B } from "./dateHelpers-yvPkofYQ.mjs";
|
|
6
|
+
import { g as I } from "./fetchWithTimeout-DmMOwL0Q.mjs";
|
|
5
7
|
async function W(r, n, i, c) {
|
|
6
8
|
const d = new FormData();
|
|
7
9
|
if (d.append("file", c), i?.isAuthenticated())
|
|
@@ -37,7 +39,7 @@ async function P(r, n, i, c) {
|
|
|
37
39
|
});
|
|
38
40
|
if (!s.ok) throw new Error(`Delete failed: ${s.status}`);
|
|
39
41
|
}
|
|
40
|
-
function
|
|
42
|
+
function H({ serverUrl: r, apiKey: n, authManager: i }) {
|
|
41
43
|
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
44
|
s(!0), m(null);
|
|
43
45
|
try {
|
|
@@ -212,5 +214,5 @@ function q({ serverUrl: r, apiKey: n, authManager: i }) {
|
|
|
212
214
|
] });
|
|
213
215
|
}
|
|
214
216
|
export {
|
|
215
|
-
|
|
217
|
+
H as ImagesSection
|
|
216
218
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),b=require("./sectionIds-B_tFiNvF.js"),L=require("./ErrorBanner-Cx2dUhps.js"),B=require("./dateHelpers-BKW_lGND.js"),S=require("./fetchWithTimeout-CG0EKbhf.js"),c=50;function k({serverUrl:o,apiKey:m,authManager:h}){const[y,N]=s.useState([]),[A,_]=s.useState(!0),[P,g]=s.useState(null),[d,I]=s.useState(""),[i,j]=s.useState([]),[w,p]=s.useState(!1),[E,f]=s.useState(null),[a,x]=s.useState(0),l=s.useCallback(async t=>{if(h?.isAuthenticated())return h.fetchWithAuth(t);const n={"Content-Type":"application/json"};m&&(n["X-API-Key"]=m);const r=await fetch(`${o}${t}`,{headers:n});if(!r.ok)throw new Error(`Request failed: ${r.status}`);return r.json()},[o,m,h]);s.useEffect(()=>{let t=!1;return _(!0),g(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:o.slice(0,20)+"..."}),g("Failed to load products"))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[l,o]);const v=s.useCallback(async(t,n)=>{if(t){p(!0),f(null);try{const r=`/admin/products/${encodeURIComponent(t)}/inventory/adjustments?limit=${c}&offset=${n}`,F=await l(r);j(F.adjustments??[])}catch(r){S.getLogger().error("[InventorySection] Failed to load adjustments:",r,{productId:t,serverUrl:o.slice(0,20)+"..."}),f("Failed to load inventory adjustments"),j([])}finally{p(!1)}}},[l,o]);s.useEffect(()=>{d&&v(d,a)},[v,d,a]);const C=t=>{I(t),x(0),j([]),f(null)},q=()=>x(t=>Math.max(0,t-c)),$=()=>x(t=>t+c),u=y.find(t=>t.id===d);return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(L.ErrorBanner,{message:P??E}),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:[b.Icons.loading," Loading products..."]}):e.jsxs("select",{id:"inventory-product-select",className:"cedros-admin__input",value:d,onChange:t=>C(t.target.value),"aria-label":"Select product to view inventory adjustments",children:[e.jsx("option",{value:"",children:"-- Choose a product --"}),y.map(t=>e.jsx("option",{value:t.id,children:t.title??t.description??t.id},t.id))]})]})})}),d?w?e.jsxs("div",{className:"cedros-admin__loading",children:[b.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:B.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:q,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:$,children:"Next"})]})]})]}):e.jsx("div",{className:"cedros-admin__empty",children:"Select a product to view its inventory adjustments."})]})}exports.InventorySection=k;
|
|
@@ -1,56 +1,58 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t, Fragment as P } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useState as o, useCallback as S, useEffect as w } from "react";
|
|
3
|
+
import { I as j } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as R } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { f as T } from "./dateHelpers-yvPkofYQ.mjs";
|
|
6
|
+
import { g as E } from "./fetchWithTimeout-DmMOwL0Q.mjs";
|
|
5
7
|
const a = 50;
|
|
6
|
-
function
|
|
7
|
-
const [g, I] =
|
|
8
|
+
function H({ serverUrl: d, apiKey: h, authManager: f }) {
|
|
9
|
+
const [g, I] = o([]), [C, v] = o(!0), [$, b] = o(null), [i, x] = o(""), [c, p] = o([]), [F, N] = o(!1), [L, _] = o(null), [l, y] = o(0), m = S(async (e) => {
|
|
8
10
|
if (f?.isAuthenticated())
|
|
9
11
|
return f.fetchWithAuth(e);
|
|
10
12
|
const s = { "Content-Type": "application/json" };
|
|
11
13
|
h && (s["X-API-Key"] = h);
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
return
|
|
15
|
-
}, [
|
|
14
|
+
const r = await fetch(`${d}${e}`, { headers: s });
|
|
15
|
+
if (!r.ok) throw new Error(`Request failed: ${r.status}`);
|
|
16
|
+
return r.json();
|
|
17
|
+
}, [d, h, f]);
|
|
16
18
|
w(() => {
|
|
17
19
|
let e = !1;
|
|
18
20
|
return v(!0), b(null), m("/admin/products?limit=100&offset=0").then((s) => {
|
|
19
21
|
if (e) return;
|
|
20
|
-
const
|
|
21
|
-
I(
|
|
22
|
+
const r = Array.isArray(s) ? s : s.products ?? [];
|
|
23
|
+
I(r);
|
|
22
24
|
}).catch((s) => {
|
|
23
25
|
e || (E().error("[InventorySection] Failed to load products:", s, {
|
|
24
|
-
serverUrl:
|
|
26
|
+
serverUrl: d.slice(0, 20) + "..."
|
|
25
27
|
}), b("Failed to load products"));
|
|
26
28
|
}).finally(() => {
|
|
27
29
|
e || v(!1);
|
|
28
30
|
}), () => {
|
|
29
31
|
e = !0;
|
|
30
32
|
};
|
|
31
|
-
}, [m,
|
|
33
|
+
}, [m, d]);
|
|
32
34
|
const A = S(async (e, s) => {
|
|
33
35
|
if (e) {
|
|
34
36
|
N(!0), _(null);
|
|
35
37
|
try {
|
|
36
|
-
const
|
|
38
|
+
const r = `/admin/products/${encodeURIComponent(e)}/inventory/adjustments?limit=${a}&offset=${s}`, q = await m(r);
|
|
37
39
|
p(q.adjustments ?? []);
|
|
38
|
-
} catch (
|
|
39
|
-
E().error("[InventorySection] Failed to load adjustments:",
|
|
40
|
+
} catch (r) {
|
|
41
|
+
E().error("[InventorySection] Failed to load adjustments:", r, {
|
|
40
42
|
productId: e,
|
|
41
|
-
serverUrl:
|
|
43
|
+
serverUrl: d.slice(0, 20) + "..."
|
|
42
44
|
}), _("Failed to load inventory adjustments"), p([]);
|
|
43
45
|
} finally {
|
|
44
46
|
N(!1);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
|
-
}, [m,
|
|
49
|
+
}, [m, d]);
|
|
48
50
|
w(() => {
|
|
49
51
|
i && A(i, l);
|
|
50
52
|
}, [A, i, l]);
|
|
51
|
-
const
|
|
53
|
+
const B = (e) => {
|
|
52
54
|
x(e), y(0), p([]), _(null);
|
|
53
|
-
},
|
|
55
|
+
}, k = () => y((e) => Math.max(0, e - a)), D = () => y((e) => e + a), u = g.find((e) => e.id === i);
|
|
54
56
|
return /* @__PURE__ */ n("div", { className: "cedros-admin__page", children: [
|
|
55
57
|
/* @__PURE__ */ t(R, { message: $ ?? L }),
|
|
56
58
|
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Inventory Adjustments" }) }),
|
|
@@ -65,7 +67,7 @@ function X({ serverUrl: o, apiKey: h, authManager: f }) {
|
|
|
65
67
|
id: "inventory-product-select",
|
|
66
68
|
className: "cedros-admin__input",
|
|
67
69
|
value: i,
|
|
68
|
-
onChange: (e) =>
|
|
70
|
+
onChange: (e) => B(e.target.value),
|
|
69
71
|
"aria-label": "Select product to view inventory adjustments",
|
|
70
72
|
children: [
|
|
71
73
|
/* @__PURE__ */ t("option", { value: "", children: "-- Choose a product --" }),
|
|
@@ -118,7 +120,7 @@ function X({ serverUrl: o, apiKey: h, authManager: f }) {
|
|
|
118
120
|
type: "button",
|
|
119
121
|
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
120
122
|
disabled: l === 0,
|
|
121
|
-
onClick:
|
|
123
|
+
onClick: k,
|
|
122
124
|
children: "Previous"
|
|
123
125
|
}
|
|
124
126
|
),
|
|
@@ -146,5 +148,5 @@ function X({ serverUrl: o, apiKey: h, authManager: f }) {
|
|
|
146
148
|
] });
|
|
147
149
|
}
|
|
148
150
|
export {
|
|
149
|
-
|
|
151
|
+
H as InventorySection
|
|
150
152
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),q=require("./sectionIds-B_tFiNvF.js"),M=require("./ErrorBanner-Cx2dUhps.js"),y=require("./Toggle-CsPSF8Dr.js"),z=require("./useAutosave-B2p6iwh8.js"),R=require("./AutosaveIndicator-DiyeAg93.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 W(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 U({serverUrl:c,apiKey:d,authManager:n}){const[m,b]=l.useState("messages"),[a,h]=l.useState(v),[S,N]=l.useState(!0),[k,C]=l.useState(!0),[E,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=W(i.smtp_host)),h(i)}catch{h(v),f("Could not load saved settings. Showing defaults.")}finally{N(!1),setTimeout(()=>C(!1),100)}},[c,d,n]);l.useEffect(()=>{g()},[g]);const P=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:T,error:A}=z.useAutosave({data:a,onSave:P,debounceMs:1500,enabled:!k}),r=(s,t)=>{(s==="smtp_password"||s==="webhook_secret")&&j(i=>new Set(i).add(s)),h(i=>({...i,[s]:t}))},I=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:"")}))},L=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 S?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:[q.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(R.AutosaveIndicator,{status:T,error:A})]}),e.jsx(M.ErrorBanner,{message:E,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(y.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(y.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=>I(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=>L(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=U;
|
|
@@ -1,9 +1,10 @@
|
|
|
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
|
|
3
|
+
import { I as $ } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as q } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
4
5
|
import { T as C } from "./Toggle-DAxIdpY4.mjs";
|
|
5
6
|
import { u as F } from "./useAutosave-YwMqRzqy.mjs";
|
|
6
|
-
import { A as j } from "./AutosaveIndicator-
|
|
7
|
+
import { A as j } from "./AutosaveIndicator-BEvABoKU.mjs";
|
|
7
8
|
const u = {
|
|
8
9
|
mailgun: { label: "Mailgun", host: "smtp.mailgun.org", username: "", credentialLabel: "SMTP Password", showUsername: !0, usernameEqualsPassword: !1 },
|
|
9
10
|
sendgrid: { label: "SendGrid", host: "smtp.sendgrid.net", username: "apikey", credentialLabel: "API Key", showUsername: !1, usernameEqualsPassword: !1 },
|
|
@@ -32,7 +33,7 @@ const y = {
|
|
|
32
33
|
webhook_secret: "",
|
|
33
34
|
webhook_timeout: 30
|
|
34
35
|
};
|
|
35
|
-
function
|
|
36
|
+
function Y({ serverUrl: m, apiKey: l, authManager: d }) {
|
|
36
37
|
const [c, f] = _("messages"), [s, h] = _(y), [E, P] = _(!0), [x, T] = _(!0), [A, g] = _(null), [b, S] = _(/* @__PURE__ */ new Set()), v = k(async () => {
|
|
37
38
|
try {
|
|
38
39
|
g(null);
|
|
@@ -390,5 +391,5 @@ function V({ serverUrl: m, apiKey: l, authManager: d }) {
|
|
|
390
391
|
] });
|
|
391
392
|
}
|
|
392
393
|
export {
|
|
393
|
-
|
|
394
|
+
Y as MessagingSection
|
|
394
395
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),A=require("./sectionIds-B_tFiNvF.js"),B=require("./ErrorBanner-Cx2dUhps.js"),k=require("./dateHelpers-BKW_lGND.js"),C=require("./safeHref-DyHIpVjY.js");function P({serverUrl:n,apiKey:r,pageSize:o=20,authManager:d}){const[l,s]=a.useState([]),[c,f]=a.useState(0),[L,y]=a.useState(!0),[v,b]=a.useState(null),[u,S]=a.useState(null),[R,p]=a.useState(null),[$,_]=a.useState([]),[F,N]=a.useState(!1),[x,O]=a.useState(""),h=a.useCallback(async(t,i)=>{if(d?.isAuthenticated())return d.fetchWithAuth(t,i);const g={"Content-Type":"application/json"};r&&(g["X-API-Key"]=r);const m=await fetch(`${n}${t}`,{...i,headers:{...g,...i?.headers}});if(!m.ok){const E=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(E)}return m.json()},[n,r,d]),j=a.useCallback(async()=>{y(!0);try{b(null);const t=new URLSearchParams({limit:String(o)});x&&t.set("status",x);const i=await h(`/admin/orders?${t}`);s(i.orders),f(i.total)}catch{b("Failed to load orders")}finally{y(!1)}},[h,o,x]);a.useEffect(()=>{j()},[j]);const T=a.useCallback(async t=>{N(!0);try{const[i,g]=await Promise.all([h(`/admin/orders/${encodeURIComponent(t)}`),h("/admin/gift-card-redemptions?limit=50").catch(()=>[])]);p(i),_(g.filter(m=>m.orderId===t))}catch{p(null),_([])}finally{N(!1)}},[h]),D=t=>{u===t?(S(null),p(null),_([])):(S(t),T(t))},I=(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:x,onChange:t=>O(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:j,children:[A.Icons.refresh," Refresh"]})]})]}),v?e.jsx(B.ErrorBanner,{message:v,onRetry:j}):null,L?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(q,{order:t,expanded:u===t.id,detail:u===t.id?R:null,redemptions:u===t.id?$:[],detailLoading:u===t.id&&F,onToggle:()=>D(t.id),formatAmount:I},t.id))})]})]})]})}function q({order:n,expanded:r,detail:o,redemptions:d,detailLoading:l,onToggle:s,formatAmount:c}){const f=n.metadata?.recipient_email||d.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:s,style:{cursor:"pointer"},className:r?"cedros-admin__table-row--active":"",children:[e.jsxs("td",{children:[e.jsxs("span",{className:"cedros-admin__mono",children:[n.id.slice(0,12),"..."]}),f?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--${w(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:k.formatDateTime(n.createdAt)})]}),r?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:0},children:e.jsx(H,{detail:o,redemptions:d,loading:l,formatAmount:c,metadata:n.metadata})})}):null]})}function H({detail:n,redemptions:r,loading:o,formatAmount:d,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,r.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Gift Card Fulfillment"}),r.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: ",d(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--${w(s.status)}`,children:s.status}),s.carrier?e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.carrier}):null,s.trackingNumber?C.safeHref(s.trackingUrl)?e.jsx("a",{href:C.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:k.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 w(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=P;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { jsxs as i, jsx as e, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { I as z
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { useState as s, useCallback as N, useEffect as U } from "react";
|
|
3
|
+
import { I as z } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as G } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { f as F } from "./dateHelpers-yvPkofYQ.mjs";
|
|
6
|
+
import { s as k } from "./safeHref-DqJPLPl5.mjs";
|
|
7
|
+
function Y({ serverUrl: a, apiKey: r, pageSize: m = 20, authManager: l }) {
|
|
8
|
+
const [c, t] = s([]), [o, y] = s(0), [R, x] = s(!0), [S, C] = s(null), [h, w] = s(null), [D, v] = s(null), [E, b] = s([]), [O, L] = s(!1), [g, T] = s(""), f = N(async (n, d) => {
|
|
6
9
|
if (l?.isAuthenticated())
|
|
7
10
|
return l.fetchWithAuth(n, d);
|
|
8
11
|
const _ = { "Content-Type": "application/json" };
|
|
9
|
-
|
|
12
|
+
r && (_["X-API-Key"] = r);
|
|
10
13
|
const u = await fetch(`${a}${n}`, { ...d, headers: { ..._, ...d?.headers } });
|
|
11
14
|
if (!u.ok) {
|
|
12
15
|
const P = await u.text().catch(() => `HTTP ${u.status}`);
|
|
13
16
|
throw new Error(P);
|
|
14
17
|
}
|
|
15
18
|
return u.json();
|
|
16
|
-
}, [a,
|
|
19
|
+
}, [a, r, l]), p = N(async () => {
|
|
17
20
|
x(!0);
|
|
18
21
|
try {
|
|
19
22
|
C(null);
|
|
20
23
|
const n = new URLSearchParams({ limit: String(m) });
|
|
21
|
-
|
|
22
|
-
const d = await
|
|
24
|
+
g && n.set("status", g);
|
|
25
|
+
const d = await f(
|
|
23
26
|
`/admin/orders?${n}`
|
|
24
27
|
);
|
|
25
28
|
t(d.orders), y(d.total);
|
|
@@ -28,25 +31,25 @@ function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
|
|
|
28
31
|
} finally {
|
|
29
32
|
x(!1);
|
|
30
33
|
}
|
|
31
|
-
}, [
|
|
34
|
+
}, [f, m, g]);
|
|
32
35
|
U(() => {
|
|
33
36
|
p();
|
|
34
37
|
}, [p]);
|
|
35
38
|
const A = N(async (n) => {
|
|
36
|
-
|
|
39
|
+
L(!0);
|
|
37
40
|
try {
|
|
38
41
|
const [d, _] = await Promise.all([
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
f(`/admin/orders/${encodeURIComponent(n)}`),
|
|
43
|
+
f("/admin/gift-card-redemptions?limit=50").catch(() => [])
|
|
41
44
|
]);
|
|
42
45
|
v(d), b(_.filter((u) => u.orderId === n));
|
|
43
46
|
} catch {
|
|
44
47
|
v(null), b([]);
|
|
45
48
|
} finally {
|
|
46
|
-
|
|
49
|
+
L(!1);
|
|
47
50
|
}
|
|
48
|
-
}, [
|
|
49
|
-
h === n ? (
|
|
51
|
+
}, [f]), j = (n) => {
|
|
52
|
+
h === n ? (w(null), v(null), b([])) : (w(n), A(n));
|
|
50
53
|
}, B = (n, d) => d === "USD" || d === "usd" ? `$${(n / 100).toFixed(2)}` : `${n} ${d}`;
|
|
51
54
|
return /* @__PURE__ */ i("div", { className: "cedros-admin__section", children: [
|
|
52
55
|
/* @__PURE__ */ i("div", { className: "cedros-admin__section-header", children: [
|
|
@@ -57,7 +60,7 @@ function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
|
|
|
57
60
|
{
|
|
58
61
|
className: "cedros-admin__input",
|
|
59
62
|
style: { width: "auto", minWidth: "120px" },
|
|
60
|
-
value:
|
|
63
|
+
value: g,
|
|
61
64
|
onChange: (n) => T(n.target.value),
|
|
62
65
|
children: [
|
|
63
66
|
/* @__PURE__ */ e("option", { value: "", children: "All statuses" }),
|
|
@@ -113,7 +116,7 @@ function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
|
|
|
113
116
|
}
|
|
114
117
|
function H({
|
|
115
118
|
order: a,
|
|
116
|
-
expanded:
|
|
119
|
+
expanded: r,
|
|
117
120
|
detail: m,
|
|
118
121
|
redemptions: l,
|
|
119
122
|
detailLoading: c,
|
|
@@ -127,7 +130,7 @@ function H({
|
|
|
127
130
|
{
|
|
128
131
|
onClick: t,
|
|
129
132
|
style: { cursor: "pointer" },
|
|
130
|
-
className:
|
|
133
|
+
className: r ? "cedros-admin__table-row--active" : "",
|
|
131
134
|
children: [
|
|
132
135
|
/* @__PURE__ */ i("td", { children: [
|
|
133
136
|
/* @__PURE__ */ i("span", { className: "cedros-admin__mono", children: [
|
|
@@ -144,7 +147,7 @@ function H({
|
|
|
144
147
|
]
|
|
145
148
|
}
|
|
146
149
|
),
|
|
147
|
-
|
|
150
|
+
r ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 6, style: { padding: 0 }, children: /* @__PURE__ */ e(
|
|
148
151
|
W,
|
|
149
152
|
{
|
|
150
153
|
detail: m,
|
|
@@ -158,7 +161,7 @@ function H({
|
|
|
158
161
|
}
|
|
159
162
|
function W({
|
|
160
163
|
detail: a,
|
|
161
|
-
redemptions:
|
|
164
|
+
redemptions: r,
|
|
162
165
|
loading: m,
|
|
163
166
|
formatAmount: l,
|
|
164
167
|
metadata: c
|
|
@@ -171,9 +174,9 @@ function W({
|
|
|
171
174
|
/* @__PURE__ */ e("span", { children: o })
|
|
172
175
|
] }, t)) })
|
|
173
176
|
] }) : null,
|
|
174
|
-
|
|
177
|
+
r.length > 0 ? /* @__PURE__ */ i("div", { style: { marginBottom: "1rem" }, children: [
|
|
175
178
|
/* @__PURE__ */ e("div", { className: "cedros-admin__label", children: "Gift Card Fulfillment" }),
|
|
176
|
-
|
|
179
|
+
r.map((t) => /* @__PURE__ */ i("div", { style: { fontSize: "0.8125rem", padding: "0.5rem", border: "1px solid var(--cedros-admin-border)", borderRadius: "0.5rem", marginBottom: "0.5rem" }, children: [
|
|
177
180
|
/* @__PURE__ */ i("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
178
181
|
/* @__PURE__ */ i("span", { children: [
|
|
179
182
|
"Face value: ",
|
|
@@ -193,7 +196,7 @@ function W({
|
|
|
193
196
|
a.fulfillments.map((t) => /* @__PURE__ */ i("div", { style: { fontSize: "0.8125rem", marginBottom: "0.25rem" }, children: [
|
|
194
197
|
/* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${I(t.status)}`, children: t.status }),
|
|
195
198
|
t.carrier ? /* @__PURE__ */ e("span", { style: { marginLeft: "0.5rem" }, children: t.carrier }) : null,
|
|
196
|
-
t.trackingNumber ?
|
|
199
|
+
t.trackingNumber ? k(t.trackingUrl) ? /* @__PURE__ */ e("a", { href: k(t.trackingUrl), target: "_blank", rel: "noreferrer", style: { marginLeft: "0.5rem" }, children: t.trackingNumber }) : /* @__PURE__ */ e("span", { style: { marginLeft: "0.5rem" }, children: t.trackingNumber }) : null
|
|
197
200
|
] }, t.id))
|
|
198
201
|
] }) : null,
|
|
199
202
|
a?.history && a.history.length > 0 ? /* @__PURE__ */ i("div", { children: [
|
|
@@ -229,5 +232,5 @@ function I(a) {
|
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
export {
|
|
232
|
-
|
|
235
|
+
Y as OrdersSection
|
|
233
236
|
};
|