@cedros/pay-react 1.1.24 → 1.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
- package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
- package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
- package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
- package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
- package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
- package/dist/ComplianceSection-DP2a9-S0.js +1 -0
- package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/CustomersSection-CBwy_waO.js +1 -0
- package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
- package/dist/DisputesSection-BLjIk60n.js +1 -0
- package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
- package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
- package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
- package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
- package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
- package/dist/InventorySection-zV6lTmue.js +1 -0
- package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
- package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
- package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
- package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
- package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
- package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
- package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
- package/dist/ReturnsSection-D_pJVxuG.js +1 -0
- package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
- package/dist/SettingsSection-vdYFSNxB.js +1 -0
- package/dist/ShippingSection-1DRSTu49.js +1 -0
- package/dist/ShippingSection-BOgto6_9.mjs +434 -0
- package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
- package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
- package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
- package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
- package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
- package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
- package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
- package/dist/TaxSection-Dt1DnM51.js +1 -0
- package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
- package/dist/Token22Section-DY3mUwTY.js +1 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
- package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/index-C0g-JxJk.js +84 -0
- package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
- package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +40 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
- package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/CustomersSection.d.ts +3 -0
- package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
- package/dist/src/components/admin/DisputesSection.d.ts +3 -0
- package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/ImagesSection.d.ts +3 -0
- package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
- package/dist/src/components/admin/InventorySection.d.ts +3 -0
- package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
- package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
- package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ShippingSection.d.ts +3 -0
- package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
- package/dist/src/components/admin/TaxSection.d.ts +3 -0
- package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
- package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
- package/dist/src/components/admin/complianceTypes.d.ts +74 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +12 -2
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +1 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-cKF0tLnS.js +0 -1
- package/dist/Token22Section-DUUl59dZ.js +0 -1
- package/dist/Token22Section-HygkDNtL.mjs +0 -1685
- package/dist/index-OaWkrl0G.js +0 -84
- package/dist/styles-21F1-oqx.js +0 -1
|
@@ -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,
|
|
3
|
+
import { E as H, j as Y, I as l } from "./index-DXnuQp5x.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"),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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("./index-C0g-JxJk.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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),u=require("./index-C0g-JxJk.js"),v=require("./CedrosContext-C2RjHLaQ.js");async function E(s,l,n,c){const o=new FormData;if(o.append("file",c),n?.isAuthenticated())return n.fetchWithAuth("/admin/images/upload",{method:"POST",body:o,headers:{}});const r={};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images/upload`,{method:"POST",headers:r,body:o});if(!d.ok)throw new Error(`Upload failed: ${d.status}`);return d.json()}async function O(s,l,n,c){const o=JSON.stringify({url:c});if(n?.isAuthenticated()){await n.fetchWithAuth("/admin/images",{method:"DELETE",body:o});return}const r={"Content-Type":"application/json"};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images`,{method:"DELETE",headers:r,body:o});if(!d.ok)throw new Error(`Delete failed: ${d.status}`)}function R({serverUrl:s,apiKey:l,authManager:n}){const[c,o]=i.useState([]),[r,d]=i.useState(!1),[x,j]=i.useState(null),[C,m]=i.useState(null),[_,S]=i.useState(null),[p,f]=i.useState(!1),[h,g]=i.useState(null),b=i.useRef(null),D=i.useCallback(async t=>{d(!0),m(null);try{const a=await E(s,l,n,t);o(y=>[{url:a.url,thumbUrl:a.thumbUrl,uploadedAt:new Date().toISOString()},...y]),g(null),b.current&&(b.current.value="")}catch(a){v.getLogger().error("[ImagesSection] Upload failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Upload failed. Check file type and try again.")}finally{d(!1)}},[s,l,n]),w=t=>{const a=t.target.files?.[0]??null;g(a),m(null)},I=()=>{h&&D(h)},U=t=>{t.preventDefault(),f(!0)},N=()=>f(!1),k=t=>{t.preventDefault(),f(!1);const a=t.dataTransfer.files?.[0];a&&a.type.startsWith("image/")?(g(a),m(null)):a&&m("Only image files are accepted.")},T=i.useCallback(async t=>{j(t),m(null);try{await O(s,l,n,t),o(a=>a.filter(y=>y.url!==t))}catch(a){v.getLogger().error("[ImagesSection] Delete failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Failed to delete image.")}finally{j(null)}},[s,l,n]),L=async t=>{try{await navigator.clipboard.writeText(t),S(t),setTimeout(()=>S(null),2e3)}catch{m("Could not copy to clipboard.")}},A=["cedros-admin__drop-zone",p?"cedros-admin__drop-zone--active":""].filter(Boolean).join(" ");return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(u.ErrorBanner,{message:C}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Image Upload"})}),e.jsxs("div",{className:A,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:w,"aria-label":"Select image file"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:I,disabled:!h||r,"aria-busy":r,children:r?e.jsxs(e.Fragment,{children:[u.Icons.loading," Uploading..."]}):"Upload"})]}),h&&!r&&e.jsxs("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",opacity:.65},children:["Selected: ",h.name," (",(h.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:u.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:()=>L(t.url),"aria-label":"Copy URL to clipboard",title:"Copy URL",children:[_===t.url?u.Icons.check:u.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?u.Icons.loading:u.Icons.trash,"Delete"]})]})})]},t.url))})]})})]})}exports.ImagesSection=R;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useRef as j, useCallback as U } from "react";
|
|
3
|
+
import { E as z, I as u, k as B } from "./index-DXnuQp5x.mjs";
|
|
4
|
+
import { i as I } from "./CedrosContext-CY6zvjvJ.mjs";
|
|
5
|
+
async function W(r, n, i, c) {
|
|
6
|
+
const d = new FormData();
|
|
7
|
+
if (d.append("file", c), i?.isAuthenticated())
|
|
8
|
+
return i.fetchWithAuth(
|
|
9
|
+
"/admin/images/upload",
|
|
10
|
+
{ method: "POST", body: d, headers: {} }
|
|
11
|
+
);
|
|
12
|
+
const o = {};
|
|
13
|
+
n && (o["X-API-Key"] = n);
|
|
14
|
+
const s = await fetch(`${r}/admin/images/upload`, {
|
|
15
|
+
method: "POST",
|
|
16
|
+
headers: o,
|
|
17
|
+
body: d
|
|
18
|
+
});
|
|
19
|
+
if (!s.ok) throw new Error(`Upload failed: ${s.status}`);
|
|
20
|
+
return s.json();
|
|
21
|
+
}
|
|
22
|
+
async function P(r, n, i, c) {
|
|
23
|
+
const d = JSON.stringify({ url: c });
|
|
24
|
+
if (i?.isAuthenticated()) {
|
|
25
|
+
await i.fetchWithAuth("/admin/images", {
|
|
26
|
+
method: "DELETE",
|
|
27
|
+
body: d
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const o = { "Content-Type": "application/json" };
|
|
32
|
+
n && (o["X-API-Key"] = n);
|
|
33
|
+
const s = await fetch(`${r}/admin/images`, {
|
|
34
|
+
method: "DELETE",
|
|
35
|
+
headers: o,
|
|
36
|
+
body: d
|
|
37
|
+
});
|
|
38
|
+
if (!s.ok) throw new Error(`Delete failed: ${s.status}`);
|
|
39
|
+
}
|
|
40
|
+
function q({ serverUrl: r, apiKey: n, authManager: i }) {
|
|
41
|
+
const [c, d] = h([]), [o, s] = h(!1), [v, D] = h(null), [S, m] = h(null), [w, C] = h(null), [f, g] = h(!1), [p, y] = h(null), b = j(null), N = U(async (e) => {
|
|
42
|
+
s(!0), m(null);
|
|
43
|
+
try {
|
|
44
|
+
const a = await W(r, n, i, e);
|
|
45
|
+
d((_) => [
|
|
46
|
+
{ url: a.url, thumbUrl: a.thumbUrl, uploadedAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
47
|
+
..._
|
|
48
|
+
]), y(null), b.current && (b.current.value = "");
|
|
49
|
+
} catch (a) {
|
|
50
|
+
I().error("[ImagesSection] Upload failed:", a, {
|
|
51
|
+
serverUrl: r.slice(0, 20) + "..."
|
|
52
|
+
}), m("Upload failed. Check file type and try again.");
|
|
53
|
+
} finally {
|
|
54
|
+
s(!1);
|
|
55
|
+
}
|
|
56
|
+
}, [r, n, i]), k = (e) => {
|
|
57
|
+
const a = e.target.files?.[0] ?? null;
|
|
58
|
+
y(a), m(null);
|
|
59
|
+
}, x = () => {
|
|
60
|
+
p && N(p);
|
|
61
|
+
}, T = (e) => {
|
|
62
|
+
e.preventDefault(), g(!0);
|
|
63
|
+
}, E = () => g(!1), A = (e) => {
|
|
64
|
+
e.preventDefault(), g(!1);
|
|
65
|
+
const a = e.dataTransfer.files?.[0];
|
|
66
|
+
a && a.type.startsWith("image/") ? (y(a), m(null)) : a && m("Only image files are accepted.");
|
|
67
|
+
}, L = U(async (e) => {
|
|
68
|
+
D(e), m(null);
|
|
69
|
+
try {
|
|
70
|
+
await P(r, n, i, e), d((a) => a.filter((_) => _.url !== e));
|
|
71
|
+
} catch (a) {
|
|
72
|
+
I().error("[ImagesSection] Delete failed:", a, {
|
|
73
|
+
serverUrl: r.slice(0, 20) + "..."
|
|
74
|
+
}), m("Failed to delete image.");
|
|
75
|
+
} finally {
|
|
76
|
+
D(null);
|
|
77
|
+
}
|
|
78
|
+
}, [r, n, i]), O = async (e) => {
|
|
79
|
+
try {
|
|
80
|
+
await navigator.clipboard.writeText(e), C(e), setTimeout(() => C(null), 2e3);
|
|
81
|
+
} catch {
|
|
82
|
+
m("Could not copy to clipboard.");
|
|
83
|
+
}
|
|
84
|
+
}, F = [
|
|
85
|
+
"cedros-admin__drop-zone",
|
|
86
|
+
f ? "cedros-admin__drop-zone--active" : ""
|
|
87
|
+
].filter(Boolean).join(" ");
|
|
88
|
+
return /* @__PURE__ */ l("div", { className: "cedros-admin__page", children: [
|
|
89
|
+
/* @__PURE__ */ t(z, { message: S }),
|
|
90
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Image Upload" }) }),
|
|
91
|
+
/* @__PURE__ */ l(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
className: F,
|
|
95
|
+
onDragOver: T,
|
|
96
|
+
onDragLeave: E,
|
|
97
|
+
onDrop: A,
|
|
98
|
+
role: "region",
|
|
99
|
+
"aria-label": "Image drop zone",
|
|
100
|
+
style: {
|
|
101
|
+
border: "2px dashed",
|
|
102
|
+
borderColor: f ? "var(--cedros-accent, #6366f1)" : "var(--cedros-border, #e2e8f0)",
|
|
103
|
+
borderRadius: "0.5rem",
|
|
104
|
+
padding: "1.5rem",
|
|
105
|
+
textAlign: "center",
|
|
106
|
+
marginBottom: "1rem",
|
|
107
|
+
transition: "border-color 0.15s",
|
|
108
|
+
backgroundColor: f ? "var(--cedros-accent-subtle, rgba(99,102,241,0.06))" : void 0
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ t("p", { style: { marginBottom: "0.75rem", fontSize: "0.9rem", opacity: 0.7 }, children: "Drag and drop an image here, or select a file below" }),
|
|
112
|
+
/* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.5rem", justifyContent: "center", alignItems: "center", flexWrap: "wrap" }, children: [
|
|
113
|
+
/* @__PURE__ */ t(
|
|
114
|
+
"input",
|
|
115
|
+
{
|
|
116
|
+
ref: b,
|
|
117
|
+
id: "cedros-image-file-input",
|
|
118
|
+
type: "file",
|
|
119
|
+
accept: "image/*",
|
|
120
|
+
className: "cedros-admin__input",
|
|
121
|
+
style: { maxWidth: 260 },
|
|
122
|
+
onChange: k,
|
|
123
|
+
"aria-label": "Select image file"
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ t(
|
|
127
|
+
"button",
|
|
128
|
+
{
|
|
129
|
+
type: "button",
|
|
130
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
131
|
+
onClick: x,
|
|
132
|
+
disabled: !p || o,
|
|
133
|
+
"aria-busy": o,
|
|
134
|
+
children: o ? /* @__PURE__ */ l(R, { children: [
|
|
135
|
+
u.loading,
|
|
136
|
+
" Uploading..."
|
|
137
|
+
] }) : "Upload"
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] }),
|
|
141
|
+
p && !o && /* @__PURE__ */ l("p", { style: { marginTop: "0.5rem", fontSize: "0.8rem", opacity: 0.65 }, children: [
|
|
142
|
+
"Selected: ",
|
|
143
|
+
p.name,
|
|
144
|
+
" (",
|
|
145
|
+
(p.size / 1024).toFixed(1),
|
|
146
|
+
" KB)"
|
|
147
|
+
] })
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ l("h3", { className: "cedros-admin__section-title", children: [
|
|
152
|
+
"Uploaded This Session",
|
|
153
|
+
c.length > 0 && /* @__PURE__ */ t("span", { className: "cedros-admin__section-badge", style: { marginLeft: "0.5rem" }, children: c.length })
|
|
154
|
+
] }) }),
|
|
155
|
+
c.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No images uploaded yet." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ l("table", { className: "cedros-admin__table", children: [
|
|
156
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
157
|
+
/* @__PURE__ */ t("th", { children: "Preview" }),
|
|
158
|
+
/* @__PURE__ */ t("th", { children: "URL" }),
|
|
159
|
+
/* @__PURE__ */ t("th", { children: "Uploaded" }),
|
|
160
|
+
/* @__PURE__ */ t("th", { children: "Actions" })
|
|
161
|
+
] }) }),
|
|
162
|
+
/* @__PURE__ */ t("tbody", { children: c.map((e) => /* @__PURE__ */ l("tr", { children: [
|
|
163
|
+
/* @__PURE__ */ t("td", { style: { width: 72 }, children: /* @__PURE__ */ t(
|
|
164
|
+
"img",
|
|
165
|
+
{
|
|
166
|
+
src: e.thumbUrl,
|
|
167
|
+
alt: "Thumbnail preview",
|
|
168
|
+
style: {
|
|
169
|
+
width: 56,
|
|
170
|
+
height: 56,
|
|
171
|
+
objectFit: "cover",
|
|
172
|
+
borderRadius: "0.25rem",
|
|
173
|
+
display: "block"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
) }),
|
|
177
|
+
/* @__PURE__ */ t("td", { style: { maxWidth: 320, wordBreak: "break-all" }, children: /* @__PURE__ */ t("code", { style: { fontSize: "0.8rem" }, children: e.url }) }),
|
|
178
|
+
/* @__PURE__ */ t("td", { style: { whiteSpace: "nowrap" }, children: B(e.uploadedAt) }),
|
|
179
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.4rem" }, children: [
|
|
180
|
+
/* @__PURE__ */ l(
|
|
181
|
+
"button",
|
|
182
|
+
{
|
|
183
|
+
type: "button",
|
|
184
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
185
|
+
onClick: () => O(e.url),
|
|
186
|
+
"aria-label": "Copy URL to clipboard",
|
|
187
|
+
title: "Copy URL",
|
|
188
|
+
children: [
|
|
189
|
+
w === e.url ? u.check : u.eye,
|
|
190
|
+
w === e.url ? "Copied" : "Copy URL"
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ l(
|
|
195
|
+
"button",
|
|
196
|
+
{
|
|
197
|
+
type: "button",
|
|
198
|
+
className: "cedros-admin__button cedros-admin__button--destructive",
|
|
199
|
+
onClick: () => L(e.url),
|
|
200
|
+
disabled: v === e.url,
|
|
201
|
+
"aria-label": "Delete image",
|
|
202
|
+
title: "Delete",
|
|
203
|
+
children: [
|
|
204
|
+
v === e.url ? u.loading : u.trash,
|
|
205
|
+
"Delete"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
] }) })
|
|
210
|
+
] }, e.url)) })
|
|
211
|
+
] }) })
|
|
212
|
+
] });
|
|
213
|
+
}
|
|
214
|
+
export {
|
|
215
|
+
q as ImagesSection
|
|
216
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { useState as r, useCallback as S, useEffect as w } from "react";
|
|
3
|
+
import { E as R, I as j, k as T } from "./index-DXnuQp5x.mjs";
|
|
4
|
+
import { i as E } from "./CedrosContext-CY6zvjvJ.mjs";
|
|
5
|
+
const a = 50;
|
|
6
|
+
function X({ serverUrl: o, apiKey: h, authManager: f }) {
|
|
7
|
+
const [g, I] = r([]), [C, v] = r(!0), [$, b] = r(null), [i, x] = r(""), [c, p] = r([]), [F, N] = r(!1), [L, _] = r(null), [l, y] = r(0), m = S(async (e) => {
|
|
8
|
+
if (f?.isAuthenticated())
|
|
9
|
+
return f.fetchWithAuth(e);
|
|
10
|
+
const s = { "Content-Type": "application/json" };
|
|
11
|
+
h && (s["X-API-Key"] = h);
|
|
12
|
+
const d = await fetch(`${o}${e}`, { headers: s });
|
|
13
|
+
if (!d.ok) throw new Error(`Request failed: ${d.status}`);
|
|
14
|
+
return d.json();
|
|
15
|
+
}, [o, h, f]);
|
|
16
|
+
w(() => {
|
|
17
|
+
let e = !1;
|
|
18
|
+
return v(!0), b(null), m("/admin/products?limit=100&offset=0").then((s) => {
|
|
19
|
+
if (e) return;
|
|
20
|
+
const d = Array.isArray(s) ? s : s.products ?? [];
|
|
21
|
+
I(d);
|
|
22
|
+
}).catch((s) => {
|
|
23
|
+
e || (E().error("[InventorySection] Failed to load products:", s, {
|
|
24
|
+
serverUrl: o.slice(0, 20) + "..."
|
|
25
|
+
}), b("Failed to load products"));
|
|
26
|
+
}).finally(() => {
|
|
27
|
+
e || v(!1);
|
|
28
|
+
}), () => {
|
|
29
|
+
e = !0;
|
|
30
|
+
};
|
|
31
|
+
}, [m, o]);
|
|
32
|
+
const A = S(async (e, s) => {
|
|
33
|
+
if (e) {
|
|
34
|
+
N(!0), _(null);
|
|
35
|
+
try {
|
|
36
|
+
const d = `/admin/products/${encodeURIComponent(e)}/inventory/adjustments?limit=${a}&offset=${s}`, q = await m(d);
|
|
37
|
+
p(q.adjustments ?? []);
|
|
38
|
+
} catch (d) {
|
|
39
|
+
E().error("[InventorySection] Failed to load adjustments:", d, {
|
|
40
|
+
productId: e,
|
|
41
|
+
serverUrl: o.slice(0, 20) + "..."
|
|
42
|
+
}), _("Failed to load inventory adjustments"), p([]);
|
|
43
|
+
} finally {
|
|
44
|
+
N(!1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [m, o]);
|
|
48
|
+
w(() => {
|
|
49
|
+
i && A(i, l);
|
|
50
|
+
}, [A, i, l]);
|
|
51
|
+
const k = (e) => {
|
|
52
|
+
x(e), y(0), p([]), _(null);
|
|
53
|
+
}, B = () => y((e) => Math.max(0, e - a)), D = () => y((e) => e + a), u = g.find((e) => e.id === i);
|
|
54
|
+
return /* @__PURE__ */ n("div", { className: "cedros-admin__page", children: [
|
|
55
|
+
/* @__PURE__ */ t(R, { message: $ ?? L }),
|
|
56
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Inventory Adjustments" }) }),
|
|
57
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__add-form", style: { marginBottom: "1rem" }, children: /* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ n("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
|
|
58
|
+
/* @__PURE__ */ t("label", { htmlFor: "inventory-product-select", className: "cedros-admin__field-label", children: "Select Product" }),
|
|
59
|
+
C ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
60
|
+
j.loading,
|
|
61
|
+
" Loading products..."
|
|
62
|
+
] }) : /* @__PURE__ */ n(
|
|
63
|
+
"select",
|
|
64
|
+
{
|
|
65
|
+
id: "inventory-product-select",
|
|
66
|
+
className: "cedros-admin__input",
|
|
67
|
+
value: i,
|
|
68
|
+
onChange: (e) => k(e.target.value),
|
|
69
|
+
"aria-label": "Select product to view inventory adjustments",
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ t("option", { value: "", children: "-- Choose a product --" }),
|
|
72
|
+
g.map((e) => /* @__PURE__ */ t("option", { value: e.id, children: e.title ?? e.description ?? e.id }, e.id))
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] }) }) }),
|
|
77
|
+
i ? F ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
78
|
+
j.loading,
|
|
79
|
+
" Loading adjustments..."
|
|
80
|
+
] }) : /* @__PURE__ */ n(P, { children: [
|
|
81
|
+
u && /* @__PURE__ */ n("p", { style: { marginBottom: "0.75rem", fontSize: "0.9rem", opacity: 0.7 }, children: [
|
|
82
|
+
"Showing adjustments for: ",
|
|
83
|
+
/* @__PURE__ */ t("strong", { children: u.title ?? u.description ?? u.id })
|
|
84
|
+
] }),
|
|
85
|
+
c.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No inventory adjustments found." }) : /* @__PURE__ */ n(P, { children: [
|
|
86
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
87
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
88
|
+
/* @__PURE__ */ t("th", { children: "Date" }),
|
|
89
|
+
/* @__PURE__ */ t("th", { children: "Delta" }),
|
|
90
|
+
/* @__PURE__ */ t("th", { children: "Before" }),
|
|
91
|
+
/* @__PURE__ */ t("th", { children: "After" }),
|
|
92
|
+
/* @__PURE__ */ t("th", { children: "Reason" }),
|
|
93
|
+
/* @__PURE__ */ t("th", { children: "Actor" })
|
|
94
|
+
] }) }),
|
|
95
|
+
/* @__PURE__ */ t("tbody", { children: c.map((e) => /* @__PURE__ */ n("tr", { children: [
|
|
96
|
+
/* @__PURE__ */ t("td", { style: { whiteSpace: "nowrap" }, children: T(e.createdAt) }),
|
|
97
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ t(
|
|
98
|
+
"span",
|
|
99
|
+
{
|
|
100
|
+
style: {
|
|
101
|
+
fontWeight: 600,
|
|
102
|
+
color: e.delta > 0 ? "var(--cedros-success, #16a34a)" : e.delta < 0 ? "var(--cedros-danger, #dc2626)" : void 0
|
|
103
|
+
},
|
|
104
|
+
"aria-label": `Delta: ${e.delta > 0 ? "plus" : ""}${e.delta}`,
|
|
105
|
+
children: e.delta > 0 ? `+${e.delta}` : e.delta
|
|
106
|
+
}
|
|
107
|
+
) }),
|
|
108
|
+
/* @__PURE__ */ t("td", { children: e.quantityBefore }),
|
|
109
|
+
/* @__PURE__ */ t("td", { children: e.quantityAfter }),
|
|
110
|
+
/* @__PURE__ */ t("td", { children: e.reason ?? /* @__PURE__ */ t("span", { style: { opacity: 0.45 }, children: "—" }) }),
|
|
111
|
+
/* @__PURE__ */ t("td", { children: e.actor ?? /* @__PURE__ */ t("span", { style: { opacity: 0.45 }, children: "—" }) })
|
|
112
|
+
] }, e.id)) })
|
|
113
|
+
] }) }),
|
|
114
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "0.75rem", fontSize: "0.85rem" }, children: [
|
|
115
|
+
/* @__PURE__ */ t(
|
|
116
|
+
"button",
|
|
117
|
+
{
|
|
118
|
+
type: "button",
|
|
119
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
120
|
+
disabled: l === 0,
|
|
121
|
+
onClick: B,
|
|
122
|
+
children: "Previous"
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ n("span", { children: [
|
|
126
|
+
"Page ",
|
|
127
|
+
Math.floor(l / a) + 1,
|
|
128
|
+
" · ",
|
|
129
|
+
c.length,
|
|
130
|
+
" record",
|
|
131
|
+
c.length !== 1 ? "s" : ""
|
|
132
|
+
] }),
|
|
133
|
+
/* @__PURE__ */ t(
|
|
134
|
+
"button",
|
|
135
|
+
{
|
|
136
|
+
type: "button",
|
|
137
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
138
|
+
disabled: c.length < a,
|
|
139
|
+
onClick: D,
|
|
140
|
+
children: "Next"
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] })
|
|
145
|
+
] }) : /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "Select a product to view its inventory adjustments." })
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
X as InventorySection
|
|
150
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),m=require("./index-C0g-JxJk.js"),S=require("./CedrosContext-C2RjHLaQ.js"),c=50;function q({serverUrl:d,apiKey:h,authManager:j}){const[_,N]=s.useState([]),[A,g]=s.useState(!0),[P,p]=s.useState(null),[o,C]=s.useState(""),[i,x]=s.useState([]),[w,v]=s.useState(!1),[I,f]=s.useState(null),[a,y]=s.useState(0),l=s.useCallback(async t=>{if(j?.isAuthenticated())return j.fetchWithAuth(t);const n={"Content-Type":"application/json"};h&&(n["X-API-Key"]=h);const r=await fetch(`${d}${t}`,{headers:n});if(!r.ok)throw new Error(`Request failed: ${r.status}`);return r.json()},[d,h,j]);s.useEffect(()=>{let t=!1;return g(!0),p(null),l("/admin/products?limit=100&offset=0").then(n=>{if(t)return;const r=Array.isArray(n)?n:n.products??[];N(r)}).catch(n=>{t||(S.getLogger().error("[InventorySection] Failed to load products:",n,{serverUrl:d.slice(0,20)+"..."}),p("Failed to load products"))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[l,d]);const b=s.useCallback(async(t,n)=>{if(t){v(!0),f(null);try{const r=`/admin/products/${encodeURIComponent(t)}/inventory/adjustments?limit=${c}&offset=${n}`,L=await l(r);x(L.adjustments??[])}catch(r){S.getLogger().error("[InventorySection] Failed to load adjustments:",r,{productId:t,serverUrl:d.slice(0,20)+"..."}),f("Failed to load inventory adjustments"),x([])}finally{v(!1)}}},[l,d]);s.useEffect(()=>{o&&b(o,a)},[b,o,a]);const E=t=>{C(t),y(0),x([]),f(null)},$=()=>y(t=>Math.max(0,t-c)),F=()=>y(t=>t+c),u=_.find(t=>t.id===o);return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(m.ErrorBanner,{message:P??I}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Inventory Adjustments"})}),e.jsx("div",{className:"cedros-admin__add-form",style:{marginBottom:"1rem"},children:e.jsx("div",{className:"cedros-admin__form-row",children:e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{htmlFor:"inventory-product-select",className:"cedros-admin__field-label",children:"Select Product"}),A?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading products..."]}):e.jsxs("select",{id:"inventory-product-select",className:"cedros-admin__input",value:o,onChange:t=>E(t.target.value),"aria-label":"Select product to view inventory adjustments",children:[e.jsx("option",{value:"",children:"-- Choose a product --"}),_.map(t=>e.jsx("option",{value:t.id,children:t.title??t.description??t.id},t.id))]})]})})}),o?w?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading adjustments..."]}):e.jsxs(e.Fragment,{children:[u&&e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:["Showing adjustments for: ",e.jsx("strong",{children:u.title??u.description??u.id})]}),i.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No inventory adjustments found."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Delta"}),e.jsx("th",{children:"Before"}),e.jsx("th",{children:"After"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:m.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{style:{fontWeight:600,color:t.delta>0?"var(--cedros-success, #16a34a)":t.delta<0?"var(--cedros-danger, #dc2626)":void 0},"aria-label":`Delta: ${t.delta>0?"plus":""}${t.delta}`,children:t.delta>0?`+${t.delta}`:t.delta})}),e.jsx("td",{children:t.quantityBefore}),e.jsx("td",{children:t.quantityAfter}),e.jsx("td",{children:t.reason??e.jsx("span",{style:{opacity:.45},children:"—"})}),e.jsx("td",{children:t.actor??e.jsx("span",{style:{opacity:.45},children:"—"})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:a===0,onClick:$,children:"Previous"}),e.jsxs("span",{children:["Page ",Math.floor(a/c)+1," · ",i.length," record",i.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:i.length<c,onClick:F,children:"Next"})]})]})]}):e.jsx("div",{className:"cedros-admin__empty",children:"Select a product to view its inventory adjustments."})]})}exports.InventorySection=q;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as i, jsx as e, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import { useState as _, useCallback as k, useEffect as U } from "react";
|
|
3
|
-
import { I as $, E as q } from "./index-
|
|
3
|
+
import { I as $, E as q } from "./index-DXnuQp5x.mjs";
|
|
4
4
|
import { T as C } from "./Toggle-DAxIdpY4.mjs";
|
|
5
5
|
import { u as F } from "./useAutosave-YwMqRzqy.mjs";
|
|
6
|
-
import { A as j } from "./AutosaveIndicator-
|
|
6
|
+
import { A as j } from "./AutosaveIndicator-Bed0-ekg.mjs";
|
|
7
7
|
const u = {
|
|
8
8
|
mailgun: { label: "Mailgun", host: "smtp.mailgun.org", username: "", credentialLabel: "SMTP Password", showUsername: !0, usernameEqualsPassword: !1 },
|
|
9
9
|
sendgrid: { label: "SendGrid", host: "smtp.sendgrid.net", username: "apikey", credentialLabel: "API Key", showUsername: !1, usernameEqualsPassword: !1 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),y=require("./index-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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),y=require("./index-C0g-JxJk.js"),S=require("./Toggle-CsPSF8Dr.js"),q=require("./useAutosave-B2p6iwh8.js"),z=require("./AutosaveIndicator-Dn_qA2hK.js"),p={mailgun:{label:"Mailgun",host:"smtp.mailgun.org",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1},sendgrid:{label:"SendGrid",host:"smtp.sendgrid.net",username:"apikey",credentialLabel:"API Key",showUsername:!1,usernameEqualsPassword:!1},postmark:{label:"Postmark",host:"smtp.postmarkapp.com",username:"",credentialLabel:"Server API Token",showUsername:!1,usernameEqualsPassword:!0},ses:{label:"AWS SES",host:"email-smtp.us-east-1.amazonaws.com",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1},resend:{label:"Resend",host:"smtp.resend.com",username:"resend",credentialLabel:"API Key",showUsername:!1,usernameEqualsPassword:!1},custom:{label:"Custom SMTP",host:"",username:"",credentialLabel:"SMTP Password",showUsername:!0,usernameEqualsPassword:!1}};function R(c){if(!c)return"custom";for(const[d,n]of Object.entries(p))if(n.host&&c===n.host)return d;return"custom"}const v={email_enabled:!1,email_provider:"custom",smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",from_email:"",from_name:"",webhook_enabled:!1,webhook_url:"",webhook_secret:"",webhook_timeout:30};function W({serverUrl:c,apiKey:d,authManager:n}){const[m,b]=l.useState("messages"),[a,h]=l.useState(v),[N,k]=l.useState(!0),[C,E]=l.useState(!0),[P,f]=l.useState(null),[_,j]=l.useState(new Set),g=l.useCallback(async()=>{try{f(null);let s;const t="/admin/config/messaging";if(n?.isAuthenticated())s=await n.fetchWithAuth(t);else{const o={"Content-Type":"application/json"};d&&(o["X-API-Key"]=d);const u=await fetch(`${c}${t}`,{headers:o});if(!u.ok)throw new Error(`Failed to fetch: ${u.status}`);s=await u.json()}const i={...v,...s.config};i.email_provider||(i.email_provider=R(i.smtp_host)),h(i)}catch{h(v),f("Could not load saved settings. Showing defaults.")}finally{k(!1),setTimeout(()=>E(!1),100)}},[c,d,n]);l.useEffect(()=>{g()},[g]);const T=l.useCallback(async s=>{const t="/admin/config/messaging",i={...s};_.has("smtp_password")||delete i.smtp_password,_.has("webhook_secret")||delete i.webhook_secret;const o=JSON.stringify({config:i});try{if(n?.isAuthenticated())await n.fetchWithAuth(t,{method:"PUT",body:o});else{const u={"Content-Type":"application/json"};d&&(u["X-API-Key"]=d);const w=await fetch(`${c}${t}`,{method:"PUT",headers:u,body:o});if(!w.ok)throw new Error(`Failed to save: ${w.status}`)}}catch{throw f("Failed to save messaging settings"),new Error("Save failed")}},[c,d,n,_]),{status:A,error:I}=q.useAutosave({data:a,onSave:T,debounceMs:1500,enabled:!C}),r=(s,t)=>{(s==="smtp_password"||s==="webhook_secret")&&j(i=>new Set(i).add(s)),h(i=>({...i,[s]:t}))},L=s=>{const t=p[s];h(i=>({...i,email_provider:s,smtp_host:t.host||i.smtp_host,smtp_port:587,smtp_username:t.username||(t.showUsername?i.smtp_username:"")}))},M=s=>{const t=a.email_provider||"custom",i=p[t];j(o=>new Set(o).add("smtp_password")),i.usernameEqualsPassword?h(o=>({...o,smtp_password:s,smtp_username:s})):h(o=>({...o,smtp_password:s}))},x=p[a.email_provider||"custom"]??p.custom;return N?e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__loading",style:{marginTop:"1rem"},children:[y.Icons.loading," Loading message settings..."]})]}):e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="messages"?"cedros-admin__tab--active":""}`,onClick:()=>b("messages"),children:"Messages"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="email"?"cedros-admin__tab--active":""}`,onClick:()=>b("email"),children:"Email"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${m==="webhooks"?"cedros-admin__tab--active":""}`,onClick:()=>b("webhooks"),children:"Webhooks"}),e.jsx("div",{style:{flex:1}}),e.jsx(z.AutosaveIndicator,{status:A,error:I})]}),e.jsx(y.ErrorBanner,{message:P,onRetry:g}),e.jsxs("div",{className:"cedros-admin__tab-content",style:{marginTop:"1rem"},children:[m==="messages"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Enable or disable notification types. Configure the delivery settings in the Email or Webhooks tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(S.Toggle,{checked:a.email_enabled,onChange:s=>r("email_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Email Confirmation"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send order confirmation emails to customers after successful purchase."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Email configuration"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(S.Toggle,{checked:a.webhook_enabled,onChange:s=>r("webhook_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Admin Purchase Notification"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send webhook notifications to your server when a purchase is completed."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Webhook configuration"})]})]})]})]}),m==="email"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Select your email service provider for automatic configuration."}),!a.email_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Email notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.email_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Email Provider"}),e.jsx("select",{className:"cedros-admin__input",value:a.email_provider||"custom",onChange:s=>L(s.target.value),disabled:!a.email_enabled,children:Object.entries(p).map(([s,{label:t}])=>e.jsx("option",{value:s,children:t},s))})]}),a.email_provider==="custom"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Host"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_host,onChange:s=>r("smtp_host",s.target.value),placeholder:"smtp.example.com",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Port"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.smtp_port,onChange:s=>r("smtp_port",parseInt(s.target.value)||587),placeholder:"587",disabled:!a.email_enabled,style:{maxWidth:120}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Common: 587 (TLS), 465 (SSL), 25 (unencrypted)."})]})]}),x.showUsername&&e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Username"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_username,onChange:s=>r("smtp_username",s.target.value),placeholder:a.email_provider==="mailgun"?"postmaster@your-domain.com":"username",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:x.credentialLabel}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:_.has("smtp_password")?a.smtp_password:"",onChange:s=>M(s.target.value),placeholder:a.smtp_password?"••••••••":`Enter ${x.credentialLabel.toLowerCase()}`,disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Email"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.from_email,onChange:s=>r("from_email",s.target.value),placeholder:"noreply@example.com",disabled:!a.email_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Default sender email address."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Name"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.from_name,onChange:s=>r("from_name",s.target.value),placeholder:"Your Store",disabled:!a.email_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Default sender display name."})]})]})]}),m==="webhooks"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Configure webhook endpoint for receiving purchase notifications."}),!a.webhook_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Webhook notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.webhook_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook URL"}),e.jsx("input",{type:"url",className:"cedros-admin__input",value:a.webhook_url,onChange:s=>r("webhook_url",s.target.value),placeholder:"https://api.yoursite.com/webhooks/orders",disabled:!a.webhook_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook Secret"}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:_.has("webhook_secret")?a.webhook_secret:"",onChange:s=>r("webhook_secret",s.target.value),placeholder:a.webhook_secret?"••••••••":"Enter secret for HMAC-SHA256",disabled:!a.webhook_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Used for HMAC-SHA256 signature verification"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Timeout (seconds)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.webhook_timeout,onChange:s=>r("webhook_timeout",parseInt(s.target.value)||30),placeholder:"30",disabled:!a.webhook_enabled,style:{maxWidth:120}})]})]})]})]})]})}exports.MessagingSection=W;
|
|
@@ -1,8 +1,8 @@
|
|
|
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,
|
|
3
|
+
import { I as z, E as G, k as F, s as L } from "./index-DXnuQp5x.mjs";
|
|
4
4
|
function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
|
|
5
|
-
const [c, t] = r([]), [o, y] = r(0), [R, x] = r(!0), [S, C] = r(null), [h,
|
|
5
|
+
const [c, t] = r([]), [o, y] = r(0), [R, x] = r(!0), [S, C] = r(null), [h, k] = r(null), [D, v] = r(null), [E, b] = r([]), [O, w] = r(!1), [f, T] = r(""), g = N(async (n, d) => {
|
|
6
6
|
if (l?.isAuthenticated())
|
|
7
7
|
return l.fetchWithAuth(n, d);
|
|
8
8
|
const _ = { "Content-Type": "application/json" };
|
|
@@ -33,7 +33,7 @@ function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
|
|
|
33
33
|
p();
|
|
34
34
|
}, [p]);
|
|
35
35
|
const A = N(async (n) => {
|
|
36
|
-
|
|
36
|
+
w(!0);
|
|
37
37
|
try {
|
|
38
38
|
const [d, _] = await Promise.all([
|
|
39
39
|
g(`/admin/orders/${encodeURIComponent(n)}`),
|
|
@@ -43,10 +43,10 @@ function J({ serverUrl: a, apiKey: s, pageSize: m = 20, authManager: l }) {
|
|
|
43
43
|
} catch {
|
|
44
44
|
v(null), b([]);
|
|
45
45
|
} finally {
|
|
46
|
-
|
|
46
|
+
w(!1);
|
|
47
47
|
}
|
|
48
48
|
}, [g]), j = (n) => {
|
|
49
|
-
h === n ? (
|
|
49
|
+
h === n ? (k(null), v(null), b([])) : (k(n), A(n));
|
|
50
50
|
}, B = (n, d) => d === "USD" || d === "usd" ? `$${(n / 100).toFixed(2)}` : `${n} ${d}`;
|
|
51
51
|
return /* @__PURE__ */ i("div", { className: "cedros-admin__section", children: [
|
|
52
52
|
/* @__PURE__ */ i("div", { className: "cedros-admin__section-header", children: [
|
|
@@ -193,7 +193,7 @@ function W({
|
|
|
193
193
|
a.fulfillments.map((t) => /* @__PURE__ */ i("div", { style: { fontSize: "0.8125rem", marginBottom: "0.25rem" }, children: [
|
|
194
194
|
/* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${I(t.status)}`, children: t.status }),
|
|
195
195
|
t.carrier ? /* @__PURE__ */ e("span", { style: { marginLeft: "0.5rem" }, children: t.carrier }) : null,
|
|
196
|
-
t.trackingNumber ?
|
|
196
|
+
t.trackingNumber ? L(t.trackingUrl) ? /* @__PURE__ */ e("a", { href: L(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
197
|
] }, t.id))
|
|
198
198
|
] }) : null,
|
|
199
199
|
a?.history && a.history.length > 0 ? /* @__PURE__ */ i("div", { children: [
|