@cedros/pay-react 1.1.23 → 1.1.24
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-DpMIk431.mjs → AISettingsSection-Dw0ZlxMf.mjs} +2 -2
- package/dist/{AISettingsSection-DAztmwnN.js → AISettingsSection-IXS1Wt_1.js} +1 -1
- package/dist/{AutosaveIndicator-BRCqAWqP.mjs → AutosaveIndicator-BJsg_kFZ.mjs} +1 -1
- package/dist/{AutosaveIndicator-BnQkKxzr.js → AutosaveIndicator-CY_YHM1D.js} +1 -1
- package/dist/{CedrosContext-BlArEF7k.mjs → CedrosContext-DQUbL8yP.mjs} +17 -17
- package/dist/{CryptoButton-CREryx1l.mjs → CryptoButton-D1BCZBk4.mjs} +51 -51
- package/dist/{FAQSection-yw64HLy3.js → FAQSection-BmgmzDN5.js} +1 -1
- package/dist/{FAQSection-Ruzs7a-0.mjs → FAQSection-C78MnK4k.mjs} +1 -1
- package/dist/{MessagingSection-Dp_SaXsv.js → MessagingSection-CWLZcg11.js} +1 -1
- package/dist/{MessagingSection-BLRjfBQT.mjs → MessagingSection-De3t8bSI.mjs} +2 -2
- package/dist/{OrdersSection-C2dyWqrR.js → OrdersSection-BKOxsZw0.js} +1 -1
- package/dist/{OrdersSection-l-MtP9EN.mjs → OrdersSection-_xKVzjSZ.mjs} +1 -1
- package/dist/{PaymentSettingsSection-C5bhLgU7.js → PaymentSettingsSection-BTEn9Dxb.js} +1 -1
- package/dist/{PaymentSettingsSection-Bbq93UtC.mjs → PaymentSettingsSection-KjU_dN_d.mjs} +1 -1
- package/dist/{SettingsSection-DorqCFXE.mjs → SettingsSection-8QHZB59k.mjs} +1 -1
- package/dist/{SettingsSection-D_pKPRrP.js → SettingsSection-cKF0tLnS.js} +1 -1
- package/dist/{SingleCategorySettings-BAND8Zkw.mjs → SingleCategorySettings--LK0TZW0.mjs} +3 -3
- package/dist/{SingleCategorySettings-Cg-zuJfr.js → SingleCategorySettings-CRXTMTo5.js} +1 -1
- package/dist/{StorefrontSection-QZPEZ6Lz.js → StorefrontSection-C9DzCmOf.js} +1 -1
- package/dist/{StorefrontSection-FSOxBclu.mjs → StorefrontSection-CeCpr8hn.mjs} +2 -2
- package/dist/{SubscriptionsSection-C4TDXCX2.mjs → SubscriptionsSection-C2xk8ApF.mjs} +1 -1
- package/dist/{SubscriptionsSection-DYr99VzB.js → SubscriptionsSection-Dn5SY6S_.js} +1 -1
- package/dist/{Token22Section-D3nnUyim.js → Token22Section-DUUl59dZ.js} +1 -1
- package/dist/{Token22Section-Cmn2lKcd.mjs → Token22Section-HygkDNtL.mjs} +2 -2
- package/dist/{WalletManager-peBN6RDH.mjs → WalletManager-CXvQ0Zu9.mjs} +1 -1
- package/dist/{bn-CHdpZHQm.mjs → bn-Bv2sKQMU.mjs} +1 -1
- package/dist/{bn-RbgIlcHc.js → bn-CHyy7EgJ.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +7 -7
- package/dist/{index-CKNB7XsA.mjs → index-BHF82XBB.mjs} +625 -625
- package/dist/{index-vEe2Y39x.js → index-OaWkrl0G.js} +8 -8
- package/dist/index.js +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{sections-Cklkxd85.js → sections-8e5Y3ukY.js} +1 -1
- package/dist/sections-C1rb9YRh.mjs +9 -0
- package/dist/stripe-only.mjs +2 -2
- package/dist/{styles-2VMpwuaI.mjs → styles-Ag-7ZvAB.mjs} +46 -46
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-DgQsh7Se.mjs → walletPool-C_0P4mTw.mjs} +1 -1
- package/package.json +6 -1
- package/dist/sections-Dt6vxDU4.mjs +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
2
2
|
import { useState as u, useRef as S, useCallback as A, useEffect as T, useMemo as q } from "react";
|
|
3
|
-
import { I as w, E as J, F as Y } from "./index-
|
|
4
|
-
import { A as X } from "./AutosaveIndicator-
|
|
3
|
+
import { I as w, E as J, F as Y } from "./index-BHF82XBB.mjs";
|
|
4
|
+
import { A as X } from "./AutosaveIndicator-BJsg_kFZ.mjs";
|
|
5
5
|
const C = [
|
|
6
6
|
{ id: "not_set", label: "Disabled", provider: null },
|
|
7
7
|
{ id: "gemini-2.5-flash", label: "Gemini 2.5 Flash", provider: "gemini" },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),b=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),b=require("./index-OaWkrl0G.js"),z=require("./AutosaveIndicator-CY_YHM1D.js"),w=[{id:"not_set",label:"Disabled",provider:null},{id:"gemini-2.5-flash",label:"Gemini 2.5 Flash",provider:"gemini"},{id:"gemini-2.5-pro",label:"Gemini 2.5 Pro",provider:"gemini"},{id:"openai-4o",label:"OpenAI 4o",provider:"openai"},{id:"openai-5.1",label:"OpenAI 5.1",provider:"openai"},{id:"openai-5.2",label:"OpenAI 5.2",provider:"openai"}],P=[{task:"site_chat",label:"Site Chat",description:"The conversational model that crafts responses to customer messages",defaultPrompt:`You are a friendly and helpful shopping assistant for our store. Your role is to:
|
|
2
2
|
|
|
3
3
|
- Help customers find products that match their needs
|
|
4
4
|
- Answer questions about products, shipping, returns, and store policies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),i=require("./index-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),i=require("./index-OaWkrl0G.js");function a({status:n,error:r}){return n==="idle"?null:e.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${n}`,style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8125rem",color:n==="error"?"var(--cedros-admin-error, #ef4444)":"var(--cedros-admin-text-muted, #64748b)"},children:[n==="pending"&&e.jsx("span",{style:{opacity:.7},children:"Unsaved changes"}),n==="saving"&&e.jsxs(e.Fragment,{children:[i.Icons.loading,e.jsx("span",{children:"Saving..."})]}),n==="saved"&&e.jsxs(e.Fragment,{children:[i.Icons.check,e.jsx("span",{style:{color:"var(--cedros-admin-success, #22c55e)"},children:"Saved"})]}),n==="error"&&e.jsxs("span",{children:["Save failed",r?`: ${r}`:""]})]})}exports.AutosaveIndicator=a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as K } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as ne,
|
|
2
|
+
import { useContext as ne, useState as N, useRef as Ae, useEffect as I, useMemo as ee, createContext as ge } from "react";
|
|
3
3
|
import { g as S } from "./uuid-_z3jSatJ.mjs";
|
|
4
4
|
var we = "https://js.stripe.com/v3", qe = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
5
5
|
var je = function() {
|
|
@@ -2171,7 +2171,7 @@ class Et extends Ct {
|
|
|
2171
2171
|
}
|
|
2172
2172
|
let X = null;
|
|
2173
2173
|
async function Pt() {
|
|
2174
|
-
return X || (X = (await import("./WalletManager-
|
|
2174
|
+
return X || (X = (await import("./WalletManager-CXvQ0Zu9.mjs")).WalletManager), X;
|
|
2175
2175
|
}
|
|
2176
2176
|
const J = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
|
|
2177
2177
|
function Ue(t, e, r, a, n) {
|
|
@@ -2476,7 +2476,7 @@ const _t = Object.freeze({
|
|
|
2476
2476
|
buttonPadding: "--cedros-button-padding",
|
|
2477
2477
|
buttonFontSize: "--cedros-button-font-size",
|
|
2478
2478
|
buttonFontWeight: "--cedros-button-font-weight"
|
|
2479
|
-
}, se =
|
|
2479
|
+
}, se = ge(null);
|
|
2480
2480
|
function Ut(t, e) {
|
|
2481
2481
|
return {
|
|
2482
2482
|
...t === "dark" ? It : _t,
|
|
@@ -2496,7 +2496,7 @@ function Ht({
|
|
|
2496
2496
|
unstyled: r = !1,
|
|
2497
2497
|
children: a
|
|
2498
2498
|
}) {
|
|
2499
|
-
const [n, i] = N(t), [o, s] = N(e), c =
|
|
2499
|
+
const [n, i] = N(t), [o, s] = N(e), c = Ae(e);
|
|
2500
2500
|
I(() => {
|
|
2501
2501
|
if (e === c.current)
|
|
2502
2502
|
return;
|
|
@@ -2536,12 +2536,12 @@ const $ = {
|
|
|
2536
2536
|
function Lt() {
|
|
2537
2537
|
return typeof process < "u" && process.env.NODE_ENV === "development" ? 0 : 2;
|
|
2538
2538
|
}
|
|
2539
|
-
const He =
|
|
2539
|
+
const He = ge(null);
|
|
2540
2540
|
function Vt({ config: t, children: e }) {
|
|
2541
|
-
const r = ee(() => Bt(t), [t]), [a, n] = N(null), [i, o] = N($), s =
|
|
2541
|
+
const r = ee(() => Bt(t), [t]), [a, n] = N(null), [i, o] = N($), s = Ae($);
|
|
2542
2542
|
I(() => {
|
|
2543
2543
|
let f = !1;
|
|
2544
|
-
return import("./walletPool-
|
|
2544
|
+
return import("./walletPool-C_0P4mTw.mjs").then(({ createWalletPool: h }) => {
|
|
2545
2545
|
if (f) return;
|
|
2546
2546
|
const w = h();
|
|
2547
2547
|
s.current = w, o(w);
|
|
@@ -2620,23 +2620,23 @@ function Jt() {
|
|
|
2620
2620
|
return t;
|
|
2621
2621
|
}
|
|
2622
2622
|
export {
|
|
2623
|
-
|
|
2623
|
+
Qt as C,
|
|
2624
2624
|
at as E,
|
|
2625
2625
|
ae as K,
|
|
2626
2626
|
Ve as L,
|
|
2627
2627
|
O as P,
|
|
2628
2628
|
M as R,
|
|
2629
2629
|
Mt as S,
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2630
|
+
Vt as a,
|
|
2631
|
+
A as b,
|
|
2632
|
+
et as c,
|
|
2633
|
+
Ee as d,
|
|
2634
|
+
E as e,
|
|
2635
|
+
j as f,
|
|
2636
|
+
Xe as g,
|
|
2637
|
+
R as h,
|
|
2638
2638
|
l as i,
|
|
2639
|
-
|
|
2639
|
+
Kt as j,
|
|
2640
2640
|
Wt as k,
|
|
2641
2641
|
me as l,
|
|
2642
2642
|
k as m,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as A, jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { useState as K, useRef as R, useCallback as P, useMemo as Y, useEffect as H } from "react";
|
|
3
3
|
import { useWallet as be } from "@solana/wallet-adapter-react";
|
|
4
4
|
import { WalletReadyState as pe } from "@solana/wallet-adapter-base";
|
|
5
5
|
import { WalletIcon as Te } from "@solana/wallet-adapter-react-ui";
|
|
6
|
-
import { T as Ie,
|
|
7
|
-
import { u as he, m as ee, i as n,
|
|
6
|
+
import { T as Ie, K as Ee, O as We, U as V, q as Re, n as fe, s as _e, o as ge, p as qe, r as we, t as Z, V as Me, W as ze } from "./styles-Ag-7ZvAB.mjs";
|
|
7
|
+
import { u as he, m as ee, i as n, j as De } from "./CedrosContext-DQUbL8yP.mjs";
|
|
8
8
|
function $e() {
|
|
9
|
-
const { x402Manager: g, walletManager: s } = he(), { publicKey: _, signTransaction: q } = be(), [
|
|
9
|
+
const { x402Manager: g, walletManager: s } = he(), { publicKey: _, signTransaction: q } = be(), [L, d] = K({
|
|
10
10
|
status: "idle",
|
|
11
11
|
error: null,
|
|
12
12
|
transactionId: null
|
|
13
|
-
}), [I, k] =
|
|
13
|
+
}), [I, k] = K(null), [G, x] = K(null), C = R(_);
|
|
14
14
|
C.current = _;
|
|
15
15
|
const w = R(q);
|
|
16
16
|
w.current = q;
|
|
17
|
-
const u = R(0),
|
|
17
|
+
const u = R(0), X = 6e4, E = () => {
|
|
18
18
|
const o = u.current;
|
|
19
|
-
return o > 0 && Date.now() - o <
|
|
19
|
+
return o > 0 && Date.now() - o < X;
|
|
20
20
|
}, v = P(() => {
|
|
21
21
|
if (!_) {
|
|
22
22
|
const o = "Wallet not connected";
|
|
@@ -27,7 +27,7 @@ function $e() {
|
|
|
27
27
|
return d({ status: "error", error: o, transactionId: null }), { valid: !1, error: o };
|
|
28
28
|
}
|
|
29
29
|
return { valid: !0 };
|
|
30
|
-
}, [_, q]),
|
|
30
|
+
}, [_, q]), M = P(
|
|
31
31
|
async (o) => {
|
|
32
32
|
try {
|
|
33
33
|
d((i) => ({ ...i, status: "loading" }));
|
|
@@ -59,12 +59,12 @@ function $e() {
|
|
|
59
59
|
couponCode: i
|
|
60
60
|
});
|
|
61
61
|
n().debug("[useX402Payment] Deserializing backend transaction");
|
|
62
|
-
const
|
|
62
|
+
const O = s.deserializeTransaction(f);
|
|
63
63
|
if (C.current?.toString() !== a.toString())
|
|
64
64
|
throw new Error("Wallet changed during payment flow");
|
|
65
65
|
n().debug("[useX402Payment] Requesting partial signature");
|
|
66
66
|
const T = await s.partiallySignTransaction({
|
|
67
|
-
transaction:
|
|
67
|
+
transaction: O,
|
|
68
68
|
signTransaction: y,
|
|
69
69
|
blockhash: D
|
|
70
70
|
});
|
|
@@ -88,13 +88,13 @@ function $e() {
|
|
|
88
88
|
const D = await s.signTransaction({
|
|
89
89
|
transaction: f,
|
|
90
90
|
signTransaction: y
|
|
91
|
-
}),
|
|
91
|
+
}), O = s.buildPaymentPayload({
|
|
92
92
|
requirement: o,
|
|
93
93
|
signedTx: D,
|
|
94
94
|
payerPublicKey: a
|
|
95
95
|
}), T = await g.submitPayment({
|
|
96
96
|
resource: l,
|
|
97
|
-
payload:
|
|
97
|
+
payload: O,
|
|
98
98
|
couponCode: i,
|
|
99
99
|
metadata: b,
|
|
100
100
|
resourceType: r
|
|
@@ -143,7 +143,7 @@ function $e() {
|
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
145
|
[v, g, B]
|
|
146
|
-
),
|
|
146
|
+
), z = P(
|
|
147
147
|
async (o, l, i) => {
|
|
148
148
|
if (E())
|
|
149
149
|
return { success: !1, error: "Payment already in progress" };
|
|
@@ -194,21 +194,21 @@ function $e() {
|
|
|
194
194
|
}), k(null), x(null), u.current = 0;
|
|
195
195
|
}, []);
|
|
196
196
|
return {
|
|
197
|
-
...
|
|
197
|
+
...L,
|
|
198
198
|
requirement: I,
|
|
199
199
|
settlement: G,
|
|
200
|
-
fetchQuote:
|
|
200
|
+
fetchQuote: M,
|
|
201
201
|
processPayment: p,
|
|
202
|
-
processCartPayment:
|
|
202
|
+
processCartPayment: z,
|
|
203
203
|
reset: W
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function je({
|
|
207
207
|
resource: g,
|
|
208
208
|
items: s,
|
|
209
209
|
label: _,
|
|
210
210
|
disabled: q = !1,
|
|
211
|
-
onAttempt:
|
|
211
|
+
onAttempt: L,
|
|
212
212
|
onSuccess: d,
|
|
213
213
|
onError: I,
|
|
214
214
|
className: k = "",
|
|
@@ -217,7 +217,7 @@ function Fe({
|
|
|
217
217
|
metadata: C,
|
|
218
218
|
couponCode: w
|
|
219
219
|
}) {
|
|
220
|
-
const { connected: u, connecting:
|
|
220
|
+
const { connected: u, connecting: X, connect: E, disconnect: v, select: M, wallets: B, wallet: p, publicKey: z } = be(), { status: W, error: o, transactionId: l, processPayment: i, processCartPayment: b } = $e(), r = De(), { solanaError: a } = he(), { isCartMode: y, effectiveResource: c } = Ee(g, s), { t: f, translations: D } = We(), O = _ || f("ui.pay_with_crypto"), T = o && typeof o != "string" ? o?.code ?? null : null, $ = a && typeof a != "string" ? a?.code ?? null : null, te = (e) => {
|
|
221
221
|
if (!e || !D) return "";
|
|
222
222
|
const t = D.errors[e];
|
|
223
223
|
return t ? t.action ? `${t.message} ${t.action}` : t.message : "";
|
|
@@ -245,11 +245,11 @@ function Fe({
|
|
|
245
245
|
fe("crypto", o, c, e), ae.current?.(o);
|
|
246
246
|
}
|
|
247
247
|
}, [W, o, y, s, c]);
|
|
248
|
-
const ce = typeof window < "u" && window.top !== window.self, [ie,
|
|
248
|
+
const ce = typeof window < "u" && window.top !== window.self, [ie, j] = K(!1), [ue, J] = K(!1), [F, S] = K(null), N = a;
|
|
249
249
|
H(() => {
|
|
250
250
|
let e = !1;
|
|
251
251
|
return e || (async () => {
|
|
252
|
-
if (ue && p && !u && !
|
|
252
|
+
if (ue && p && !u && !X) {
|
|
253
253
|
n().debug("[CryptoButton] Wallet detected, attempting auto-connect:", p.adapter.name), J(!1), we(p.adapter.name);
|
|
254
254
|
try {
|
|
255
255
|
await E(), e || n().debug("[CryptoButton] Auto-connect successful");
|
|
@@ -264,24 +264,24 @@ function Fe({
|
|
|
264
264
|
})(), () => {
|
|
265
265
|
e = !0;
|
|
266
266
|
};
|
|
267
|
-
}, [p, ue, u,
|
|
267
|
+
}, [p, ue, u, X, E]), H(() => {
|
|
268
268
|
let e = !0;
|
|
269
269
|
if (n().debug("[CryptoButton] Payment useEffect triggered", {
|
|
270
270
|
connected: u,
|
|
271
|
-
hasPendingPayment: !!
|
|
272
|
-
hasPublicKey: !!
|
|
273
|
-
pendingPaymentType:
|
|
274
|
-
}), u &&
|
|
275
|
-
_e(p.adapter.name,
|
|
276
|
-
const t =
|
|
277
|
-
S(null),
|
|
271
|
+
hasPendingPayment: !!F,
|
|
272
|
+
hasPublicKey: !!z,
|
|
273
|
+
pendingPaymentType: F?.type
|
|
274
|
+
}), u && F && z && p && e) {
|
|
275
|
+
_e(p.adapter.name, z.toString()), n().debug("[CryptoButton] All conditions met! Processing pending payment:", F);
|
|
276
|
+
const t = F;
|
|
277
|
+
S(null), j(!1);
|
|
278
278
|
const m = t.type === "cart" && t.items ? V(t.items) : void 0;
|
|
279
279
|
ge("crypto", t.resource, m), t.type === "cart" && t.items ? (n().debug("[CryptoButton] Auto-processing cart payment"), le.current(t.items, t.metadata, t.couponCode)) : t.type === "single" && t.resource && (n().debug("[CryptoButton] Auto-processing single payment"), se.current(t.resource, t.couponCode, t.metadata));
|
|
280
280
|
}
|
|
281
281
|
return () => {
|
|
282
282
|
e = !1;
|
|
283
283
|
};
|
|
284
|
-
}, [u,
|
|
284
|
+
}, [u, F, z, p]);
|
|
285
285
|
const de = P(async () => {
|
|
286
286
|
n().debug("[CryptoButton] executePaymentFlow called", {
|
|
287
287
|
connected: u,
|
|
@@ -292,8 +292,8 @@ function Fe({
|
|
|
292
292
|
effectiveResource: c
|
|
293
293
|
});
|
|
294
294
|
const e = y && s ? V(s) : void 0;
|
|
295
|
-
if (qe("crypto", c, e),
|
|
296
|
-
n().error("[CryptoButton] Solana dependencies missing:",
|
|
295
|
+
if (qe("crypto", c, e), L && L("crypto"), N) {
|
|
296
|
+
n().error("[CryptoButton] Solana dependencies missing:", N), fe("crypto", N, c, e), I && I(N);
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
299
|
if (ce) {
|
|
@@ -327,7 +327,7 @@ function Fe({
|
|
|
327
327
|
const m = "No wallets available";
|
|
328
328
|
throw Z(m), new Error(m);
|
|
329
329
|
}
|
|
330
|
-
|
|
330
|
+
j(!0);
|
|
331
331
|
}
|
|
332
332
|
} catch (m) {
|
|
333
333
|
S(null);
|
|
@@ -335,22 +335,22 @@ function Fe({
|
|
|
335
335
|
n().error("[CryptoButton] Connection error:", U), Z(U, p?.adapter.name);
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
}, [u, p, w, y, s, c, ce, G, Q, E, C, b, i,
|
|
339
|
-
() =>
|
|
338
|
+
}, [u, p, w, y, s, c, ce, G, Q, E, C, b, i, N, L, I]), ye = Y(() => y && s ? `crypto-cart-${s.map((e) => e.resource).join("-")}` : `crypto-${c || "unknown"}`, [y, s, c]), Pe = Y(
|
|
339
|
+
() => Me(ye, de, {
|
|
340
340
|
cooldownMs: 200,
|
|
341
341
|
deduplicationWindowMs: 0
|
|
342
342
|
// MUST be 0 for crypto - each payment needs fresh transaction
|
|
343
343
|
}),
|
|
344
344
|
[ye, de]
|
|
345
|
-
), me = W === "loading", xe = q || me ||
|
|
345
|
+
), me = W === "loading", xe = q || me || X || !!N, ve = me ? f("ui.processing") : O, Se = P(async () => {
|
|
346
346
|
try {
|
|
347
|
-
J(!1), u && await v(),
|
|
347
|
+
J(!1), u && await v(), M(null), j(!0);
|
|
348
348
|
} catch (e) {
|
|
349
349
|
n().error("Failed to change wallet:", e);
|
|
350
350
|
}
|
|
351
|
-
}, [u, v,
|
|
352
|
-
n().debug("[CryptoButton] Wallet clicked:", e),
|
|
353
|
-
}, [
|
|
351
|
+
}, [u, v, M]), ke = P((e) => {
|
|
352
|
+
n().debug("[CryptoButton] Wallet clicked:", e), j(!1), M(e), J(!0), n().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
|
|
353
|
+
}, [M]), Be = P(async () => {
|
|
354
354
|
try {
|
|
355
355
|
if (await v(), S(null), typeof window < "u" && window.localStorage)
|
|
356
356
|
try {
|
|
@@ -362,7 +362,7 @@ function Fe({
|
|
|
362
362
|
n().error("Failed to disconnect wallet:", e);
|
|
363
363
|
}
|
|
364
364
|
}, [v]);
|
|
365
|
-
return /* @__PURE__ */
|
|
365
|
+
return /* @__PURE__ */ A("div", { className: r.unstyled ? k : `${r.className} cedros-theme__crypto-button ${k || ""}`, style: r.unstyled ? {} : r.style, children: [
|
|
366
366
|
/* @__PURE__ */ h(
|
|
367
367
|
"button",
|
|
368
368
|
{
|
|
@@ -391,9 +391,9 @@ function Fe({
|
|
|
391
391
|
padding: "1rem"
|
|
392
392
|
},
|
|
393
393
|
onClick: () => {
|
|
394
|
-
|
|
394
|
+
j(!1), S(null);
|
|
395
395
|
},
|
|
396
|
-
children: /* @__PURE__ */
|
|
396
|
+
children: /* @__PURE__ */ A(
|
|
397
397
|
"div",
|
|
398
398
|
{
|
|
399
399
|
className: "cedros-modal-content",
|
|
@@ -408,7 +408,7 @@ function Fe({
|
|
|
408
408
|
},
|
|
409
409
|
onClick: (e) => e.stopPropagation(),
|
|
410
410
|
children: [
|
|
411
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ A(
|
|
412
412
|
"div",
|
|
413
413
|
{
|
|
414
414
|
style: {
|
|
@@ -434,9 +434,9 @@ function Fe({
|
|
|
434
434
|
"button",
|
|
435
435
|
{
|
|
436
436
|
onClick: () => {
|
|
437
|
-
|
|
437
|
+
j(!1), S(null);
|
|
438
438
|
},
|
|
439
|
-
style:
|
|
439
|
+
style: ze(r.tokens.surfaceText),
|
|
440
440
|
"aria-label": "Close modal",
|
|
441
441
|
type: "button",
|
|
442
442
|
children: "×"
|
|
@@ -445,7 +445,7 @@ function Fe({
|
|
|
445
445
|
]
|
|
446
446
|
}
|
|
447
447
|
),
|
|
448
|
-
/* @__PURE__ */ h("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: Q.map((e) => /* @__PURE__ */
|
|
448
|
+
/* @__PURE__ */ h("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: Q.map((e) => /* @__PURE__ */ A(
|
|
449
449
|
"button",
|
|
450
450
|
{
|
|
451
451
|
onClick: () => ke(e.adapter.name),
|
|
@@ -483,7 +483,7 @@ function Fe({
|
|
|
483
483
|
)
|
|
484
484
|
}
|
|
485
485
|
),
|
|
486
|
-
u && !x && !ie && /* @__PURE__ */
|
|
486
|
+
u && !x && !ie && /* @__PURE__ */ A("div", { style: {
|
|
487
487
|
display: "flex",
|
|
488
488
|
justifyContent: "space-between",
|
|
489
489
|
marginTop: "0.5rem",
|
|
@@ -533,10 +533,10 @@ function Fe({
|
|
|
533
533
|
}
|
|
534
534
|
const Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
535
535
|
__proto__: null,
|
|
536
|
-
CryptoButton:
|
|
536
|
+
CryptoButton: je
|
|
537
537
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
538
538
|
export {
|
|
539
|
-
|
|
539
|
+
je as C,
|
|
540
540
|
Ge as a,
|
|
541
541
|
$e as u
|
|
542
542
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("./index-vEe2Y39x.js");function R({serverUrl:h,apiKey:o,pageSize:g=20,authManager:r}){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),[$,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(r?.isAuthenticated())s=await r.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);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,o,g,r]);c.useEffect(()=>{_()},[_]);const E=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(r?.isAuthenticated())await r.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};o&&(m["X-API-Key"]=o);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(r?.isAuthenticated())await r.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);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(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);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(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);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)},W=u.length,B=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(d.ErrorBanner,{message:$,onRetry:_}),e.jsx(d.StatsBar,{stats:[{label:"Total FAQs",value:W},{label:"Active",value:B,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:[d.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:E,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:d.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?d.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[d.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:[d.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[d.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?d.Icons.eyeOff:d.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:d.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:d.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=R;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("./index-OaWkrl0G.js");function R({serverUrl:h,apiKey:o,pageSize:g=20,authManager:r}){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),[$,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(r?.isAuthenticated())s=await r.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);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,o,g,r]);c.useEffect(()=>{_()},[_]);const E=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(r?.isAuthenticated())await r.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};o&&(m["X-API-Key"]=o);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(r?.isAuthenticated())await r.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);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(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);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(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);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)},W=u.length,B=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(d.ErrorBanner,{message:$,onRetry:_}),e.jsx(d.StatsBar,{stats:[{label:"Total FAQs",value:W},{label:"Active",value:B,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:[d.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:E,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:d.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?d.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[d.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:[d.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[d.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?d.Icons.eyeOff:d.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:d.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:d.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=R;
|
|
@@ -1,6 +1,6 @@
|
|
|
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 { E as H, g as Y, I as l } from "./index-
|
|
3
|
+
import { E as H, g as Y, I as l } from "./index-BHF82XBB.mjs";
|
|
4
4
|
function M({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
|
|
5
5
|
const [_, F] = r([]), [E, C] = r(!0), [S, 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
6
|
question: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),y=require("./index-vEe2Y39x.js"),S=require("./Toggle-CsPSF8Dr.js"),q=require("./useAutosave-B2p6iwh8.js"),z=require("./AutosaveIndicator-BnQkKxzr.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-OaWkrl0G.js"),S=require("./Toggle-CsPSF8Dr.js"),q=require("./useAutosave-B2p6iwh8.js"),z=require("./AutosaveIndicator-CY_YHM1D.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,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-
|
|
3
|
+
import { I as $, E as q } from "./index-BHF82XBB.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-
|
|
6
|
+
import { A as j } from "./AutosaveIndicator-BJsg_kFZ.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"),a=require("react"),u=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),u=require("./index-OaWkrl0G.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,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, h as F, s as k } from "./index-
|
|
3
|
+
import { I as z, E as G, h as F, s as k } from "./index-BHF82XBB.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, w] = r(null), [D, v] = r(null), [E, b] = r([]), [O, L] = r(!1), [f, T] = r(""), g = N(async (n, d) => {
|
|
6
6
|
if (l?.isAuthenticated())
|