@cedros/pay-react 1.1.15 → 1.1.17
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--jn-BNmd.mjs +539 -0
- package/dist/AISettingsSection-BrXUD4l_.js +51 -0
- package/dist/AutosaveIndicator-B3T328jH.mjs +35 -0
- package/dist/AutosaveIndicator-BQkm3cn8.js +1 -0
- package/dist/{CedrosContext-D7nh5-Zh.mjs → CedrosContext-BnJ2Cf7R.mjs} +1179 -642
- package/dist/CedrosContext-C26DlvLF.js +6 -0
- package/dist/CryptoButton-B4-oJ8lF.js +1 -0
- package/dist/CryptoButton-Dhxnk9d7.mjs +542 -0
- package/dist/FAQSection-BB1wJRsR.mjs +366 -0
- package/dist/FAQSection-aoAz35MV.js +1 -0
- package/dist/MessagingSection-BG9O62ko.mjs +347 -0
- package/dist/MessagingSection-DId-WJdU.js +1 -0
- package/dist/PaymentSettingsSection-D92IO4xJ.js +1 -0
- package/dist/PaymentSettingsSection-c13RAUxn.mjs +94 -0
- package/dist/SettingsSection-DUxjXl2G.js +1 -0
- package/dist/SettingsSection-htem-WL3.mjs +57 -0
- package/dist/SingleCategorySettings-BIEs6s6Z.mjs +1421 -0
- package/dist/SingleCategorySettings-CQ-osdzb.js +3 -0
- package/dist/StorefrontSection-CKTQt255.mjs +765 -0
- package/dist/StorefrontSection-DcSoDx-k.js +1 -0
- package/dist/SubscriptionsSection-C0hYf7Hr.js +1 -0
- package/dist/SubscriptionsSection-CONwHhT4.mjs +616 -0
- package/dist/Toggle-CsPSF8Dr.js +1 -0
- package/dist/Toggle-DAxIdpY4.mjs +48 -0
- package/dist/WalletManager-D6BYTwXn.js +1 -0
- package/dist/{WalletManager-oEjZhaFk.mjs → WalletManager-HXXyARQ7.mjs} +36 -32
- package/dist/components/CedrosPay.d.ts.map +1 -1
- package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
- package/dist/components/PaymentModal.d.ts.map +1 -1
- package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
- package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
- package/dist/components/admin/AdminAuthManager.d.ts +2 -1
- package/dist/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/components/admin/AutosaveIndicator.d.ts +7 -0
- package/dist/components/admin/AutosaveIndicator.d.ts.map +1 -0
- package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/components/admin/ConfigEditor.d.ts +0 -2
- package/dist/components/admin/ConfigEditor.d.ts.map +1 -1
- package/dist/components/admin/MessagingSection.d.ts.map +1 -1
- package/dist/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/components/admin/SecretArrayEditor.d.ts +16 -0
- package/dist/components/admin/SecretArrayEditor.d.ts.map +1 -0
- package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
- package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
- package/dist/components/admin/Toggle.d.ts +14 -0
- package/dist/components/admin/Toggle.d.ts.map +1 -0
- package/dist/components/admin/TokenMintSelector.d.ts +27 -0
- package/dist/components/admin/TokenMintSelector.d.ts.map +1 -0
- package/dist/components/admin/configApi.d.ts +5 -3
- package/dist/components/admin/configApi.d.ts.map +1 -1
- package/dist/components/admin/index.d.ts +8 -9
- package/dist/components/admin/index.d.ts.map +1 -1
- package/dist/components/admin/sections-more.d.ts +2 -9
- package/dist/components/admin/sections-more.d.ts.map +1 -1
- package/dist/context/CedrosContext.d.ts +1 -1
- package/dist/context/CedrosContext.d.ts.map +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +391 -380
- package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/storage.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/storage.test.d.ts.map +1 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts +5 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts +2 -0
- package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
- package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -1
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -1
- package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -1
- package/dist/ecommerce/config/context.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -1
- package/dist/ecommerce/index.d.ts +2 -0
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -1
- package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -1
- package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +1 -1
- package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
- package/dist/ecommerce/utils/storage.d.ts +1 -1
- package/dist/ecommerce/utils/storage.d.ts.map +1 -1
- package/dist/hooks/useCreditsPayment.d.ts.map +1 -1
- package/dist/hooks/useCreditsSubscription.d.ts.map +1 -1
- package/dist/hooks/useCryptoSubscription.d.ts.map +1 -1
- package/dist/hooks/useRefundVerification.d.ts.map +1 -1
- package/dist/hooks/useStripeCheckout.d.ts +1 -1
- package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
- package/dist/hooks/useSubscription.d.ts.map +1 -1
- package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/hooks/useX402Payment.d.ts.map +1 -1
- package/dist/index-2N_CMVAv.js +84 -0
- package/dist/index-C1hbnxn0.mjs +22915 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +67 -72
- package/dist/managers/CreditsManager.d.ts +6 -0
- package/dist/managers/CreditsManager.d.ts.map +1 -1
- package/dist/managers/ManagerCache.d.ts.map +1 -1
- package/dist/managers/RouteDiscoveryManager.d.ts +3 -0
- package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
- package/dist/managers/StripeManager.d.ts +15 -0
- package/dist/managers/StripeManager.d.ts.map +1 -1
- package/dist/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/managers/SubscriptionManager.d.ts +7 -14
- package/dist/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/managers/WalletManager.d.ts +2 -1
- package/dist/managers/WalletManager.d.ts.map +1 -1
- package/dist/managers/X402Manager.d.ts.map +1 -1
- package/dist/{sections-DG4Ws13b.js → sections-D2GMJuKq.js} +1 -1
- package/dist/{sections-Dl8qjlql.mjs → sections-DICaHGhz.mjs} +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +67 -72
- package/dist/telemetry.js +1 -1
- package/dist/telemetry.mjs +23 -25
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/types/index.d.ts +13 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/useAutosave-B2p6iwh8.js +1 -0
- package/dist/useAutosave-YwMqRzqy.mjs +44 -0
- package/dist/utils/circuitBreaker.d.ts +3 -1
- package/dist/utils/circuitBreaker.d.ts.map +1 -1
- package/dist/utils/cspHelper.d.ts +6 -0
- package/dist/utils/cspHelper.d.ts.map +1 -1
- package/dist/utils/csvHelpers.d.ts +0 -41
- package/dist/utils/csvHelpers.d.ts.map +1 -1
- package/dist/utils/errorHandling.d.ts.map +1 -1
- package/dist/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/utils/requestDeduplication.d.ts.map +1 -1
- package/dist/utils/telemetry.d.ts.map +1 -1
- package/dist/utils/validateConfig.d.ts +1 -1
- package/dist/utils/validateConfig.d.ts.map +1 -1
- package/dist/walletDetection-JZR3UCOa.mjs +27 -0
- package/dist/walletDetection-bNmV5ItZ.js +1 -0
- package/dist/{walletPool-BR6etEiq.mjs → walletPool-BV_z1lEA.mjs} +1 -1
- package/dist/{walletPool-BZyAG4YS.js → walletPool-DjA7J3a9.js} +1 -1
- package/package.json +8 -7
- package/dist/CedrosContext-C2v_s8cc.js +0 -6
- package/dist/WalletManager-B5KLZK2D.js +0 -1
- package/dist/index-BjxGupjw.mjs +0 -27893
- package/dist/index-DW6XWuRP.js +0 -136
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-2N_CMVAv.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-BQkm3cn8.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-2N_CMVAv.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),m({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),m({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return j("Failed to save subscription settings"),!1}},[f,b,v]),E=d.useMemo(()=>x.enabled!==l.enabled||x.pageTitle!==l.pageTitle||x.pageSubtitle!==l.pageSubtitle||x.annualSavingsBadge!==l.annualSavingsBadge||x.popularBadgeText!==l.popularBadgeText||x.footerNotice!==l.footerNotice,[l,x]),D=d.useMemo(()=>JSON.stringify(r.plans),[r.plans]),U=d.useMemo(()=>F!==D,[D,F]),S=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await I(e);h(e),t&&(P({enabled:e.enabled,pageTitle:e.pageTitle,pageSubtitle:e.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge,popularBadgeText:e.popularBadgeText,footerNotice:e.footerNotice}),C(JSON.stringify(e.plans))),B(t?"saved":"error"),setTimeout(()=>B("idle"),1500)},[l,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(g=>g.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>m(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>m(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>m(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>m(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>m(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?u.Icons.chevronDown:u.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:u.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:u.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:u.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>Q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:g=>J(e.id,o,g.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
|