@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.
Files changed (174) hide show
  1. package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
  2. package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
  3. package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
  5. package/dist/CedrosContext-C2RjHLaQ.js +6 -0
  6. package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
  7. package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
  8. package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
  9. package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
  10. package/dist/ComplianceSection-DP2a9-S0.js +1 -0
  11. package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
  12. package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
  13. package/dist/CustomersSection-CBwy_waO.js +1 -0
  14. package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
  15. package/dist/DisputesSection-BLjIk60n.js +1 -0
  16. package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
  17. package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
  18. package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
  19. package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
  20. package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
  21. package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
  22. package/dist/InventorySection-zV6lTmue.js +1 -0
  23. package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
  24. package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
  25. package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
  26. package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
  27. package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
  28. package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
  29. package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
  30. package/dist/ReturnsSection-D_pJVxuG.js +1 -0
  31. package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
  32. package/dist/SettingsSection-vdYFSNxB.js +1 -0
  33. package/dist/ShippingSection-1DRSTu49.js +1 -0
  34. package/dist/ShippingSection-BOgto6_9.mjs +434 -0
  35. package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
  36. package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
  37. package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
  38. package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
  39. package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
  40. package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
  41. package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
  42. package/dist/TaxSection-Dt1DnM51.js +1 -0
  43. package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
  44. package/dist/Token22Section-DY3mUwTY.js +1 -0
  45. package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
  46. package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
  47. package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
  48. package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
  49. package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
  50. package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
  51. package/dist/crypto-only.js +1 -1
  52. package/dist/crypto-only.mjs +85 -83
  53. package/dist/index-C0g-JxJk.js +84 -0
  54. package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
  55. package/dist/index.js +1 -1
  56. package/dist/index.mjs +42 -40
  57. package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
  58. package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
  59. package/dist/src/admin/plugin.d.ts.map +1 -1
  60. package/dist/src/components/ComplianceGatePage.d.ts +40 -0
  61. package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
  62. package/dist/src/components/SubscribeButton.d.ts +1 -5
  63. package/dist/src/components/SubscribeButton.d.ts.map +1 -1
  64. package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
  65. package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
  66. package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
  67. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  68. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  69. package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
  70. package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
  71. package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
  72. package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
  73. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
  74. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
  75. package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
  76. package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
  77. package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
  78. package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
  79. package/dist/src/components/admin/CustomersSection.d.ts +3 -0
  80. package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
  81. package/dist/src/components/admin/DisputesSection.d.ts +3 -0
  82. package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
  83. package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
  84. package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
  85. package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
  86. package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
  87. package/dist/src/components/admin/ImagesSection.d.ts +3 -0
  88. package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
  89. package/dist/src/components/admin/InventorySection.d.ts +3 -0
  90. package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
  91. package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
  92. package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
  93. package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
  94. package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
  95. package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
  96. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  97. package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
  98. package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
  99. package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
  100. package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
  101. package/dist/src/components/admin/ShippingSection.d.ts +3 -0
  102. package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
  103. package/dist/src/components/admin/TaxSection.d.ts +3 -0
  104. package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
  105. package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
  106. package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
  107. package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
  108. package/dist/src/components/admin/complianceTypes.d.ts +74 -0
  109. package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
  110. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  111. package/dist/src/components/admin/icons.d.ts +1 -0
  112. package/dist/src/components/admin/icons.d.ts.map +1 -1
  113. package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
  114. package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
  115. package/dist/src/context/CedrosContext.d.ts.map +1 -1
  116. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
  117. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  118. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  119. package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
  120. package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
  121. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
  122. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  123. package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
  124. package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
  125. package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
  126. package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
  127. package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
  128. package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
  129. package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
  130. package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
  131. package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
  132. package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
  133. package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
  134. package/dist/src/ecommerce/index.d.ts +12 -2
  135. package/dist/src/ecommerce/index.d.ts.map +1 -1
  136. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
  137. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
  138. package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  139. package/dist/src/ecommerce/types.d.ts +6 -0
  140. package/dist/src/ecommerce/types.d.ts.map +1 -1
  141. package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
  142. package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
  143. package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
  144. package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
  145. package/dist/src/index.d.ts +4 -0
  146. package/dist/src/index.d.ts.map +1 -1
  147. package/dist/src/managers/CreditsManager.d.ts.map +1 -1
  148. package/dist/src/managers/ManagerCache.d.ts +2 -2
  149. package/dist/src/managers/ManagerCache.d.ts.map +1 -1
  150. package/dist/src/managers/StripeManager.d.ts +7 -1
  151. package/dist/src/managers/StripeManager.d.ts.map +1 -1
  152. package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
  153. package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
  154. package/dist/src/types/index.d.ts +14 -0
  155. package/dist/src/types/index.d.ts.map +1 -1
  156. package/dist/src/types/subscription.d.ts +21 -33
  157. package/dist/src/types/subscription.d.ts.map +1 -1
  158. package/dist/src/utils/exponentialBackoff.d.ts +22 -0
  159. package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
  160. package/dist/stripe-only.js +1 -1
  161. package/dist/stripe-only.mjs +2 -2
  162. package/dist/styles-BT4bhFey.js +1 -0
  163. package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
  164. package/dist/testing/index.js +1 -1
  165. package/dist/testing/index.mjs +1 -1
  166. package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
  167. package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
  168. package/package.json +1 -1
  169. package/dist/CedrosContext-7dwmEeUY.js +0 -6
  170. package/dist/SettingsSection-cKF0tLnS.js +0 -1
  171. package/dist/Token22Section-DUUl59dZ.js +0 -1
  172. package/dist/Token22Section-HygkDNtL.mjs +0 -1685
  173. package/dist/index-OaWkrl0G.js +0 -84
  174. package/dist/styles-21F1-oqx.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),u=require("./index-OaWkrl0G.js");function A({serverUrl:n,apiKey:d,pageSize:o=20,authManager:r}){const[l,s]=a.useState([]),[c,p]=a.useState(0),[w,v]=a.useState(!0),[b,S]=a.useState(null),[h,N]=a.useState(null),[L,_]=a.useState(null),[R,y]=a.useState([]),[$,C]=a.useState(!1),[j,F]=a.useState(""),x=a.useCallback(async(t,i)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,i);const f={"Content-Type":"application/json"};d&&(f["X-API-Key"]=d);const m=await fetch(`${n}${t}`,{...i,headers:{...f,...i?.headers}});if(!m.ok){const I=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(I)}return m.json()},[n,d,r]),g=a.useCallback(async()=>{v(!0);try{S(null);const t=new URLSearchParams({limit:String(o)});j&&t.set("status",j);const i=await x(`/admin/orders?${t}`);s(i.orders),p(i.total)}catch{S("Failed to load orders")}finally{v(!1)}},[x,o,j]);a.useEffect(()=>{g()},[g]);const O=a.useCallback(async t=>{C(!0);try{const[i,f]=await Promise.all([x(`/admin/orders/${encodeURIComponent(t)}`),x("/admin/gift-card-redemptions?limit=50").catch(()=>[])]);_(i),y(f.filter(m=>m.orderId===t))}catch{_(null),y([])}finally{C(!1)}},[x]),T=t=>{h===t?(N(null),_(null),y([])):(N(t),O(t))},D=(t,i)=>i==="USD"||i==="usd"?`$${(t/100).toFixed(2)}`:`${t} ${i}`;return e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h2",{className:"cedros-admin__section-title",children:"Orders"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",style:{width:"auto",minWidth:"120px"},value:j,onChange:t=>F(t.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"paid",children:"Paid"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"fulfilled",children:"Fulfilled"}),e.jsx("option",{value:"shipped",children:"Shipped"}),e.jsx("option",{value:"delivered",children:"Delivered"}),e.jsx("option",{value:"cancelled",children:"Cancelled"}),e.jsx("option",{value:"refunded",children:"Refunded"})]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:g,children:[u.Icons.refresh," Refresh"]})]})]}),b?e.jsx(u.ErrorBanner,{message:b,onRetry:g}):null,w?e.jsx("div",{className:"cedros-admin__loading-text",children:"Loading orders..."}):l.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No orders found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__table-info",children:[c," order",c===1?"":"s"," total"]}),e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Customer"}),e.jsx("th",{children:"Date"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsx(E,{order:t,expanded:h===t.id,detail:h===t.id?L:null,redemptions:h===t.id?R:[],detailLoading:h===t.id&&$,onToggle:()=>T(t.id),formatAmount:D},t.id))})]})]})]})}function E({order:n,expanded:d,detail:o,redemptions:r,detailLoading:l,onToggle:s,formatAmount:c}){const p=n.metadata?.recipient_email||r.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:s,style:{cursor:"pointer"},className:d?"cedros-admin__table-row--active":"",children:[e.jsxs("td",{children:[e.jsxs("span",{className:"cedros-admin__mono",children:[n.id.slice(0,12),"..."]}),p?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Gift Card"}):null]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(n.status)}`,children:n.status})}),e.jsx("td",{children:c(n.amount,n.amountAsset)}),e.jsx("td",{children:n.source}),e.jsx("td",{children:n.customerEmail||n.customerName||"—"}),e.jsx("td",{children:u.formatDateTime(n.createdAt)})]}),d?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:0},children:e.jsx(P,{detail:o,redemptions:r,loading:l,formatAmount:c,metadata:n.metadata})})}):null]})}function P({detail:n,redemptions:d,loading:o,formatAmount:r,metadata:l}){return o?e.jsx("div",{style:{padding:"1rem"},className:"cedros-admin__loading-text",children:"Loading details..."}):e.jsxs("div",{style:{padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)"},children:[Object.keys(l).length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Order Metadata"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",fontSize:"0.8125rem"},children:Object.entries(l).map(([s,c])=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--cedros-admin-text-muted)"},children:s}),e.jsx("span",{children:c})]},s))})]}):null,d.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Gift Card Fulfillment"}),d.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",padding:"0.5rem",border:"1px solid var(--cedros-admin-border)",borderRadius:"0.5rem",marginBottom:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("span",{children:["Face value: ",r(s.faceValueCents,s.currency)]}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${s.creditsIssued>0?"success":"warning"}`,children:s.creditsIssued>0?"Credits issued":"Pending"})]}),e.jsxs("div",{style:{marginTop:"0.25rem",color:"var(--cedros-admin-text-muted)"},children:["Recipient: ",s.recipientUserId||"—",s.tokenMinted?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Token minted"}):null]})]},s.id))]}):null,n?.fulfillments&&n.fulfillments.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Fulfillments"}),n.fulfillments.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(s.status)}`,children:s.status}),s.carrier?e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.carrier}):null,s.trackingNumber?u.safeHref(s.trackingUrl)?e.jsx("a",{href:u.safeHref(s.trackingUrl),target:"_blank",rel:"noreferrer",style:{marginLeft:"0.5rem"},children:s.trackingNumber}):e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.trackingNumber}):null]},s.id))]}):null,n?.history&&n.history.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__label",children:"Status History"}),n.history.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{style:{color:"var(--cedros-admin-text-muted)"},children:u.formatDateTime(s.createdAt)})," ",s.fromStatus," → ",s.toStatus,s.note?e.jsx("span",{style:{marginLeft:"0.5rem",fontStyle:"italic"},children:s.note}):null]},s.id))]}):null]})}function k(n){switch(n){case"paid":case"fulfilled":case"delivered":case"success":return"success";case"processing":case"shipped":case"pending":return"warning";case"cancelled":case"refunded":case"failed":return"error";default:return"default"}}exports.OrdersSection=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),u=require("./index-C0g-JxJk.js");function A({serverUrl:n,apiKey:d,pageSize:o=20,authManager:r}){const[l,s]=a.useState([]),[c,p]=a.useState(0),[w,v]=a.useState(!0),[b,S]=a.useState(null),[h,N]=a.useState(null),[L,_]=a.useState(null),[R,y]=a.useState([]),[$,C]=a.useState(!1),[j,F]=a.useState(""),x=a.useCallback(async(t,i)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,i);const f={"Content-Type":"application/json"};d&&(f["X-API-Key"]=d);const m=await fetch(`${n}${t}`,{...i,headers:{...f,...i?.headers}});if(!m.ok){const I=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(I)}return m.json()},[n,d,r]),g=a.useCallback(async()=>{v(!0);try{S(null);const t=new URLSearchParams({limit:String(o)});j&&t.set("status",j);const i=await x(`/admin/orders?${t}`);s(i.orders),p(i.total)}catch{S("Failed to load orders")}finally{v(!1)}},[x,o,j]);a.useEffect(()=>{g()},[g]);const O=a.useCallback(async t=>{C(!0);try{const[i,f]=await Promise.all([x(`/admin/orders/${encodeURIComponent(t)}`),x("/admin/gift-card-redemptions?limit=50").catch(()=>[])]);_(i),y(f.filter(m=>m.orderId===t))}catch{_(null),y([])}finally{C(!1)}},[x]),T=t=>{h===t?(N(null),_(null),y([])):(N(t),O(t))},D=(t,i)=>i==="USD"||i==="usd"?`$${(t/100).toFixed(2)}`:`${t} ${i}`;return e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h2",{className:"cedros-admin__section-title",children:"Orders"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",style:{width:"auto",minWidth:"120px"},value:j,onChange:t=>F(t.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"paid",children:"Paid"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"fulfilled",children:"Fulfilled"}),e.jsx("option",{value:"shipped",children:"Shipped"}),e.jsx("option",{value:"delivered",children:"Delivered"}),e.jsx("option",{value:"cancelled",children:"Cancelled"}),e.jsx("option",{value:"refunded",children:"Refunded"})]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:g,children:[u.Icons.refresh," Refresh"]})]})]}),b?e.jsx(u.ErrorBanner,{message:b,onRetry:g}):null,w?e.jsx("div",{className:"cedros-admin__loading-text",children:"Loading orders..."}):l.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No orders found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__table-info",children:[c," order",c===1?"":"s"," total"]}),e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Customer"}),e.jsx("th",{children:"Date"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsx(E,{order:t,expanded:h===t.id,detail:h===t.id?L:null,redemptions:h===t.id?R:[],detailLoading:h===t.id&&$,onToggle:()=>T(t.id),formatAmount:D},t.id))})]})]})]})}function E({order:n,expanded:d,detail:o,redemptions:r,detailLoading:l,onToggle:s,formatAmount:c}){const p=n.metadata?.recipient_email||r.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:s,style:{cursor:"pointer"},className:d?"cedros-admin__table-row--active":"",children:[e.jsxs("td",{children:[e.jsxs("span",{className:"cedros-admin__mono",children:[n.id.slice(0,12),"..."]}),p?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Gift Card"}):null]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(n.status)}`,children:n.status})}),e.jsx("td",{children:c(n.amount,n.amountAsset)}),e.jsx("td",{children:n.source}),e.jsx("td",{children:n.customerEmail||n.customerName||"—"}),e.jsx("td",{children:u.formatDateTime(n.createdAt)})]}),d?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:0},children:e.jsx(P,{detail:o,redemptions:r,loading:l,formatAmount:c,metadata:n.metadata})})}):null]})}function P({detail:n,redemptions:d,loading:o,formatAmount:r,metadata:l}){return o?e.jsx("div",{style:{padding:"1rem"},className:"cedros-admin__loading-text",children:"Loading details..."}):e.jsxs("div",{style:{padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)"},children:[Object.keys(l).length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Order Metadata"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",fontSize:"0.8125rem"},children:Object.entries(l).map(([s,c])=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--cedros-admin-text-muted)"},children:s}),e.jsx("span",{children:c})]},s))})]}):null,d.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Gift Card Fulfillment"}),d.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",padding:"0.5rem",border:"1px solid var(--cedros-admin-border)",borderRadius:"0.5rem",marginBottom:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("span",{children:["Face value: ",r(s.faceValueCents,s.currency)]}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${s.creditsIssued>0?"success":"warning"}`,children:s.creditsIssued>0?"Credits issued":"Pending"})]}),e.jsxs("div",{style:{marginTop:"0.25rem",color:"var(--cedros-admin-text-muted)"},children:["Recipient: ",s.recipientUserId||"—",s.tokenMinted?e.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--info",style:{marginLeft:"0.5rem"},children:"Token minted"}):null]})]},s.id))]}):null,n?.fulfillments&&n.fulfillments.length>0?e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsx("div",{className:"cedros-admin__label",children:"Fulfillments"}),n.fulfillments.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${k(s.status)}`,children:s.status}),s.carrier?e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.carrier}):null,s.trackingNumber?u.safeHref(s.trackingUrl)?e.jsx("a",{href:u.safeHref(s.trackingUrl),target:"_blank",rel:"noreferrer",style:{marginLeft:"0.5rem"},children:s.trackingNumber}):e.jsx("span",{style:{marginLeft:"0.5rem"},children:s.trackingNumber}):null]},s.id))]}):null,n?.history&&n.history.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__label",children:"Status History"}),n.history.map(s=>e.jsxs("div",{style:{fontSize:"0.8125rem",marginBottom:"0.25rem"},children:[e.jsx("span",{style:{color:"var(--cedros-admin-text-muted)"},children:u.formatDateTime(s.createdAt)})," ",s.fromStatus," → ",s.toStatus,s.note?e.jsx("span",{style:{marginLeft:"0.5rem",fontStyle:"italic"},children:s.note}):null]},s.id))]}):null]})}function k(n){switch(n){case"paid":case"fulfilled":case"delivered":case"success":return"success";case"processing":case"shipped":case"pending":return"warning";case"cancelled":case"refunded":case"failed":return"error";default:return"default"}}exports.OrdersSection=A;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),p=require("./SingleCategorySettings-CRXTMTo5.js");function r({href:s,children:n}){return e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:n})}const a=[{id:"stripe",label:"Stripe",category:"stripe",description:e.jsxs(e.Fragment,{children:["Configure your Stripe integration for card payments. Get your API keys from the"," ",e.jsx(r,{href:"https://dashboard.stripe.com/apikeys",children:"Stripe Dashboard"}),"."]})},{id:"crypto",label:"Crypto",category:"x402",description:e.jsxs(e.Fragment,{children:["Configure Solana wallet and token settings for crypto payments. Get a fast RPC endpoint from"," ",e.jsx(r,{href:"https://www.helius.dev",children:"Helius"})," or"," ",e.jsx(r,{href:"https://www.quicknode.com/chains/sol",children:"QuickNode"}),". Set up a payment address using"," ",e.jsx(r,{href:"https://phantom.app",children:"Phantom"})," or"," ",e.jsx(r,{href:"https://solflare.com",children:"Solflare"})," wallet."]})},{id:"credits",label:"Credits",category:"cedros_login",description:e.jsxs(e.Fragment,{children:["Configure Cedros Login integration for credits payments. See the"," ",e.jsx(r,{href:"https://docs.cedros.dev/credits",children:"Credits API documentation"}),"."]})}];function h({serverUrl:s,apiKey:n,authManager:c}){const[o,d]=l.useState("stripe"),i=a.find(t=>t.id===o);return e.jsxs("div",{className:"cedros-admin__payment-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Payment Options"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure payment methods including Stripe, crypto, and credits."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:a.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${o===t.id?"cedros-admin__tab--active":""}`,onClick:()=>d(t.id),children:t.label},t.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(p.SingleCategorySettings,{serverUrl:s,apiKey:n,authManager:c,category:i.category,title:`${i.label} Settings`,description:i.description,showEnabledToggle:!0},i.category)})]})}exports.PaymentSettingsSection=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),p=require("./SingleCategorySettings-DwCnBdRf.js");function r({href:s,children:n}){return e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:n})}const a=[{id:"stripe",label:"Stripe",category:"stripe",description:e.jsxs(e.Fragment,{children:["Configure your Stripe integration for card payments. Get your API keys from the"," ",e.jsx(r,{href:"https://dashboard.stripe.com/apikeys",children:"Stripe Dashboard"}),"."]})},{id:"crypto",label:"Crypto",category:"x402",description:e.jsxs(e.Fragment,{children:["Configure Solana wallet and token settings for crypto payments. Get a fast RPC endpoint from"," ",e.jsx(r,{href:"https://www.helius.dev",children:"Helius"})," or"," ",e.jsx(r,{href:"https://www.quicknode.com/chains/sol",children:"QuickNode"}),". Set up a payment address using"," ",e.jsx(r,{href:"https://phantom.app",children:"Phantom"})," or"," ",e.jsx(r,{href:"https://solflare.com",children:"Solflare"})," wallet."]})},{id:"credits",label:"Credits",category:"cedros_login",description:e.jsxs(e.Fragment,{children:["Configure Cedros Login integration for credits payments. See the"," ",e.jsx(r,{href:"https://docs.cedros.dev/credits",children:"Credits API documentation"}),"."]})}];function h({serverUrl:s,apiKey:n,authManager:c}){const[o,d]=l.useState("stripe"),i=a.find(t=>t.id===o);return e.jsxs("div",{className:"cedros-admin__payment-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Payment Options"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure payment methods including Stripe, crypto, and credits."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:a.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${o===t.id?"cedros-admin__tab--active":""}`,onClick:()=>d(t.id),children:t.label},t.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(p.SingleCategorySettings,{serverUrl:s,apiKey:n,authManager:c,category:i.category,title:`${i.label} Settings`,description:i.description,showEnabledToggle:!0},i.category)})]})}exports.PaymentSettingsSection=h;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as e, Fragment as s } from "react/jsx-runtime";
2
2
  import { useState as h } from "react";
3
- import { S as m } from "./SingleCategorySettings--LK0TZW0.mjs";
3
+ import { S as m } from "./SingleCategorySettings-suJ8z9d8.mjs";
4
4
  function r({ href: o, children: a }) {
5
5
  return /* @__PURE__ */ e(
6
6
  "a",
@@ -0,0 +1,267 @@
1
+ import { jsx as e, jsxs as n, Fragment as U } from "react/jsx-runtime";
2
+ import { useState as l, useCallback as R, useEffect as D } from "react";
3
+ import { E as O, I as $, k as b } from "./index-DXnuQp5x.mjs";
4
+ const C = ["requested", "approved", "rejected", "received", "refunded"], W = (d) => {
5
+ switch (d) {
6
+ case "approved":
7
+ return "success";
8
+ case "refunded":
9
+ return "success";
10
+ case "rejected":
11
+ return "failed";
12
+ case "received":
13
+ return "muted";
14
+ case "requested":
15
+ return "pending";
16
+ default:
17
+ return "muted";
18
+ }
19
+ };
20
+ function q({ returnRequest: d, onBack: m, onStatusUpdated: c, onError: u, fetchWithAuth: s }) {
21
+ const [r, v] = l(d.status), [_, p] = l(!1), o = async () => {
22
+ if (!(!r || r === d.status)) {
23
+ p(!0);
24
+ try {
25
+ const a = await s(
26
+ `/admin/returns/${encodeURIComponent(d.id)}/status`,
27
+ { method: "PUT", body: JSON.stringify({ status: r }) }
28
+ );
29
+ c(a);
30
+ } catch {
31
+ u("Failed to update return status");
32
+ } finally {
33
+ p(!1);
34
+ }
35
+ }
36
+ };
37
+ return /* @__PURE__ */ n("div", { children: [
38
+ /* @__PURE__ */ e(
39
+ "button",
40
+ {
41
+ type: "button",
42
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
43
+ onClick: m,
44
+ style: { marginBottom: "1rem" },
45
+ children: "← Back to returns"
46
+ }
47
+ ),
48
+ /* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ n("h3", { className: "cedros-admin__section-title", children: [
49
+ "Return ",
50
+ /* @__PURE__ */ e("code", { style: { fontSize: "0.8rem" }, children: d.id.slice(0, 12) }),
51
+ /* @__PURE__ */ e(
52
+ "span",
53
+ {
54
+ className: `cedros-admin__badge cedros-admin__badge--${W(d.status)}`,
55
+ style: { marginLeft: "0.5rem" },
56
+ children: d.status
57
+ }
58
+ )
59
+ ] }) }),
60
+ /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", style: { maxWidth: "500px", marginBottom: "1rem" }, children: /* @__PURE__ */ e("table", { className: "cedros-admin__table", children: /* @__PURE__ */ n("tbody", { children: [
61
+ /* @__PURE__ */ n("tr", { children: [
62
+ /* @__PURE__ */ e("td", { style: { fontWeight: 600, width: "35%" }, children: "Order ID" }),
63
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: d.orderId }) })
64
+ ] }),
65
+ d.reason && /* @__PURE__ */ n("tr", { children: [
66
+ /* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Reason" }),
67
+ /* @__PURE__ */ e("td", { children: d.reason })
68
+ ] }),
69
+ /* @__PURE__ */ n("tr", { children: [
70
+ /* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Created" }),
71
+ /* @__PURE__ */ e("td", { children: b(d.createdAt) })
72
+ ] }),
73
+ d.statusUpdatedAt && /* @__PURE__ */ n("tr", { children: [
74
+ /* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Status Updated" }),
75
+ /* @__PURE__ */ e("td", { children: b(d.statusUpdatedAt) })
76
+ ] }),
77
+ d.updatedAt && /* @__PURE__ */ n("tr", { children: [
78
+ /* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Last Updated" }),
79
+ /* @__PURE__ */ e("td", { children: b(d.updatedAt) })
80
+ ] })
81
+ ] }) }) }),
82
+ /* @__PURE__ */ n("h4", { style: { fontSize: "0.85rem", fontWeight: 600, margin: "0 0 0.5rem" }, children: [
83
+ "Items (",
84
+ d.items.length,
85
+ ")"
86
+ ] }),
87
+ /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", style: { maxWidth: "500px", marginBottom: "1.25rem" }, children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
88
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
89
+ /* @__PURE__ */ e("th", { children: "Product ID" }),
90
+ /* @__PURE__ */ e("th", { children: "Variant ID" }),
91
+ /* @__PURE__ */ e("th", { children: "Qty" })
92
+ ] }) }),
93
+ /* @__PURE__ */ e("tbody", { children: d.items.map((a, h) => /* @__PURE__ */ n("tr", { children: [
94
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { style: { fontSize: "0.75rem" }, children: a.productId }) }),
95
+ /* @__PURE__ */ e("td", { children: a.variantId ? /* @__PURE__ */ e("code", { style: { fontSize: "0.75rem" }, children: a.variantId }) : /* @__PURE__ */ e("span", { style: { color: "var(--cedros-admin-text-muted, #888)" }, children: "—" }) }),
96
+ /* @__PURE__ */ e("td", { children: a.quantity })
97
+ ] }, h)) })
98
+ ] }) }),
99
+ Object.keys(d.metadata).length > 0 && /* @__PURE__ */ n(U, { children: [
100
+ /* @__PURE__ */ e("h4", { style: { fontSize: "0.85rem", fontWeight: 600, margin: "0 0 0.5rem" }, children: "Metadata" }),
101
+ /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", style: { maxWidth: "500px", marginBottom: "1.25rem" }, children: /* @__PURE__ */ e("table", { className: "cedros-admin__table", children: /* @__PURE__ */ e("tbody", { children: Object.entries(d.metadata).map(([a, h]) => /* @__PURE__ */ n("tr", { children: [
102
+ /* @__PURE__ */ e("td", { style: { fontWeight: 600, width: "40%" }, children: a }),
103
+ /* @__PURE__ */ e("td", { children: h })
104
+ ] }, a)) }) }) })
105
+ ] }),
106
+ /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.5rem", alignItems: "flex-end", maxWidth: "400px" }, children: [
107
+ /* @__PURE__ */ n("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
108
+ /* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Update Status" }),
109
+ /* @__PURE__ */ e(
110
+ "select",
111
+ {
112
+ className: "cedros-admin__input",
113
+ value: r,
114
+ onChange: (a) => v(a.target.value),
115
+ children: C.map((a) => /* @__PURE__ */ e("option", { value: a, children: a }, a))
116
+ }
117
+ )
118
+ ] }),
119
+ /* @__PURE__ */ e(
120
+ "button",
121
+ {
122
+ type: "button",
123
+ className: "cedros-admin__button cedros-admin__button--primary",
124
+ onClick: o,
125
+ disabled: _ || r === d.status,
126
+ children: _ ? "Updating..." : "Update"
127
+ }
128
+ )
129
+ ] })
130
+ ] });
131
+ }
132
+ function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
133
+ const [s, r] = l([]), [v, _] = l(!0), [p, o] = l(null), [a, h] = l(0), [g, A] = l("all"), [x, N] = l(null), [k, I] = l(!1), y = R(async (t, i) => {
134
+ if (u?.isAuthenticated())
135
+ return u.fetchWithAuth(t, i);
136
+ const f = { "Content-Type": "application/json" };
137
+ m && (f["X-API-Key"] = m);
138
+ const S = await fetch(`${d}${t}`, { ...i, headers: { ...f, ...i?.headers } });
139
+ if (!S.ok) throw new Error(`Request failed: ${S.status}`);
140
+ return S.json();
141
+ }, [d, m, u]), w = R(async () => {
142
+ _(!0), o(null);
143
+ try {
144
+ const t = new URLSearchParams();
145
+ t.set("limit", String(c)), t.set("offset", String(a)), g !== "all" && t.set("status", g);
146
+ const i = await y(`/admin/returns?${t.toString()}`);
147
+ r(i.returns ?? []);
148
+ } catch {
149
+ o("Failed to load returns"), r([]);
150
+ } finally {
151
+ _(!1);
152
+ }
153
+ }, [y, c, a, g]);
154
+ D(() => {
155
+ w();
156
+ }, [w]);
157
+ const j = async (t) => {
158
+ I(!0), o(null);
159
+ try {
160
+ const i = await y(`/admin/returns/${encodeURIComponent(t)}`);
161
+ N(i);
162
+ } catch {
163
+ o("Failed to load return details");
164
+ } finally {
165
+ I(!1);
166
+ }
167
+ }, B = (t) => {
168
+ N(t), r((i) => i.map((f) => f.id === t.id ? t : f));
169
+ };
170
+ return x ? /* @__PURE__ */ e(
171
+ q,
172
+ {
173
+ returnRequest: x,
174
+ onBack: () => N(null),
175
+ onStatusUpdated: B,
176
+ onError: o,
177
+ fetchWithAuth: y
178
+ }
179
+ ) : /* @__PURE__ */ n("div", { children: [
180
+ /* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Returns" }) }),
181
+ /* @__PURE__ */ e(O, { message: p }),
182
+ /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: [
183
+ /* @__PURE__ */ n(
184
+ "select",
185
+ {
186
+ className: "cedros-admin__input",
187
+ value: g,
188
+ onChange: (t) => {
189
+ A(t.target.value), h(0);
190
+ },
191
+ style: { width: "auto", fontSize: "0.85rem" },
192
+ children: [
193
+ /* @__PURE__ */ e("option", { value: "all", children: "All statuses" }),
194
+ C.map((t) => /* @__PURE__ */ e("option", { value: t, children: t.charAt(0).toUpperCase() + t.slice(1) }, t))
195
+ ]
196
+ }
197
+ ),
198
+ /* @__PURE__ */ n("span", { style: { fontSize: "0.85rem", color: "var(--cedros-admin-text-muted, #888)" }, children: [
199
+ s.length,
200
+ " result",
201
+ s.length !== 1 ? "s" : ""
202
+ ] })
203
+ ] }),
204
+ v || k ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
205
+ $.loading,
206
+ " Loading returns..."
207
+ ] }) : s.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No returns found." }) : /* @__PURE__ */ n(U, { children: [
208
+ /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
209
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
210
+ /* @__PURE__ */ e("th", { children: "Order ID" }),
211
+ /* @__PURE__ */ e("th", { children: "Items" }),
212
+ /* @__PURE__ */ e("th", { children: "Status" }),
213
+ /* @__PURE__ */ e("th", { children: "Reason" }),
214
+ /* @__PURE__ */ e("th", { children: "Created" }),
215
+ /* @__PURE__ */ e("th", {})
216
+ ] }) }),
217
+ /* @__PURE__ */ e("tbody", { children: s.map((t) => /* @__PURE__ */ n("tr", { children: [
218
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { style: { fontSize: "0.75rem" }, children: t.orderId }) }),
219
+ /* @__PURE__ */ e("td", { children: t.items.length }),
220
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${W(t.status)}`, children: t.status }) }),
221
+ /* @__PURE__ */ e("td", { style: { maxWidth: "180px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: t.reason ?? /* @__PURE__ */ e("span", { style: { color: "var(--cedros-admin-text-muted, #888)" }, children: "—" }) }),
222
+ /* @__PURE__ */ e("td", { children: b(t.createdAt) }),
223
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
224
+ "button",
225
+ {
226
+ type: "button",
227
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
228
+ onClick: () => j(t.id),
229
+ children: "View"
230
+ }
231
+ ) })
232
+ ] }, t.id)) })
233
+ ] }) }),
234
+ /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "0.75rem", fontSize: "0.85rem" }, children: [
235
+ /* @__PURE__ */ e(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
240
+ disabled: a === 0,
241
+ onClick: () => h(Math.max(0, a - c)),
242
+ children: "Previous"
243
+ }
244
+ ),
245
+ /* @__PURE__ */ n("span", { children: [
246
+ "Showing ",
247
+ s.length,
248
+ " return",
249
+ s.length !== 1 ? "s" : ""
250
+ ] }),
251
+ /* @__PURE__ */ e(
252
+ "button",
253
+ {
254
+ type: "button",
255
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
256
+ disabled: s.length < c,
257
+ onClick: () => h(a + c),
258
+ children: "Next"
259
+ }
260
+ )
261
+ ] })
262
+ ] })
263
+ ] });
264
+ }
265
+ export {
266
+ T as ReturnsSection
267
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),h=require("./index-C0g-JxJk.js"),w=["requested","approved","rejected","received","refunded"],I=s=>{switch(s){case"approved":return"success";case"refunded":return"success";case"rejected":return"failed";case"received":return"muted";case"requested":return"pending";default:return"muted"}};function A({returnRequest:s,onBack:u,onStatusUpdated:l,onError:m,fetchWithAuth:a}){const[r,p]=d.useState(s.status),[x,_]=d.useState(!1),c=async()=>{if(!(!r||r===s.status)){_(!0);try{const n=await a(`/admin/returns/${encodeURIComponent(s.id)}/status`,{method:"PUT",body:JSON.stringify({status:r})});l(n)}catch{m("Failed to update return status")}finally{_(!1)}}};return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:u,style:{marginBottom:"1rem"},children:"← Back to returns"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Return ",e.jsx("code",{style:{fontSize:"0.8rem"},children:s.id.slice(0,12)}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(s.status)}`,style:{marginLeft:"0.5rem"},children:s.status})]})}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px",marginBottom:"1rem"},children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"35%"},children:"Order ID"}),e.jsx("td",{children:e.jsx("code",{children:s.orderId})})]}),s.reason&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Reason"}),e.jsx("td",{children:s.reason})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Created"}),e.jsx("td",{children:h.formatDateTime(s.createdAt)})]}),s.statusUpdatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Status Updated"}),e.jsx("td",{children:h.formatDateTime(s.statusUpdatedAt)})]}),s.updatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Last Updated"}),e.jsx("td",{children:h.formatDateTime(s.updatedAt)})]})]})})}),e.jsxs("h4",{style:{fontSize:"0.85rem",fontWeight:600,margin:"0 0 0.5rem"},children:["Items (",s.items.length,")"]}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px",marginBottom:"1.25rem"},children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Product ID"}),e.jsx("th",{children:"Variant ID"}),e.jsx("th",{children:"Qty"})]})}),e.jsx("tbody",{children:s.items.map((n,o)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{style:{fontSize:"0.75rem"},children:n.productId})}),e.jsx("td",{children:n.variantId?e.jsx("code",{style:{fontSize:"0.75rem"},children:n.variantId}):e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:n.quantity})]},o))})]})}),Object.keys(s.metadata).length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{style:{fontSize:"0.85rem",fontWeight:600,margin:"0 0 0.5rem"},children:"Metadata"}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px",marginBottom:"1.25rem"},children:e.jsx("table",{className:"cedros-admin__table",children:e.jsx("tbody",{children:Object.entries(s.metadata).map(([n,o])=>e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"40%"},children:n}),e.jsx("td",{children:o})]},n))})})})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",maxWidth:"400px"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Update Status"}),e.jsx("select",{className:"cedros-admin__input",value:r,onChange:n=>p(n.target.value),children:w.map(n=>e.jsx("option",{value:n,children:n},n))})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:c,disabled:x||r===s.status,children:x?"Updating...":"Update"})]})]})}function D({serverUrl:s,apiKey:u,pageSize:l=20,authManager:m}){const[a,r]=d.useState([]),[p,x]=d.useState(!0),[_,c]=d.useState(null),[n,o]=d.useState(0),[f,R]=d.useState("all"),[S,y]=d.useState(null),[C,v]=d.useState(!1),g=d.useCallback(async(t,i)=>{if(m?.isAuthenticated())return m.fetchWithAuth(t,i);const j={"Content-Type":"application/json"};u&&(j["X-API-Key"]=u);const b=await fetch(`${s}${t}`,{...i,headers:{...j,...i?.headers}});if(!b.ok)throw new Error(`Request failed: ${b.status}`);return b.json()},[s,u,m]),N=d.useCallback(async()=>{x(!0),c(null);try{const t=new URLSearchParams;t.set("limit",String(l)),t.set("offset",String(n)),f!=="all"&&t.set("status",f);const i=await g(`/admin/returns?${t.toString()}`);r(i.returns??[])}catch{c("Failed to load returns"),r([])}finally{x(!1)}},[g,l,n,f]);d.useEffect(()=>{N()},[N]);const U=async t=>{v(!0),c(null);try{const i=await g(`/admin/returns/${encodeURIComponent(t)}`);y(i)}catch{c("Failed to load return details")}finally{v(!1)}},W=t=>{y(t),r(i=>i.map(j=>j.id===t.id?t:j))};return S?e.jsx(A,{returnRequest:S,onBack:()=>y(null),onStatusUpdated:W,onError:c,fetchWithAuth:g}):e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Returns"})}),e.jsx(h.ErrorBanner,{message:_}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:f,onChange:t=>{R(t.target.value),o(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),w.map(t=>e.jsx("option",{value:t,children:t.charAt(0).toUpperCase()+t.slice(1)},t))]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[a.length," result",a.length!==1?"s":""]})]}),p||C?e.jsxs("div",{className:"cedros-admin__loading",children:[h.Icons.loading," Loading returns..."]}):a.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No returns 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:"Order ID"}),e.jsx("th",{children:"Items"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{style:{fontSize:"0.75rem"},children:t.orderId})}),e.jsx("td",{children:t.items.length}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})}),e.jsx("td",{style:{maxWidth:"180px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.reason??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:h.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>U(t.id),children:"View"})})]},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:n===0,onClick:()=>o(Math.max(0,n-l)),children:"Previous"}),e.jsxs("span",{children:["Showing ",a.length," return",a.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:a.length<l,onClick:()=>o(n+l),children:"Next"})]})]})]})}exports.ReturnsSection=D;
@@ -1,7 +1,7 @@
1
- import { jsxs as n, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as s, jsx as i } from "react/jsx-runtime";
2
2
  import { useState as g } from "react";
3
- import { S as l } from "./SingleCategorySettings--LK0TZW0.mjs";
4
- const s = [
3
+ import { S as l } from "./SingleCategorySettings-suJ8z9d8.mjs";
4
+ const o = [
5
5
  {
6
6
  id: "logging",
7
7
  label: "Logging",
@@ -19,16 +19,22 @@ const s = [
19
19
  label: "Security",
20
20
  category: "security",
21
21
  description: "Configure CORS, rate limiting, and other security settings."
22
+ },
23
+ {
24
+ id: "storage",
25
+ label: "Storage",
26
+ category: "storage",
27
+ description: "Configure S3-compatible storage for product images."
22
28
  }
23
29
  ];
24
- function u({ serverUrl: c, apiKey: o, authManager: a }) {
25
- const [r, d] = g("logging"), t = s.find((e) => e.id === r);
26
- return /* @__PURE__ */ n("div", { className: "cedros-admin__server-settings", children: [
27
- /* @__PURE__ */ n("div", { className: "cedros-admin__page-header", children: [
30
+ function _({ serverUrl: n, apiKey: a, authManager: c }) {
31
+ const [r, d] = g("logging"), t = o.find((e) => e.id === r);
32
+ return /* @__PURE__ */ s("div", { className: "cedros-admin__server-settings", children: [
33
+ /* @__PURE__ */ s("div", { className: "cedros-admin__page-header", children: [
28
34
  /* @__PURE__ */ i("h2", { className: "cedros-admin__page-title", children: "Store Server" }),
29
- /* @__PURE__ */ i("p", { className: "cedros-admin__page-description", children: "Configure logging, metrics, and security settings." })
35
+ /* @__PURE__ */ i("p", { className: "cedros-admin__page-description", children: "Configure logging, metrics, security, and storage settings." })
30
36
  ] }),
31
- /* @__PURE__ */ i("div", { className: "cedros-admin__tabs cedros-admin__tabs--line", children: s.map((e) => /* @__PURE__ */ i(
37
+ /* @__PURE__ */ i("div", { className: "cedros-admin__tabs cedros-admin__tabs--line", children: o.map((e) => /* @__PURE__ */ i(
32
38
  "button",
33
39
  {
34
40
  type: "button",
@@ -41,9 +47,9 @@ function u({ serverUrl: c, apiKey: o, authManager: a }) {
41
47
  /* @__PURE__ */ i("div", { style: { marginTop: "1rem" }, children: /* @__PURE__ */ i(
42
48
  l,
43
49
  {
44
- serverUrl: c,
45
- apiKey: o,
46
- authManager: a,
50
+ serverUrl: n,
51
+ apiKey: a,
52
+ authManager: c,
47
53
  category: t.category,
48
54
  title: `${t.label} Settings`,
49
55
  description: t.description
@@ -53,5 +59,5 @@ function u({ serverUrl: c, apiKey: o, authManager: a }) {
53
59
  ] });
54
60
  }
55
61
  export {
56
- u as SettingsSection
62
+ _ as SettingsSection
57
63
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),d=require("./SingleCategorySettings-DwCnBdRf.js"),r=[{id:"logging",label:"Logging",category:"logging",description:"Configure log levels, format, and environment settings."},{id:"metrics",label:"Metrics",category:"metrics",description:"Configure metrics collection and API access for monitoring."},{id:"security",label:"Security",category:"security",description:"Configure CORS, rate limiting, and other security settings."},{id:"storage",label:"Storage",category:"storage",description:"Configure S3-compatible storage for product images."}];function l({serverUrl:n,apiKey:o,authManager:c}){const[s,a]=g.useState("logging"),t=r.find(i=>i.id===s);return e.jsxs("div",{className:"cedros-admin__server-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Server"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure logging, metrics, security, and storage settings."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:r.map(i=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${s===i.id?"cedros-admin__tab--active":""}`,onClick:()=>a(i.id),children:i.label},i.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(d.SingleCategorySettings,{serverUrl:n,apiKey:o,authManager:c,category:t.category,title:`${t.label} Settings`,description:t.description},t.category)})]})}exports.SettingsSection=l;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),c=require("./index-C0g-JxJk.js"),z={name:"",description:"",countries:"",active:!0},W={name:"",rateType:"flat",amountAtomic:"",currency:"USD",minSubtotal:"",maxSubtotal:"",active:!0},A=(_,h)=>`${h.toUpperCase()} ${(_/100).toFixed(2)}`;function Z({serverUrl:_,apiKey:h,authManager:S}){const[R,E]=a.useState([]),[q,P]=a.useState(!0),[w,p]=a.useState(null),[I,d]=a.useState(null),[J,f]=a.useState(!1),[b,g]=a.useState(null),[o,m]=a.useState(z),[k,T]=a.useState(!1),[n,F]=a.useState(null),[D,U]=a.useState([]),[M,$]=a.useState(!1),[G,u]=a.useState(!1),[y,x]=a.useState(null),[i,r]=a.useState(W),[L,B]=a.useState(!1),l=a.useCallback(async(t,s)=>{if(S?.isAuthenticated())return S.fetchWithAuth(t,s);const v={"Content-Type":"application/json"};h&&(v["X-API-Key"]=h);const C=await fetch(`${_}${t}`,{...s,headers:{...v,...s?.headers}});if(!C.ok)throw new Error(`Request failed: ${C.status}`);return C.json()},[_,h,S]),j=a.useCallback(async()=>{P(!0),p(null);try{const t=await l("/admin/shipping/profiles?limit=50&offset=0");E(t.profiles??[])}catch{p("Failed to load shipping profiles"),E([])}finally{P(!1)}},[l]);a.useEffect(()=>{j()},[j]);const K=t=>{g(t),m({name:t.name,description:t.description??"",countries:t.countries.join(", "),active:t.active}),f(!0)},X=async t=>{t.preventDefault(),T(!0),d(null);try{const s={name:o.name,description:o.description||void 0,countries:o.countries.split(",").map(v=>v.trim()).filter(Boolean),active:o.active};b?await l(`/admin/shipping/profiles/${encodeURIComponent(b.id)}`,{method:"PUT",body:JSON.stringify(s)}):await l("/admin/shipping/profiles",{method:"POST",body:JSON.stringify(s)}),f(!1),g(null),j()}catch(s){d(s instanceof Error?s.message:"Failed to save profile")}finally{T(!1)}},H=async t=>{if(window.confirm("Delete this shipping profile?")){d(null);try{await l(`/admin/shipping/profiles/${encodeURIComponent(t)}`,{method:"DELETE"}),j()}catch{d("Failed to delete profile")}}},N=a.useCallback(async t=>{$(!0),p(null);try{const s=await l(`/admin/shipping/profiles/${encodeURIComponent(t.id)}/rates?limit=50&offset=0`);U(s.rates??[])}catch{p("Failed to load rates"),U([])}finally{$(!1)}},[l]),O=t=>{F(t),u(!1),x(null),N(t)},Q=t=>{x(t),r({name:t.name,rateType:t.rateType,amountAtomic:String(t.amountAtomic),currency:t.currency,minSubtotal:t.minSubtotal!=null?String(t.minSubtotal):"",maxSubtotal:t.maxSubtotal!=null?String(t.maxSubtotal):"",active:t.active}),u(!0)},V=async t=>{if(t.preventDefault(),!!n){B(!0),d(null);try{const s={name:i.name,rateType:i.rateType,amountAtomic:parseInt(i.amountAtomic,10),currency:i.currency,active:i.active,profileId:n.id,minSubtotal:i.minSubtotal?parseInt(i.minSubtotal,10):void 0,maxSubtotal:i.maxSubtotal?parseInt(i.maxSubtotal,10):void 0};y?await l(`/admin/shipping/rates/${encodeURIComponent(y.id)}`,{method:"PUT",body:JSON.stringify(s)}):await l(`/admin/shipping/profiles/${encodeURIComponent(n.id)}/rates`,{method:"POST",body:JSON.stringify(s)}),u(!1),x(null),N(n)}catch(s){d(s instanceof Error?s.message:"Failed to save rate")}finally{B(!1)}}},Y=async t=>{if(!(!window.confirm("Delete this rate?")||!n)){d(null);try{await l(`/admin/shipping/rates/${encodeURIComponent(t)}`,{method:"DELETE"}),N(n)}catch{d("Failed to delete rate")}}};return n?e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>{F(null),u(!1),p(null),d(null)},style:{marginBottom:"1rem"},children:"← Back to profiles"}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[n.name,e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${n.active?"success":"muted"}`,style:{marginLeft:"0.5rem"},children:n.active?"Active":"Inactive"})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{x(null),r(W),u(!0)},children:"+ Add Rate"})]}),e.jsx(c.ErrorBanner,{message:w}),e.jsx(c.ErrorBanner,{message:I}),e.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",margin:"0 0 1rem"},children:[n.description&&e.jsxs(e.Fragment,{children:[n.description," · "]}),"Countries: ",n.countries.length>0?n.countries.join(", "):"All"]}),G&&e.jsxs("form",{onSubmit:V,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"520px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:y?"Edit Rate":"New Rate"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",required:!0,value:i.name,onChange:t=>r(s=>({...s,name:t.target.value})),placeholder:"Standard Shipping"})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Rate Type *"}),e.jsxs("select",{className:"cedros-admin__input",value:i.rateType,onChange:t=>r(s=>({...s,rateType:t.target.value})),children:[e.jsx("option",{value:"flat",children:"Flat"}),e.jsx("option",{value:"price",children:"Price-based"}),e.jsx("option",{value:"weight",children:"Weight-based"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Amount (atomic) *"}),e.jsx("input",{type:"number",className:"cedros-admin__input",required:!0,min:0,value:i.amountAtomic,onChange:t=>r(s=>({...s,amountAtomic:t.target.value})),placeholder:"500"})]}),e.jsxs("div",{className:"cedros-admin__field",style:{width:"80px"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.currency,maxLength:3,onChange:t=>r(s=>({...s,currency:t.target.value.toUpperCase()})),placeholder:"USD"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Min Subtotal"}),e.jsx("input",{type:"number",className:"cedros-admin__input",min:0,value:i.minSubtotal,onChange:t=>r(s=>({...s,minSubtotal:t.target.value})),placeholder:"0"})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Subtotal"}),e.jsx("input",{type:"number",className:"cedros-admin__input",min:0,value:i.maxSubtotal,onChange:t=>r(s=>({...s,maxSubtotal:t.target.value})),placeholder:"10000"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"rate-active",checked:i.active,onChange:t=>r(s=>({...s,active:t.target.checked}))}),e.jsx("label",{htmlFor:"rate-active",className:"cedros-admin__field-label",style:{margin:0},children:"Active"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:L,children:L?"Saving...":y?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>{u(!1),x(null)},children:"Cancel"})]})]}),M?e.jsxs("div",{className:"cedros-admin__loading",children:[c.Icons.loading," Loading rates..."]}):D.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No rates yet. Add one above."}):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:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Min / Max Subtotal"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:D.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.rateType}),e.jsx("td",{style:{fontSize:"0.85rem"},children:A(t.amountAtomic,t.currency)}),e.jsxs("td",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)"},children:[t.minSubtotal!=null?A(t.minSubtotal,t.currency):"—"," / ",t.maxSubtotal!=null?A(t.maxSubtotal,t.currency):"—"]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:c.formatDateTime(t.updatedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>Q(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>Y(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Shipping"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{g(null),m(z),f(!0)},children:"+ Add Profile"})]}),e.jsx(c.ErrorBanner,{message:w}),e.jsx(c.ErrorBanner,{message:I}),J&&e.jsxs("form",{onSubmit:X,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:b?"Edit Profile":"New Profile"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",required:!0,value:o.name,onChange:t=>m(s=>({...s,name:t.target.value})),placeholder:"Domestic Shipping"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:o.description,onChange:t=>m(s=>({...s,description:t.target.value})),placeholder:"Optional description"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Countries (comma-separated ISO codes)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:o.countries,onChange:t=>m(s=>({...s,countries:t.target.value})),placeholder:"US, CA, GB"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"profile-active",checked:o.active,onChange:t=>m(s=>({...s,active:t.target.checked}))}),e.jsx("label",{htmlFor:"profile-active",className:"cedros-admin__field-label",style:{margin:0},children:"Active"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:k,children:k?"Saving...":b?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>{f(!1),g(null)},children:"Cancel"})]})]}),q?e.jsxs("div",{className:"cedros-admin__loading",children:[c.Icons.loading," Loading profiles..."]}):R.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No shipping profiles found."}):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:"Name"}),e.jsx("th",{children:"Countries"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:R.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",fontWeight:600,padding:0,color:"var(--cedros-admin-text, #333)",fontSize:"0.9rem"},onClick:()=>O(t),children:t.name})}),e.jsx("td",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.countries.length>0?t.countries.join(", "):"All"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:c.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>O(t),children:"Rates"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>K(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>H(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]})}exports.ShippingSection=Z;