@cedros/pay-react 1.1.25 → 1.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-Dg1kazTI.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
- package/dist/{AISettingsSection-BvSSiK2G.js → AISettingsSection-DELur7D2.js} +1 -1
- package/dist/{AutosaveIndicator-BHfkV59p.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
- package/dist/{AutosaveIndicator-D2l7U8R1.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
- package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
- package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
- package/dist/{ComplianceSection-BSE2f3Wo.mjs → ComplianceSection-CemgfDrL.mjs} +282 -166
- package/dist/ComplianceSection-DP2a9-S0.js +1 -0
- package/dist/CustomersSection-CBwy_waO.js +1 -0
- package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
- package/dist/DisputesSection-BLjIk60n.js +1 -0
- package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
- package/dist/{FAQSection-uZG5V3pJ.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
- package/dist/{FAQSection-6nGI0FK9.js → FAQSection-wNeH0i6Q.js} +1 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
- package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
- package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
- package/dist/InventorySection-zV6lTmue.js +1 -0
- package/dist/{MessagingSection-M0lj5yo4.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
- package/dist/{MessagingSection-DrXb578q.js → MessagingSection-B_wdFR0j.js} +1 -1
- package/dist/{OrdersSection-DteItv_O.mjs → OrdersSection-Bj8bPdg8.mjs} +1 -1
- package/dist/{OrdersSection-_-rIw6XW.js → OrdersSection-Dw2FX-1d.js} +1 -1
- package/dist/{PaymentSettingsSection-enTbUI95.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
- package/dist/{PaymentSettingsSection-CdtdLFTg.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
- package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
- package/dist/ReturnsSection-D_pJVxuG.js +1 -0
- package/dist/{SettingsSection-mcT4LEhO.mjs → SettingsSection-KYdEizq_.mjs} +1 -1
- package/dist/{SettingsSection-DUTEd6uV.js → SettingsSection-vdYFSNxB.js} +1 -1
- package/dist/ShippingSection-1DRSTu49.js +1 -0
- package/dist/ShippingSection-BOgto6_9.mjs +434 -0
- package/dist/{SingleCategorySettings-D2LVM5mn.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
- package/dist/{SingleCategorySettings-BvHBVfSe.mjs → SingleCategorySettings-suJ8z9d8.mjs} +2 -2
- package/dist/{StorefrontSection-BqQ36JIS.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
- package/dist/{StorefrontSection-Du7hV2Gc.js → StorefrontSection-RumGkb3C.js} +1 -1
- package/dist/{SubscriptionsSection-C4BRN1dP.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
- package/dist/{SubscriptionsSection-BYiCBwKZ.mjs → SubscriptionsSection-D60qrX9a.mjs} +1 -1
- package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
- package/dist/TaxSection-Dt1DnM51.js +1 -0
- package/dist/{Token22Section-BHvOhz5d.mjs → Token22Section-CrHLQ0EB.mjs} +1 -1
- package/dist/{Token22Section-0c22NM5G.js → Token22Section-DY3mUwTY.js} +1 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
- package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +1 -1
- package/dist/index-C0g-JxJk.js +84 -0
- package/dist/{index-BkDimQDF.mjs → index-DXnuQp5x.mjs} +7068 -6768
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{sections-By4H1baL.mjs → sections-C1NpK7hk.mjs} +2 -2
- package/dist/{sections-5jO2aHAo.js → sections-DVVSZBhW.js} +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +3 -1
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
- package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -1
- package/dist/src/components/admin/CustomersSection.d.ts +3 -0
- package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
- package/dist/src/components/admin/DisputesSection.d.ts +3 -0
- package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
- package/dist/src/components/admin/ImagesSection.d.ts +3 -0
- package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
- package/dist/src/components/admin/InventorySection.d.ts +3 -0
- package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
- package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
- package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
- package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
- package/dist/src/components/admin/ShippingSection.d.ts +3 -0
- package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
- package/dist/src/components/admin/TaxSection.d.ts +3 -0
- package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
- package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
- package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
- package/dist/src/components/admin/complianceTypes.d.ts +15 -1
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +2 -2
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/ComplianceSection-D6ETKG6b.js +0 -1
- package/dist/index-C7MWL6O8.js +0 -84
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),m=require("./index-C0g-JxJk.js"),y=require("./CedrosContext-C2RjHLaQ.js"),_=a=>a.length>12?`${a.slice(0,6)}...${a.slice(-4)}`:a,ie=a=>{switch(a){case"active":return"success";case"frozen":return"failed";case"thawed":return"pending";default:return"muted"}},G=a=>{switch(a){case"freeze":return"failed";case"thaw":return"success";case"sweep_freeze":return"failed";case"report_generated":return"muted";default:return"muted"}},re=a=>{switch(a){case"verified":return"success";case"pending":return"pending";case"expired":return"failed";case"none":default:return"muted"}},ce="https://explorer.solana.com/tx/",de={apiUrl:"",refreshIntervalSecs:3600,enabled:!1};function oe({serverUrl:a,apiKey:h,authManager:u}){const[r,o]=n.useState(de),[b,A]=n.useState(!0),[x,p]=n.useState(!1),[i,N]=n.useState(!1),[C,f]=n.useState(null),[k,j]=n.useState(null),S=n.useCallback(async(s,l)=>{if(u?.isAuthenticated())return u.fetchWithAuth(s,l);const v={"Content-Type":"application/json"};h&&(v["X-API-Key"]=h);const z=await fetch(`${a}${s}`,{...l,headers:{...v,...l?.headers}});if(!z.ok)throw new Error(`Request failed: ${z.status}`);return z.json()},[a,h,u]);n.useEffect(()=>{(async()=>{try{const s=await S("/admin/compliance/sanctions-api");o(s)}catch(s){y.getLogger().error("[ComplianceSanctionsApi] Failed to fetch settings:",s)}finally{A(!1)}})()},[S]);const T=async()=>{p(!0),f(null),j(null);try{await S("/admin/compliance/sanctions-api",{method:"PUT",body:JSON.stringify(r)}),j("Settings saved")}catch(s){y.getLogger().error("[ComplianceSanctionsApi] Save failed:",s),f("Failed to save settings")}finally{p(!1)}},d=async()=>{N(!0),f(null),j(null);try{await S("/admin/compliance/sanctions-api/refresh",{method:"POST"}),j("Sanctions list refreshed")}catch(s){y.getLogger().error("[ComplianceSanctionsApi] Refresh failed:",s),f("Failed to refresh sanctions list")}finally{N(!1)}};return b?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading sanctions API settings..."]}):e.jsxs("div",{style:{maxWidth:"500px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Dynamic Sanctions API"})}),C&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem"},children:C}),k&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--success",style:{padding:"0.5rem"},children:k}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:s=>o(l=>({...l,enabled:s.target.checked}))}),"Enable dynamic sanctions list"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["API URL",e.jsx("input",{type:"url",className:"cedros-admin__input",placeholder:"https://sunscreen.cedros.io",value:r.apiUrl,onChange:s=>o(l=>({...l,apiUrl:s.target.value}))})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Refresh interval (seconds, min 60)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:60,value:r.refreshIntervalSecs,onChange:s=>o(l=>({...l,refreshIntervalSecs:Number(s.target.value)})),style:{width:"160px"}})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:T,disabled:x,children:x?"Saving...":"Save Settings"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:d,disabled:i||!r.enabled||!r.apiUrl,children:i?"Refreshing...":"Force Refresh"})]})]})}function le({serverUrl:a,apiKey:h,authManager:u}){const[r,o]=n.useState(""),[b,A]=n.useState(!1),[x,p]=n.useState(null),[i,N]=n.useState(null),[C,f]=n.useState(!1),k=n.useCallback(async(d,s)=>{if(u?.isAuthenticated())return u.fetchWithAuth(d,s);const l={"Content-Type":"application/json"};h&&(l["X-API-Key"]=h);const v=await fetch(`${a}${d}`,{...s,headers:{...l,...s?.headers}});if(!v.ok)throw new Error(`Request failed: ${v.status}`);return v.json()},[a,h,u]),j=async()=>{const d=r.trim();if(d){A(!0),p(null),N(null),f(!0);try{const s=await k(`/admin/compliance/user-status/${encodeURIComponent(d)}`);N(s)}catch(s){y.getLogger().error("[ComplianceKycTab] Lookup failed:",s),p("Failed to fetch user compliance status. Ensure cedros-login is configured.")}finally{A(!1)}}},S=d=>{d.key==="Enter"&&j()},T=d=>{switch(d){case"verified":return"Verified";case"pending":return"Pending";case"expired":return"Expired";case"none":default:return"Not Started"}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"KYC & Accredited Investor Status"})}),e.jsx("p",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)",marginBottom:"1rem"},children:"Look up a user's KYC verification and accredited investor status from cedros-login."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsxs("label",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["User ID",e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"user_abc123",value:r,onChange:d=>o(d.target.value),onKeyDown:S})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:j,disabled:b||!r.trim(),children:b?"Looking up...":"Look Up"})]}),x&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem",marginBottom:"1rem"},children:x}),b&&e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Fetching compliance status..."]}),i&&!b&&e.jsxs("div",{style:{maxWidth:"500px"},children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"40%"},children:"User ID"}),e.jsx("td",{children:e.jsx("code",{children:i.userId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"KYC Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${re(i.kycStatus)}`,children:T(i.kycStatus)})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Investor"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${i.accreditedInvestor?"success":"muted"}`,children:i.accreditedInvestor?"Yes":"No"})})]}),i.accreditedVerifiedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Since"}),e.jsx("td",{children:m.formatDateTime(i.accreditedVerifiedAt)})]})]})})}),e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem",borderRadius:"4px",fontSize:"0.85rem",background:i.kycStatus==="verified"?"var(--cedros-admin-bg-success, #f0fdf4)":"var(--cedros-admin-bg-muted, #f5f5f5)",color:"var(--cedros-admin-text, #333)"},children:i.kycStatus==="verified"&&i.accreditedInvestor?"This user is fully verified and accredited. They can access all compliance-gated products.":i.kycStatus==="verified"?"This user has KYC verification but is not an accredited investor.":i.kycStatus==="pending"?"This user has submitted KYC documents. Verification is in progress.":i.kycStatus==="expired"?"This user's KYC verification has expired. They will need to re-verify.":"This user has not started KYC verification."})]}),C&&!i&&!b&&!x&&e.jsx("div",{className:"cedros-admin__empty",children:"No compliance record found for this user."})]})}function me({serverUrl:a,apiKey:h,pageSize:u=50,authManager:r}){const[o,b]=n.useState("holders"),[A,x]=n.useState(null),[p,i]=n.useState([]),[N,C]=n.useState(!0),[f,k]=n.useState(""),[j,S]=n.useState([]),[T,d]=n.useState(!0),[s,l]=n.useState(null),[v,z]=n.useState(!1),[P,V]=n.useState(""),[W,X]=n.useState(""),[B,O]=n.useState({enabled:!0,batchSize:100}),[M,Q]=n.useState(!0),[H,Y]=n.useState(!1),[g,L]=n.useState(null),[R,$]=n.useState(""),[F,q]=n.useState(!1),w=n.useCallback(async(t,c)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,c);const I={"Content-Type":"application/json"};h&&(I["X-API-Key"]=h);const U=await fetch(`${a}${t}`,{...c,headers:{...I,...c?.headers}});if(!U.ok)throw new Error(`Request failed: ${U.status}`);return U.json()},[a,h,r]),D=n.useCallback(async()=>{try{const t=f?`&status=${f}`:"",c=await w(`/admin/compliance/holders?limit=${u}&offset=0${t}`);i(c.holders||[])}catch(t){y.getLogger().error("[ComplianceSection] Failed to fetch holders:",t),i([]),x("Failed to load token holders")}finally{C(!1)}},[w,u,f]),E=n.useCallback(async()=>{try{const t=await w(`/admin/compliance/actions?limit=${u}&offset=0`);S(t.actions||[])}catch(t){y.getLogger().error("[ComplianceSection] Failed to fetch actions:",t),S([]),x("Failed to load compliance actions")}finally{d(!1)}},[w,u]),K=n.useCallback(async()=>{try{const t=await w("/admin/compliance/sweep-settings");O(t)}catch(t){y.getLogger().error("[ComplianceSection] Failed to fetch sweep settings:",t)}finally{Q(!1)}},[w]),Z=async()=>{Y(!0);try{await w("/admin/compliance/sweep-settings",{method:"PUT",body:JSON.stringify(B)})}catch(t){y.getLogger().error("[ComplianceSection] Failed to save sweep settings:",t),x("Failed to save sweep settings")}finally{Y(!1)}};n.useEffect(()=>{D()},[D]),n.useEffect(()=>{E()},[E]),n.useEffect(()=>{K()},[K]);const ee=async()=>{if(!(!g||!R.trim())){q(!0);try{const t=g.action==="freeze"?"/admin/compliance/freeze":"/admin/compliance/thaw";await w(t,{method:"POST",body:JSON.stringify({holderId:g.holder.id,reason:R})}),L(null),$(""),await D(),await E()}catch(t){y.getLogger().error(`[ComplianceSection] ${g.action} failed:`,t),x(`Failed to ${g.action} holder`)}finally{q(!1)}}},te=async()=>{z(!0);try{const t=new URLSearchParams;P&&t.set("from",new Date(P).toISOString()),W&&t.set("to",new Date(W).toISOString());const c=await w(`/admin/compliance/report?${t.toString()}`);l(c.report)}catch(t){y.getLogger().error("[ComplianceSection] Failed to generate report:",t),x("Failed to generate compliance report")}finally{z(!1)}},se=()=>{if(!s)return;const t=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),c=URL.createObjectURL(t),I=document.createElement("a");I.href=c,I.download=`compliance-report-${new Date().toISOString().slice(0,10)}.json`,I.click(),URL.revokeObjectURL(c)},ne=p.length,J=p.filter(t=>t.status==="frozen").length,ae=p.filter(t=>t.status==="active").length;return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(m.ErrorBanner,{message:A,onRetry:()=>{D(),E()}}),e.jsx(m.StatsBar,{stats:[{label:"Total Holders",value:ne},{label:"Active",value:ae,variant:"success"},{label:"Frozen",value:J,variant:J>0?"warning":"muted"},{label:"Actions Logged",value:j.length}],isLoading:N||T}),e.jsx("div",{className:"cedros-admin__tabs",style:{display:"flex",gap:"0.5rem",marginBottom:"1rem"},children:["holders","actions","reports","sweep-settings","sanctions-api","kyc"].map(t=>{const c=t==="holders"?"Token Holders":t==="actions"?"Actions Log":t==="reports"?"Reports":t==="sweep-settings"?"Sweep Settings":t==="sanctions-api"?"Sanctions API":"KYC & Accreditation";return e.jsx("button",{type:"button",className:`cedros-admin__button ${o===t?"cedros-admin__button--primary":"cedros-admin__button--ghost"}`,onClick:()=>b(t),children:c},t)})}),o==="holders"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__section-header",style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Token Holders"}),e.jsxs("select",{value:f,onChange:t=>{k(t.target.value),C(!0)},className:"cedros-admin__input",style:{width:"auto",padding:"0.25rem 0.5rem",fontSize:"0.85rem"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"frozen",children:"Frozen"}),e.jsx("option",{value:"thawed",children:"Thawed"})]})]}),N?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading holders..."]}):p.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No token holders 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:"Wallet"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"Mint"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:p.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:_(t.walletAddress)})}),e.jsx("td",{children:e.jsx("code",{title:t.collectionId,children:_(t.collectionId)})}),e.jsx("td",{children:e.jsx("code",{title:t.mintAddress,children:_(t.mintAddress)})}),e.jsx("td",{children:t.amountMinted}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${ie(t.status)}`,children:t.status})}),e.jsx("td",{children:m.formatDateTime(t.createdAt)}),e.jsx("td",{children:t.status==="active"||t.status==="thawed"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>{L({holder:t,action:"freeze"}),$("")},children:"Freeze"}):t.status==="frozen"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{L({holder:t,action:"thaw"}),$("")},children:"Thaw"}):null})]},t.id))})]})})]}),o==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Actions"})}),T?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading actions..."]}):j.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No compliance actions recorded."}):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:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"}),e.jsx("th",{children:"Tx Signature"})]})}),e.jsx("tbody",{children:j.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:m.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${G(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:_(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:_(t.actor)})}),e.jsx("td",{children:t.txSignature?e.jsx("a",{href:`${ce}${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin__link",children:_(t.txSignature)}):"—"})]},t.id))})]})})]}),o==="reports"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Report"})}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"flex-end",marginBottom:"1rem"},children:[e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["From",e.jsx("input",{type:"date",className:"cedros-admin__input",value:P,onChange:t=>V(t.target.value)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["To",e.jsx("input",{type:"date",className:"cedros-admin__input",value:W,onChange:t=>X(t.target.value)})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:te,disabled:v,children:v?"Generating...":"Generate Report"})]}),s&&e.jsxs("div",{children:[e.jsx(m.StatsBar,{stats:[{label:"Total Holders",value:s.totalHolders},{label:"Frozen",value:s.totalFrozen,variant:s.totalFrozen>0?"warning":"muted"},{label:"Freezes",value:s.freezeCount},{label:"Thaws",value:s.thawCount},{label:"Sweep Freezes",value:s.sweepFreezeCount,variant:s.sweepFreezeCount>0?"warning":"muted"}],isLoading:!1}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"1rem 0 0.5rem"},children:[e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:["Generated ",m.formatDateTime(s.generatedAt)," · ",s.actionsInPeriod," actions in period"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:se,children:"Download JSON"})]}),s.actions.length>0&&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:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:s.actions.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:m.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${G(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:_(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:_(t.actor)})})]},t.id))})]})})]})]}),o==="sweep-settings"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Sanctions Sweep Settings"})}),M?e.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading settings..."]}):e.jsxs("div",{style:{maxWidth:"400px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:B.enabled,onChange:t=>O(c=>({...c,enabled:t.target.checked}))}),"Enable automated sanctions sweep"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Batch size (1 – 10,000)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:1,max:1e4,value:B.batchSize,onChange:t=>O(c=>({...c,batchSize:Number(t.target.value)})),style:{width:"160px"}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:Z,disabled:H,style:{alignSelf:"flex-start"},children:H?"Saving...":"Save Settings"})]})]}),o==="sanctions-api"&&e.jsx(oe,{serverUrl:a,apiKey:h,authManager:r}),o==="kyc"&&e.jsx(le,{serverUrl:a,apiKey:h,authManager:r}),g&&e.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>!F&&L(null),children:e.jsxs("div",{className:"cedros-admin__modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"cedros-admin__modal-header",children:[e.jsxs("h4",{className:"cedros-admin__modal-title",children:[g.action==="freeze"?"Freeze":"Thaw"," Token Account"]}),e.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:()=>!F&&L(null),children:m.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__modal-body",children:[e.jsxs("p",{style:{marginBottom:"0.5rem",fontSize:"0.9rem"},children:["Wallet: ",e.jsx("code",{children:_(g.holder.walletAddress)})]}),e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem"},children:["Mint: ",e.jsx("code",{children:_(g.holder.mintAddress)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Reason (required)",e.jsx("textarea",{className:"cedros-admin__input",rows:3,value:R,onChange:t=>$(t.target.value),placeholder:`Reason for ${g.action}...`,maxLength:1024})]})]}),e.jsxs("div",{className:"cedros-admin__modal-footer",children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>L(null),disabled:F,children:"Cancel"}),e.jsx("button",{className:`cedros-admin__button ${g.action==="freeze"?"cedros-admin__button--danger":"cedros-admin__button--primary"}`,onClick:ee,disabled:F||!R.trim(),children:F?"Processing...":g.action==="freeze"?"Freeze Account":"Thaw Account"})]})]})})]})}exports.ComplianceSection=me;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),y=require("./index-C0g-JxJk.js");function q({serverUrl:g,apiKey:h,pageSize:i=20,authManager:x}){const[_,C]=n.useState([]),[A,N]=n.useState(!0),[F,l]=n.useState(null),[o,v]=n.useState(0),[D,p]=n.useState(!1),[S,w]=n.useState(!1),[r,E]=n.useState(null),[c,I]=n.useState(""),[a,d]=n.useState({email:"",name:"",phone:""}),m=n.useCallback(async(t,s)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,s);const k={"Content-Type":"application/json"};h&&(k["X-API-Key"]=h);const b=await fetch(`${g}${t}`,{...s,headers:{...k,...s?.headers}});if(!b.ok)throw new Error(`Request failed: ${b.status}`);return b.json()},[g,h,x]),f=n.useCallback(async()=>{N(!0),l(null);try{const t=await m(`/admin/customers?limit=${i}&offset=${o}`);C(t.customers??[])}catch{l("Failed to load customers"),C([])}finally{N(!1)}},[m,i,o]);n.useEffect(()=>{f()},[f]);const j=()=>{d({email:"",name:"",phone:""}),E(null),p(!1)},L=t=>{E(t),d({email:t.email,name:t.name??"",phone:t.phone??""}),p(!0)},P=async t=>{t.preventDefault(),w(!0),l(null);try{r?await m(`/admin/customers/${encodeURIComponent(r.id)}`,{method:"PUT",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:r.addresses})}):await m("/admin/customers",{method:"POST",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:[]})}),j(),f()}catch(s){l(s instanceof Error?s.message:"Failed to save customer")}finally{w(!1)}},u=c.trim()?_.filter(t=>{const s=c.toLowerCase();return t.email.toLowerCase().includes(s)||(t.name??"").toLowerCase().includes(s)||t.id.toLowerCase().includes(s)}):_,T=t=>[t.line1,t.city,t.state,t.postalCode,t.country].filter(Boolean).join(", ");return e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Customers"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{j(),p(!0)},children:"+ Add Customer"})]}),e.jsx(y.ErrorBanner,{message:F}),e.jsx("div",{style:{marginBottom:"1rem",maxWidth:"400px"},children:e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"Search by email, name, or ID...",value:c,onChange:t=>I(t.target.value),style:{fontSize:"0.85rem"}})}),D&&e.jsxs("form",{onSubmit:P,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:r?"Edit Customer":"New Customer"}),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:"Email *"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.email,onChange:t=>d(s=>({...s,email:t.target.value})),required:!0,placeholder:"customer@example.com"})]}),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",value:a.name,onChange:t=>d(s=>({...s,name:t.target.value})),placeholder:"Jane Doe"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Phone"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.phone,onChange:t=>d(s=>({...s,phone:t.target.value})),placeholder:"+1 555 123 4567"})]})]}),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:S,children:S?"Saving...":r?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:j,children:"Cancel"})]})]}),A?e.jsxs("div",{className:"cedros-admin__loading",children:[y.Icons.loading," Loading customers..."]}):u.length===0?e.jsx("div",{className:"cedros-admin__empty",children:c?"No matching customers.":"No customers 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:"Email"}),e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Phone"}),e.jsx("th",{children:"Address"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:u.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.email}),e.jsx("td",{children:t.name??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:t.phone??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.addresses.length>0?T(t.addresses[0]):"—"}),e.jsx("td",{children:y.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:()=>L(t),children:"Edit"})})]},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:o===0,onClick:()=>v(Math.max(0,o-i)),children:"Previous"}),e.jsxs("span",{children:["Showing ",u.length," customer",u.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:_.length<i,onClick:()=>v(o+i),children:"Next"})]})]})]})}exports.CustomersSection=q;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as o, useCallback as F, useEffect as O } from "react";
|
|
3
|
+
import { E as B, I as q, k as J } from "./index-DXnuQp5x.mjs";
|
|
4
|
+
function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
5
|
+
const [f, v] = o([]), [I, x] = o(!0), [D, m] = o(null), [i, w] = o(0), [L, b] = o(!1), [S, E] = o(!1), [d, k] = o(null), [c, j] = o(""), [a, l] = o({ email: "", name: "", phone: "" }), h = F(async (e, n) => {
|
|
6
|
+
if (p?.isAuthenticated())
|
|
7
|
+
return p.fetchWithAuth(e, n);
|
|
8
|
+
const A = { "Content-Type": "application/json" };
|
|
9
|
+
_ && (A["X-API-Key"] = _);
|
|
10
|
+
const C = await fetch(`${N}${e}`, { ...n, headers: { ...A, ...n?.headers } });
|
|
11
|
+
if (!C.ok) throw new Error(`Request failed: ${C.status}`);
|
|
12
|
+
return C.json();
|
|
13
|
+
}, [N, _, p]), y = F(async () => {
|
|
14
|
+
x(!0), m(null);
|
|
15
|
+
try {
|
|
16
|
+
const e = await h(
|
|
17
|
+
`/admin/customers?limit=${r}&offset=${i}`
|
|
18
|
+
);
|
|
19
|
+
v(e.customers ?? []);
|
|
20
|
+
} catch {
|
|
21
|
+
m("Failed to load customers"), v([]);
|
|
22
|
+
} finally {
|
|
23
|
+
x(!1);
|
|
24
|
+
}
|
|
25
|
+
}, [h, r, i]);
|
|
26
|
+
O(() => {
|
|
27
|
+
y();
|
|
28
|
+
}, [y]);
|
|
29
|
+
const g = () => {
|
|
30
|
+
l({ email: "", name: "", phone: "" }), k(null), b(!1);
|
|
31
|
+
}, P = (e) => {
|
|
32
|
+
k(e), l({ email: e.email, name: e.name ?? "", phone: e.phone ?? "" }), b(!0);
|
|
33
|
+
}, T = async (e) => {
|
|
34
|
+
e.preventDefault(), E(!0), m(null);
|
|
35
|
+
try {
|
|
36
|
+
d ? await h(`/admin/customers/${encodeURIComponent(d.id)}`, {
|
|
37
|
+
method: "PUT",
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
email: a.email,
|
|
40
|
+
name: a.name || null,
|
|
41
|
+
phone: a.phone || null,
|
|
42
|
+
addresses: d.addresses
|
|
43
|
+
})
|
|
44
|
+
}) : await h("/admin/customers", {
|
|
45
|
+
method: "POST",
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
email: a.email,
|
|
48
|
+
name: a.name || null,
|
|
49
|
+
phone: a.phone || null,
|
|
50
|
+
addresses: []
|
|
51
|
+
})
|
|
52
|
+
}), g(), y();
|
|
53
|
+
} catch (n) {
|
|
54
|
+
m(n instanceof Error ? n.message : "Failed to save customer");
|
|
55
|
+
} finally {
|
|
56
|
+
E(!1);
|
|
57
|
+
}
|
|
58
|
+
}, u = c.trim() ? f.filter((e) => {
|
|
59
|
+
const n = c.toLowerCase();
|
|
60
|
+
return e.email.toLowerCase().includes(n) || (e.name ?? "").toLowerCase().includes(n) || e.id.toLowerCase().includes(n);
|
|
61
|
+
}) : f, W = (e) => [e.line1, e.city, e.state, e.postalCode, e.country].filter(Boolean).join(", ");
|
|
62
|
+
return /* @__PURE__ */ s("div", { children: [
|
|
63
|
+
/* @__PURE__ */ s("div", { className: "cedros-admin__section-header", children: [
|
|
64
|
+
/* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Customers" }),
|
|
65
|
+
/* @__PURE__ */ t(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
type: "button",
|
|
69
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
70
|
+
onClick: () => {
|
|
71
|
+
g(), b(!0);
|
|
72
|
+
},
|
|
73
|
+
children: "+ Add Customer"
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ t(B, { message: D }),
|
|
78
|
+
/* @__PURE__ */ t("div", { style: { marginBottom: "1rem", maxWidth: "400px" }, children: /* @__PURE__ */ t(
|
|
79
|
+
"input",
|
|
80
|
+
{
|
|
81
|
+
type: "text",
|
|
82
|
+
className: "cedros-admin__input",
|
|
83
|
+
placeholder: "Search by email, name, or ID...",
|
|
84
|
+
value: c,
|
|
85
|
+
onChange: (e) => j(e.target.value),
|
|
86
|
+
style: { fontSize: "0.85rem" }
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
L && /* @__PURE__ */ s("form", { onSubmit: T, style: {
|
|
90
|
+
border: "1px solid var(--cedros-admin-border, #e0e0e0)",
|
|
91
|
+
borderRadius: "4px",
|
|
92
|
+
padding: "1rem",
|
|
93
|
+
marginBottom: "1.5rem",
|
|
94
|
+
maxWidth: "500px"
|
|
95
|
+
}, children: [
|
|
96
|
+
/* @__PURE__ */ t("h4", { style: { margin: "0 0 0.75rem", fontSize: "0.9rem", fontWeight: 600 }, children: d ? "Edit Customer" : "New Customer" }),
|
|
97
|
+
/* @__PURE__ */ s("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
98
|
+
/* @__PURE__ */ s("div", { className: "cedros-admin__field", children: [
|
|
99
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Email *" }),
|
|
100
|
+
/* @__PURE__ */ t(
|
|
101
|
+
"input",
|
|
102
|
+
{
|
|
103
|
+
type: "email",
|
|
104
|
+
className: "cedros-admin__input",
|
|
105
|
+
value: a.email,
|
|
106
|
+
onChange: (e) => l((n) => ({ ...n, email: e.target.value })),
|
|
107
|
+
required: !0,
|
|
108
|
+
placeholder: "customer@example.com"
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ s("div", { className: "cedros-admin__field", children: [
|
|
113
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Name" }),
|
|
114
|
+
/* @__PURE__ */ t(
|
|
115
|
+
"input",
|
|
116
|
+
{
|
|
117
|
+
type: "text",
|
|
118
|
+
className: "cedros-admin__input",
|
|
119
|
+
value: a.name,
|
|
120
|
+
onChange: (e) => l((n) => ({ ...n, name: e.target.value })),
|
|
121
|
+
placeholder: "Jane Doe"
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ s("div", { className: "cedros-admin__field", children: [
|
|
126
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Phone" }),
|
|
127
|
+
/* @__PURE__ */ t(
|
|
128
|
+
"input",
|
|
129
|
+
{
|
|
130
|
+
type: "text",
|
|
131
|
+
className: "cedros-admin__input",
|
|
132
|
+
value: a.phone,
|
|
133
|
+
onChange: (e) => l((n) => ({ ...n, phone: e.target.value })),
|
|
134
|
+
placeholder: "+1 555 123 4567"
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ s("div", { style: { marginTop: "0.75rem", display: "flex", gap: "0.5rem" }, children: [
|
|
140
|
+
/* @__PURE__ */ t("button", { type: "submit", className: "cedros-admin__button cedros-admin__button--primary", disabled: S, children: S ? "Saving..." : d ? "Update" : "Create" }),
|
|
141
|
+
/* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button cedros-admin__button--ghost", onClick: g, children: "Cancel" })
|
|
142
|
+
] })
|
|
143
|
+
] }),
|
|
144
|
+
I ? /* @__PURE__ */ s("div", { className: "cedros-admin__loading", children: [
|
|
145
|
+
q.loading,
|
|
146
|
+
" Loading customers..."
|
|
147
|
+
] }) : u.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: c ? "No matching customers." : "No customers found." }) : /* @__PURE__ */ s($, { children: [
|
|
148
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ s("table", { className: "cedros-admin__table", children: [
|
|
149
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ s("tr", { children: [
|
|
150
|
+
/* @__PURE__ */ t("th", { children: "Email" }),
|
|
151
|
+
/* @__PURE__ */ t("th", { children: "Name" }),
|
|
152
|
+
/* @__PURE__ */ t("th", { children: "Phone" }),
|
|
153
|
+
/* @__PURE__ */ t("th", { children: "Address" }),
|
|
154
|
+
/* @__PURE__ */ t("th", { children: "Created" }),
|
|
155
|
+
/* @__PURE__ */ t("th", {})
|
|
156
|
+
] }) }),
|
|
157
|
+
/* @__PURE__ */ t("tbody", { children: u.map((e) => /* @__PURE__ */ s("tr", { children: [
|
|
158
|
+
/* @__PURE__ */ t("td", { children: e.email }),
|
|
159
|
+
/* @__PURE__ */ t("td", { children: e.name ?? /* @__PURE__ */ t("span", { style: { color: "var(--cedros-admin-text-muted, #888)" }, children: "—" }) }),
|
|
160
|
+
/* @__PURE__ */ t("td", { children: e.phone ?? /* @__PURE__ */ t("span", { style: { color: "var(--cedros-admin-text-muted, #888)" }, children: "—" }) }),
|
|
161
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "200px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: e.addresses.length > 0 ? W(e.addresses[0]) : "—" }),
|
|
162
|
+
/* @__PURE__ */ t("td", { children: J(e.createdAt) }),
|
|
163
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ t(
|
|
164
|
+
"button",
|
|
165
|
+
{
|
|
166
|
+
type: "button",
|
|
167
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
168
|
+
onClick: () => P(e),
|
|
169
|
+
children: "Edit"
|
|
170
|
+
}
|
|
171
|
+
) })
|
|
172
|
+
] }, e.id)) })
|
|
173
|
+
] }) }),
|
|
174
|
+
/* @__PURE__ */ s("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "0.75rem", fontSize: "0.85rem" }, children: [
|
|
175
|
+
/* @__PURE__ */ t(
|
|
176
|
+
"button",
|
|
177
|
+
{
|
|
178
|
+
type: "button",
|
|
179
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
180
|
+
disabled: i === 0,
|
|
181
|
+
onClick: () => w(Math.max(0, i - r)),
|
|
182
|
+
children: "Previous"
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ s("span", { children: [
|
|
186
|
+
"Showing ",
|
|
187
|
+
u.length,
|
|
188
|
+
" customer",
|
|
189
|
+
u.length !== 1 ? "s" : ""
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ t(
|
|
192
|
+
"button",
|
|
193
|
+
{
|
|
194
|
+
type: "button",
|
|
195
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
196
|
+
disabled: f.length < r,
|
|
197
|
+
onClick: () => w(i + r),
|
|
198
|
+
children: "Next"
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] })
|
|
202
|
+
] })
|
|
203
|
+
] });
|
|
204
|
+
}
|
|
205
|
+
export {
|
|
206
|
+
X as CustomersSection
|
|
207
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),l=require("./index-C0g-JxJk.js"),I=d=>{switch(d){case"won":return"success";case"lost":return"failed";case"needs_response":case"warning_needs_response":return"pending";default:return"muted"}},C=(d,i)=>`${i.toUpperCase()} ${(d/100).toFixed(2)}`;function k({serverUrl:d,apiKey:i,pageSize:a=20,authManager:j}){const[r,y]=s.useState([]),[W,b]=s.useState(!0),[D,o]=s.useState(null),[c,p]=s.useState(0),[h,U]=s.useState("all"),[u,_]=s.useState(null),[m,v]=s.useState(""),[S,N]=s.useState(!1),x=s.useCallback(async(t,n)=>{if(j?.isAuthenticated())return j.fetchWithAuth(t,n);const w={"Content-Type":"application/json"};i&&(w["X-API-Key"]=i);const g=await fetch(`${d}${t}`,{...n,headers:{...w,...n?.headers}});if(!g.ok)throw new Error(`Request failed: ${g.status}`);return g.json()},[d,i,j]),f=s.useCallback(async()=>{b(!0),o(null);try{const t=new URLSearchParams;t.set("limit",String(a)),t.set("offset",String(c)),h!=="all"&&t.set("status",h);const n=await x(`/admin/disputes?${t.toString()}`);y(n.disputes??[])}catch{o("Failed to load disputes"),y([])}finally{b(!1)}},[x,a,c,h]);s.useEffect(()=>{f()},[f]);const A=async t=>{try{const n=await x(`/admin/disputes/${encodeURIComponent(t)}`);_(n),v(n.status)}catch{o("Failed to load dispute details")}},R=async()=>{if(!(!u||!m.trim())){N(!0);try{const t=await x(`/admin/disputes/${encodeURIComponent(u.id)}/status`,{method:"PUT",body:JSON.stringify({status:m})});_(t),f()}catch{o("Failed to update dispute status")}finally{N(!1)}}};if(u){const t=u;return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>_(null),style:{marginBottom:"1rem"},children:"← Back to disputes"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Dispute ",e.jsx("code",{style:{fontSize:"0.8rem"},children:t.id.slice(0,12)})]})}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px"},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:"Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Amount"}),e.jsx("td",{children:C(t.amount,t.currency)})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Source"}),e.jsx("td",{children:t.source})]}),t.reason&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Reason"}),e.jsx("td",{children:t.reason})]}),t.orderId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Order ID"}),e.jsx("td",{children:e.jsx("code",{children:t.orderId})})]}),t.chargeId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Charge ID"}),e.jsx("td",{children:e.jsx("code",{children:t.chargeId})})]}),t.paymentIntentId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Payment Intent"}),e.jsx("td",{children:e.jsx("code",{children:t.paymentIntentId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Created"}),e.jsx("td",{children:l.formatDateTime(t.createdAt)})]}),t.statusUpdatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Status Updated"}),e.jsx("td",{children:l.formatDateTime(t.statusUpdatedAt)})]})]})})}),e.jsxs("div",{style:{marginTop:"1rem",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.jsxs("select",{className:"cedros-admin__input",value:m,onChange:n=>v(n.target.value),children:[e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"}),e.jsx("option",{value:"warning_closed",children:"Warning Closed"})]})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:R,disabled:S||m===t.status,children:S?"Updating...":"Update"})]})]})}return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Disputes & Chargebacks"})}),e.jsx(l.ErrorBanner,{message:D}),e.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:e.jsxs("select",{className:"cedros-admin__input",value:h,onChange:t=>{U(t.target.value),p(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"})]})}),W?e.jsxs("div",{className:"cedros-admin__loading",children:[l.Icons.loading," Loading disputes..."]}):r.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No disputes 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:"ID"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Source"}),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("code",{style:{fontSize:"0.75rem"},children:t.id.slice(0,12)})}),e.jsx("td",{children:C(t.amount,t.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})}),e.jsx("td",{children:t.reason??"—"}),e.jsx("td",{children:t.source}),e.jsx("td",{children:l.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:()=>A(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:c===0,onClick:()=>p(Math.max(0,c-a)),children:"Previous"}),e.jsxs("span",{children:["Showing ",r.length," dispute",r.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r.length<a,onClick:()=>p(c+a),children:"Next"})]})]})]})}exports.DisputesSection=k;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as E } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useCallback as x, useEffect as L } from "react";
|
|
3
|
+
import { k as v, E as j, I as B } from "./index-DXnuQp5x.mjs";
|
|
4
|
+
const U = (i) => {
|
|
5
|
+
switch (i) {
|
|
6
|
+
case "won":
|
|
7
|
+
return "success";
|
|
8
|
+
case "lost":
|
|
9
|
+
return "failed";
|
|
10
|
+
case "needs_response":
|
|
11
|
+
case "warning_needs_response":
|
|
12
|
+
return "pending";
|
|
13
|
+
default:
|
|
14
|
+
return "muted";
|
|
15
|
+
}
|
|
16
|
+
}, A = (i, a) => `${a.toUpperCase()} ${(i / 100).toFixed(2)}`;
|
|
17
|
+
function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
18
|
+
const [c, N] = d([]), [D, w] = d(!0), [k, o] = d(null), [l, f] = d(0), [h, R] = d("all"), [u, g] = d(null), [m, I] = d(""), [S, C] = d(!1), p = x(async (t, s) => {
|
|
19
|
+
if (_?.isAuthenticated())
|
|
20
|
+
return _.fetchWithAuth(t, s);
|
|
21
|
+
const W = { "Content-Type": "application/json" };
|
|
22
|
+
a && (W["X-API-Key"] = a);
|
|
23
|
+
const b = await fetch(`${i}${t}`, { ...s, headers: { ...W, ...s?.headers } });
|
|
24
|
+
if (!b.ok) throw new Error(`Request failed: ${b.status}`);
|
|
25
|
+
return b.json();
|
|
26
|
+
}, [i, a, _]), y = x(async () => {
|
|
27
|
+
w(!0), o(null);
|
|
28
|
+
try {
|
|
29
|
+
const t = new URLSearchParams();
|
|
30
|
+
t.set("limit", String(r)), t.set("offset", String(l)), h !== "all" && t.set("status", h);
|
|
31
|
+
const s = await p(`/admin/disputes?${t.toString()}`);
|
|
32
|
+
N(s.disputes ?? []);
|
|
33
|
+
} catch {
|
|
34
|
+
o("Failed to load disputes"), N([]);
|
|
35
|
+
} finally {
|
|
36
|
+
w(!1);
|
|
37
|
+
}
|
|
38
|
+
}, [p, r, l, h]);
|
|
39
|
+
L(() => {
|
|
40
|
+
y();
|
|
41
|
+
}, [y]);
|
|
42
|
+
const $ = async (t) => {
|
|
43
|
+
try {
|
|
44
|
+
const s = await p(`/admin/disputes/${encodeURIComponent(t)}`);
|
|
45
|
+
g(s), I(s.status);
|
|
46
|
+
} catch {
|
|
47
|
+
o("Failed to load dispute details");
|
|
48
|
+
}
|
|
49
|
+
}, F = async () => {
|
|
50
|
+
if (!(!u || !m.trim())) {
|
|
51
|
+
C(!0);
|
|
52
|
+
try {
|
|
53
|
+
const t = await p(
|
|
54
|
+
`/admin/disputes/${encodeURIComponent(u.id)}/status`,
|
|
55
|
+
{ method: "PUT", body: JSON.stringify({ status: m }) }
|
|
56
|
+
);
|
|
57
|
+
g(t), y();
|
|
58
|
+
} catch {
|
|
59
|
+
o("Failed to update dispute status");
|
|
60
|
+
} finally {
|
|
61
|
+
C(!1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (u) {
|
|
66
|
+
const t = u;
|
|
67
|
+
return /* @__PURE__ */ n("div", { children: [
|
|
68
|
+
/* @__PURE__ */ e(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
type: "button",
|
|
72
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
73
|
+
onClick: () => g(null),
|
|
74
|
+
style: { marginBottom: "1rem" },
|
|
75
|
+
children: "← Back to disputes"
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ n("h3", { className: "cedros-admin__section-title", children: [
|
|
79
|
+
"Dispute ",
|
|
80
|
+
/* @__PURE__ */ e("code", { style: { fontSize: "0.8rem" }, children: t.id.slice(0, 12) })
|
|
81
|
+
] }) }),
|
|
82
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__table-container", style: { maxWidth: "500px" }, children: /* @__PURE__ */ e("table", { className: "cedros-admin__table", children: /* @__PURE__ */ n("tbody", { children: [
|
|
83
|
+
/* @__PURE__ */ n("tr", { children: [
|
|
84
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600, width: "35%" }, children: "Status" }),
|
|
85
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${U(t.status)}`, children: t.status }) })
|
|
86
|
+
] }),
|
|
87
|
+
/* @__PURE__ */ n("tr", { children: [
|
|
88
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Amount" }),
|
|
89
|
+
/* @__PURE__ */ e("td", { children: A(t.amount, t.currency) })
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ n("tr", { children: [
|
|
92
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Source" }),
|
|
93
|
+
/* @__PURE__ */ e("td", { children: t.source })
|
|
94
|
+
] }),
|
|
95
|
+
t.reason && /* @__PURE__ */ n("tr", { children: [
|
|
96
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Reason" }),
|
|
97
|
+
/* @__PURE__ */ e("td", { children: t.reason })
|
|
98
|
+
] }),
|
|
99
|
+
t.orderId && /* @__PURE__ */ n("tr", { children: [
|
|
100
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Order ID" }),
|
|
101
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: t.orderId }) })
|
|
102
|
+
] }),
|
|
103
|
+
t.chargeId && /* @__PURE__ */ n("tr", { children: [
|
|
104
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Charge ID" }),
|
|
105
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: t.chargeId }) })
|
|
106
|
+
] }),
|
|
107
|
+
t.paymentIntentId && /* @__PURE__ */ n("tr", { children: [
|
|
108
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Payment Intent" }),
|
|
109
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: t.paymentIntentId }) })
|
|
110
|
+
] }),
|
|
111
|
+
/* @__PURE__ */ n("tr", { children: [
|
|
112
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Created" }),
|
|
113
|
+
/* @__PURE__ */ e("td", { children: v(t.createdAt) })
|
|
114
|
+
] }),
|
|
115
|
+
t.statusUpdatedAt && /* @__PURE__ */ n("tr", { children: [
|
|
116
|
+
/* @__PURE__ */ e("td", { style: { fontWeight: 600 }, children: "Status Updated" }),
|
|
117
|
+
/* @__PURE__ */ e("td", { children: v(t.statusUpdatedAt) })
|
|
118
|
+
] })
|
|
119
|
+
] }) }) }),
|
|
120
|
+
/* @__PURE__ */ n("div", { style: { marginTop: "1rem", display: "flex", gap: "0.5rem", alignItems: "flex-end", maxWidth: "400px" }, children: [
|
|
121
|
+
/* @__PURE__ */ n("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
|
|
122
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Update Status" }),
|
|
123
|
+
/* @__PURE__ */ n("select", { className: "cedros-admin__input", value: m, onChange: (s) => I(s.target.value), children: [
|
|
124
|
+
/* @__PURE__ */ e("option", { value: "needs_response", children: "Needs Response" }),
|
|
125
|
+
/* @__PURE__ */ e("option", { value: "under_review", children: "Under Review" }),
|
|
126
|
+
/* @__PURE__ */ e("option", { value: "won", children: "Won" }),
|
|
127
|
+
/* @__PURE__ */ e("option", { value: "lost", children: "Lost" }),
|
|
128
|
+
/* @__PURE__ */ e("option", { value: "warning_closed", children: "Warning Closed" })
|
|
129
|
+
] })
|
|
130
|
+
] }),
|
|
131
|
+
/* @__PURE__ */ e(
|
|
132
|
+
"button",
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
136
|
+
onClick: F,
|
|
137
|
+
disabled: S || m === t.status,
|
|
138
|
+
children: S ? "Updating..." : "Update"
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
] })
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ n("div", { children: [
|
|
145
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Disputes & Chargebacks" }) }),
|
|
146
|
+
/* @__PURE__ */ e(j, { message: k }),
|
|
147
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: /* @__PURE__ */ n(
|
|
148
|
+
"select",
|
|
149
|
+
{
|
|
150
|
+
className: "cedros-admin__input",
|
|
151
|
+
value: h,
|
|
152
|
+
onChange: (t) => {
|
|
153
|
+
R(t.target.value), f(0);
|
|
154
|
+
},
|
|
155
|
+
style: { width: "auto", fontSize: "0.85rem" },
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ e("option", { value: "all", children: "All statuses" }),
|
|
158
|
+
/* @__PURE__ */ e("option", { value: "needs_response", children: "Needs Response" }),
|
|
159
|
+
/* @__PURE__ */ e("option", { value: "under_review", children: "Under Review" }),
|
|
160
|
+
/* @__PURE__ */ e("option", { value: "won", children: "Won" }),
|
|
161
|
+
/* @__PURE__ */ e("option", { value: "lost", children: "Lost" })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
) }),
|
|
165
|
+
D ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
166
|
+
B.loading,
|
|
167
|
+
" Loading disputes..."
|
|
168
|
+
] }) : c.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No disputes found." }) : /* @__PURE__ */ n(E, { children: [
|
|
169
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
170
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
171
|
+
/* @__PURE__ */ e("th", { children: "ID" }),
|
|
172
|
+
/* @__PURE__ */ e("th", { children: "Amount" }),
|
|
173
|
+
/* @__PURE__ */ e("th", { children: "Status" }),
|
|
174
|
+
/* @__PURE__ */ e("th", { children: "Reason" }),
|
|
175
|
+
/* @__PURE__ */ e("th", { children: "Source" }),
|
|
176
|
+
/* @__PURE__ */ e("th", { children: "Created" }),
|
|
177
|
+
/* @__PURE__ */ e("th", {})
|
|
178
|
+
] }) }),
|
|
179
|
+
/* @__PURE__ */ e("tbody", { children: c.map((t) => /* @__PURE__ */ n("tr", { children: [
|
|
180
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { style: { fontSize: "0.75rem" }, children: t.id.slice(0, 12) }) }),
|
|
181
|
+
/* @__PURE__ */ e("td", { children: A(t.amount, t.currency) }),
|
|
182
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${U(t.status)}`, children: t.status }) }),
|
|
183
|
+
/* @__PURE__ */ e("td", { children: t.reason ?? "—" }),
|
|
184
|
+
/* @__PURE__ */ e("td", { children: t.source }),
|
|
185
|
+
/* @__PURE__ */ e("td", { children: v(t.createdAt) }),
|
|
186
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
type: "button",
|
|
190
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
191
|
+
onClick: () => $(t.id),
|
|
192
|
+
children: "View"
|
|
193
|
+
}
|
|
194
|
+
) })
|
|
195
|
+
] }, t.id)) })
|
|
196
|
+
] }) }),
|
|
197
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "0.75rem", fontSize: "0.85rem" }, children: [
|
|
198
|
+
/* @__PURE__ */ e(
|
|
199
|
+
"button",
|
|
200
|
+
{
|
|
201
|
+
type: "button",
|
|
202
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
203
|
+
disabled: l === 0,
|
|
204
|
+
onClick: () => f(Math.max(0, l - r)),
|
|
205
|
+
children: "Previous"
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ n("span", { children: [
|
|
209
|
+
"Showing ",
|
|
210
|
+
c.length,
|
|
211
|
+
" dispute",
|
|
212
|
+
c.length !== 1 ? "s" : ""
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ e(
|
|
215
|
+
"button",
|
|
216
|
+
{
|
|
217
|
+
type: "button",
|
|
218
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
219
|
+
disabled: c.length < r,
|
|
220
|
+
onClick: () => f(l + r),
|
|
221
|
+
children: "Next"
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
] })
|
|
225
|
+
] })
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
export {
|
|
229
|
+
q as DisputesSection
|
|
230
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as r, useCallback as R, useEffect as V, useMemo as G } from "react";
|
|
3
|
-
import { E as H, j as Y, I as l } from "./index-
|
|
3
|
+
import { E as H, j as Y, I as l } from "./index-DXnuQp5x.mjs";
|
|
4
4
|
function M({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
|
|
5
5
|
const [_, F] = r([]), [E, C] = r(!0), [S, N] = r(!1), [v, k] = r(null), [Q, I] = r(!1), [y, $] = r(""), [f, x] = r("all"), [q, w] = r(null), [T, b] = r(null), [n, m] = r({
|
|
6
6
|
question: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("./index-C7MWL6O8.js");function R({serverUrl:h,apiKey:o,pageSize:g=20,authManager:r}){const[u,N]=c.useState([]),[Q,w]=c.useState(!0),[S,f]=c.useState(!1),[p,A]=c.useState(null),[F,C]=c.useState(!1),[x,P]=c.useState(""),[v,O]=c.useState("all"),[q,b]=c.useState(null),[$,j]=c.useState(null),[n,l]=c.useState({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),_=c.useCallback(async()=>{w(!0);try{j(null);let s;const t=`/admin/faqs?limit=${g}`;if(r?.isAuthenticated())s=await r.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);const a=await fetch(`${h}${t}`,{headers:i});if(!a.ok)throw new Error(`Failed to fetch FAQs: ${a.status}`);s=await a.json()}N(s.faqs||[])}catch{N([]),j("Failed to load FAQs")}finally{w(!1)}},[h,o,g,r]);c.useEffect(()=>{_()},[_]);const E=async s=>{if(s.preventDefault(),!(!n.question.trim()||!n.answer.trim())){C(!0);try{const t=n.keywordsCsv.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),i={question:n.question.trim(),answer:n.answer.trim(),keywords:t,active:n.active,useInChat:n.useInChat,displayOnPage:n.displayOnPage};if(p){const a=`/admin/faqs/${p.id}`;if(r?.isAuthenticated())await r.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};o&&(m["X-API-Key"]=o);const I=await fetch(`${h}${a}`,{method:"PUT",headers:m,body:JSON.stringify(i)});if(!I.ok)throw new Error(`Failed to update FAQ: ${I.status}`)}}else if(r?.isAuthenticated())await r.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);const m=await fetch(`${h}/admin/faqs`,{method:"POST",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to create FAQ: ${m.status}`)}y(),_()}catch{j(p?"Failed to update FAQ":"Failed to create FAQ")}finally{C(!1)}}},T=async s=>{try{const t=`/admin/faqs/${s}`;if(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);const a=await fetch(`${h}${t}`,{method:"DELETE",headers:i});if(!a.ok)throw new Error(`Failed to delete FAQ: ${a.status}`)}_()}catch{j("Failed to delete FAQ")}b(null)},D=async s=>{try{const t=`/admin/faqs/${s.id}`,i={...s,active:!s.active};if(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);const m=await fetch(`${h}${t}`,{method:"PUT",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to update FAQ: ${m.status}`)}_()}catch{j("Failed to update FAQ status")}},y=()=>{l({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),A(null),f(!1)},L=s=>{l({question:s.question,answer:s.answer,keywordsCsv:s.keywords.join(", "),active:s.active,useInChat:s.useInChat??!0,displayOnPage:s.displayOnPage??!0}),A(s),f(!0)},W=u.length,B=u.filter(s=>s.active).length,J=u.filter(s=>s.active&&s.useInChat).length,X=u.filter(s=>s.active&&s.displayOnPage).length,k=c.useMemo(()=>u.filter(s=>{if(v==="active"&&!s.active||v==="inactive"&&s.active)return!1;if(x){const t=x.toLowerCase();return s.question.toLowerCase().includes(t)||s.answer.toLowerCase().includes(t)||s.keywords.some(i=>i.includes(t))}return!0}),[u,v,x]);return e.jsxs("div",{className:"cedros-admin__faqs",children:[e.jsx(d.ErrorBanner,{message:$,onRetry:_}),e.jsx(d.StatsBar,{stats:[{label:"Total FAQs",value:W},{label:"Active",value:B,variant:"success"},{label:"In Chat",value:J},{label:"On Page",value:X}]}),e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{className:"cedros-admin__section-header-left",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Knowledge Base"}),e.jsx("p",{className:"cedros-admin__section-subtitle",children:"Manage FAQs for the AI chat assistant and public FAQ page."})]}),e.jsx("div",{className:"cedros-admin__section-header-right",children:e.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{y(),f(!0)},children:[d.Icons.plus," Add FAQ"]})})]}),e.jsxs("div",{className:"cedros-admin__filters",style:{display:"flex",gap:"1rem",marginBottom:"1rem"},children:[e.jsx("input",{type:"text",placeholder:"Search FAQs...",value:x,onChange:s=>P(s.target.value),className:"cedros-admin__input",style:{flex:1,maxWidth:300}}),e.jsxs("select",{value:v,onChange:s=>O(s.target.value),className:"cedros-admin__select",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"active",children:"Active Only"}),e.jsx("option",{value:"inactive",children:"Inactive Only"})]})]}),S&&e.jsx("div",{className:"cedros-admin__form-container",style:{marginBottom:"1.5rem"},children:e.jsxs("form",{onSubmit:E,className:"cedros-admin__form",children:[e.jsxs("div",{className:"cedros-admin__form-header",children:[e.jsx("h4",{children:p?"Edit FAQ":"Add New FAQ"}),e.jsx("button",{type:"button",className:"cedros-admin__button--icon",onClick:y,children:d.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Question *"}),e.jsx("input",{type:"text",value:n.question,onChange:s=>l(t=>({...t,question:s.target.value})),className:"cedros-admin__input",placeholder:"What is your return policy?",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Answer *"}),e.jsx("textarea",{value:n.answer,onChange:s=>l(t=>({...t,answer:s.target.value})),className:"cedros-admin__textarea",placeholder:"We accept returns within 30 days...",rows:4,required:!0}),e.jsx("span",{className:"cedros-admin__hint",children:"Supports markdown formatting."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Keywords"}),e.jsx("input",{type:"text",value:n.keywordsCsv,onChange:s=>l(t=>({...t,keywordsCsv:s.target.value})),className:"cedros-admin__input",placeholder:"returns, refund, policy"}),e.jsx("span",{className:"cedros-admin__hint",children:"Comma-separated keywords to help AI find this FAQ."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:s=>l(t=>({...t,active:s.target.checked}))}),e.jsx("span",{children:"Active"})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Inactive FAQs won't appear anywhere."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Visibility"}),e.jsxs("div",{className:"cedros-admin__checkbox-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.useInChat,onChange:s=>l(t=>({...t,useInChat:s.target.checked}))}),e.jsx("span",{children:"Use in AI Chat"})]}),e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.displayOnPage,onChange:s=>l(t=>({...t,displayOnPage:s.target.checked}))}),e.jsx("span",{children:"Display on FAQ Page"})]})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Choose where this FAQ should appear."})]}),e.jsxs("div",{className:"cedros-admin__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-admin__button",onClick:y,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:F||!n.question.trim()||!n.answer.trim(),children:F?d.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[d.Icons.loading,e.jsx("span",{children:"Loading FAQs..."})]}):k.length===0?e.jsx("div",{className:"cedros-admin__empty",children:e.jsx("p",{children:x||v!=="all"?"No FAQs match your filters.":"No FAQs yet. Add one to get started."})}):e.jsx("div",{className:"cedros-admin__faq-list",children:k.map(s=>e.jsxs("div",{className:`cedros-admin__faq-item ${s.active?"":"cedros-admin__faq-item--inactive"}`,children:[e.jsxs("div",{className:"cedros-admin__faq-content",children:[e.jsxs("div",{className:"cedros-admin__faq-question",children:[e.jsx("span",{className:`cedros-admin__status-dot ${s.active?"cedros-admin__status-dot--active":"cedros-admin__status-dot--inactive"}`}),s.question]}),e.jsx("div",{className:"cedros-admin__faq-answer",children:s.answer}),e.jsxs("div",{className:"cedros-admin__faq-meta",children:[s.keywords.length>0&&e.jsx("div",{className:"cedros-admin__faq-keywords",children:s.keywords.map(t=>e.jsx("span",{className:"cedros-admin__tag",children:t},t))}),e.jsxs("div",{className:"cedros-admin__faq-visibility",children:[s.useInChat&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--chat",title:"Used in AI Chat",children:[d.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[d.Icons.globe," Page"]})]})]})]}),e.jsxs("div",{className:"cedros-admin__faq-actions",children:[e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>D(s),title:s.active?"Deactivate":"Activate",children:s.active?d.Icons.eyeOff:d.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:d.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:d.Icons.trash})]}),q===s.id&&e.jsx("div",{className:"cedros-admin__confirm-overlay",children:e.jsxs("div",{className:"cedros-admin__confirm-dialog",children:[e.jsx("p",{children:"Delete this FAQ?"}),e.jsxs("div",{className:"cedros-admin__confirm-actions",children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>b(null),children:"Cancel"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger",onClick:()=>T(s.id),children:"Delete"})]})]})})]},s.id))})]})]})}exports.FAQSection=R;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("./index-C0g-JxJk.js");function R({serverUrl:h,apiKey:o,pageSize:g=20,authManager:r}){const[u,N]=c.useState([]),[Q,w]=c.useState(!0),[S,f]=c.useState(!1),[p,A]=c.useState(null),[F,C]=c.useState(!1),[x,P]=c.useState(""),[v,O]=c.useState("all"),[q,b]=c.useState(null),[$,j]=c.useState(null),[n,l]=c.useState({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),_=c.useCallback(async()=>{w(!0);try{j(null);let s;const t=`/admin/faqs?limit=${g}`;if(r?.isAuthenticated())s=await r.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);const a=await fetch(`${h}${t}`,{headers:i});if(!a.ok)throw new Error(`Failed to fetch FAQs: ${a.status}`);s=await a.json()}N(s.faqs||[])}catch{N([]),j("Failed to load FAQs")}finally{w(!1)}},[h,o,g,r]);c.useEffect(()=>{_()},[_]);const E=async s=>{if(s.preventDefault(),!(!n.question.trim()||!n.answer.trim())){C(!0);try{const t=n.keywordsCsv.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),i={question:n.question.trim(),answer:n.answer.trim(),keywords:t,active:n.active,useInChat:n.useInChat,displayOnPage:n.displayOnPage};if(p){const a=`/admin/faqs/${p.id}`;if(r?.isAuthenticated())await r.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};o&&(m["X-API-Key"]=o);const I=await fetch(`${h}${a}`,{method:"PUT",headers:m,body:JSON.stringify(i)});if(!I.ok)throw new Error(`Failed to update FAQ: ${I.status}`)}}else if(r?.isAuthenticated())await r.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);const m=await fetch(`${h}/admin/faqs`,{method:"POST",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to create FAQ: ${m.status}`)}y(),_()}catch{j(p?"Failed to update FAQ":"Failed to create FAQ")}finally{C(!1)}}},T=async s=>{try{const t=`/admin/faqs/${s}`;if(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);const a=await fetch(`${h}${t}`,{method:"DELETE",headers:i});if(!a.ok)throw new Error(`Failed to delete FAQ: ${a.status}`)}_()}catch{j("Failed to delete FAQ")}b(null)},D=async s=>{try{const t=`/admin/faqs/${s.id}`,i={...s,active:!s.active};if(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);const m=await fetch(`${h}${t}`,{method:"PUT",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to update FAQ: ${m.status}`)}_()}catch{j("Failed to update FAQ status")}},y=()=>{l({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),A(null),f(!1)},L=s=>{l({question:s.question,answer:s.answer,keywordsCsv:s.keywords.join(", "),active:s.active,useInChat:s.useInChat??!0,displayOnPage:s.displayOnPage??!0}),A(s),f(!0)},W=u.length,B=u.filter(s=>s.active).length,J=u.filter(s=>s.active&&s.useInChat).length,X=u.filter(s=>s.active&&s.displayOnPage).length,k=c.useMemo(()=>u.filter(s=>{if(v==="active"&&!s.active||v==="inactive"&&s.active)return!1;if(x){const t=x.toLowerCase();return s.question.toLowerCase().includes(t)||s.answer.toLowerCase().includes(t)||s.keywords.some(i=>i.includes(t))}return!0}),[u,v,x]);return e.jsxs("div",{className:"cedros-admin__faqs",children:[e.jsx(d.ErrorBanner,{message:$,onRetry:_}),e.jsx(d.StatsBar,{stats:[{label:"Total FAQs",value:W},{label:"Active",value:B,variant:"success"},{label:"In Chat",value:J},{label:"On Page",value:X}]}),e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{className:"cedros-admin__section-header-left",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Knowledge Base"}),e.jsx("p",{className:"cedros-admin__section-subtitle",children:"Manage FAQs for the AI chat assistant and public FAQ page."})]}),e.jsx("div",{className:"cedros-admin__section-header-right",children:e.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{y(),f(!0)},children:[d.Icons.plus," Add FAQ"]})})]}),e.jsxs("div",{className:"cedros-admin__filters",style:{display:"flex",gap:"1rem",marginBottom:"1rem"},children:[e.jsx("input",{type:"text",placeholder:"Search FAQs...",value:x,onChange:s=>P(s.target.value),className:"cedros-admin__input",style:{flex:1,maxWidth:300}}),e.jsxs("select",{value:v,onChange:s=>O(s.target.value),className:"cedros-admin__select",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"active",children:"Active Only"}),e.jsx("option",{value:"inactive",children:"Inactive Only"})]})]}),S&&e.jsx("div",{className:"cedros-admin__form-container",style:{marginBottom:"1.5rem"},children:e.jsxs("form",{onSubmit:E,className:"cedros-admin__form",children:[e.jsxs("div",{className:"cedros-admin__form-header",children:[e.jsx("h4",{children:p?"Edit FAQ":"Add New FAQ"}),e.jsx("button",{type:"button",className:"cedros-admin__button--icon",onClick:y,children:d.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Question *"}),e.jsx("input",{type:"text",value:n.question,onChange:s=>l(t=>({...t,question:s.target.value})),className:"cedros-admin__input",placeholder:"What is your return policy?",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Answer *"}),e.jsx("textarea",{value:n.answer,onChange:s=>l(t=>({...t,answer:s.target.value})),className:"cedros-admin__textarea",placeholder:"We accept returns within 30 days...",rows:4,required:!0}),e.jsx("span",{className:"cedros-admin__hint",children:"Supports markdown formatting."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Keywords"}),e.jsx("input",{type:"text",value:n.keywordsCsv,onChange:s=>l(t=>({...t,keywordsCsv:s.target.value})),className:"cedros-admin__input",placeholder:"returns, refund, policy"}),e.jsx("span",{className:"cedros-admin__hint",children:"Comma-separated keywords to help AI find this FAQ."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:s=>l(t=>({...t,active:s.target.checked}))}),e.jsx("span",{children:"Active"})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Inactive FAQs won't appear anywhere."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Visibility"}),e.jsxs("div",{className:"cedros-admin__checkbox-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.useInChat,onChange:s=>l(t=>({...t,useInChat:s.target.checked}))}),e.jsx("span",{children:"Use in AI Chat"})]}),e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.displayOnPage,onChange:s=>l(t=>({...t,displayOnPage:s.target.checked}))}),e.jsx("span",{children:"Display on FAQ Page"})]})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Choose where this FAQ should appear."})]}),e.jsxs("div",{className:"cedros-admin__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-admin__button",onClick:y,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:F||!n.question.trim()||!n.answer.trim(),children:F?d.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[d.Icons.loading,e.jsx("span",{children:"Loading FAQs..."})]}):k.length===0?e.jsx("div",{className:"cedros-admin__empty",children:e.jsx("p",{children:x||v!=="all"?"No FAQs match your filters.":"No FAQs yet. Add one to get started."})}):e.jsx("div",{className:"cedros-admin__faq-list",children:k.map(s=>e.jsxs("div",{className:`cedros-admin__faq-item ${s.active?"":"cedros-admin__faq-item--inactive"}`,children:[e.jsxs("div",{className:"cedros-admin__faq-content",children:[e.jsxs("div",{className:"cedros-admin__faq-question",children:[e.jsx("span",{className:`cedros-admin__status-dot ${s.active?"cedros-admin__status-dot--active":"cedros-admin__status-dot--inactive"}`}),s.question]}),e.jsx("div",{className:"cedros-admin__faq-answer",children:s.answer}),e.jsxs("div",{className:"cedros-admin__faq-meta",children:[s.keywords.length>0&&e.jsx("div",{className:"cedros-admin__faq-keywords",children:s.keywords.map(t=>e.jsx("span",{className:"cedros-admin__tag",children:t},t))}),e.jsxs("div",{className:"cedros-admin__faq-visibility",children:[s.useInChat&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--chat",title:"Used in AI Chat",children:[d.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[d.Icons.globe," Page"]})]})]})]}),e.jsxs("div",{className:"cedros-admin__faq-actions",children:[e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>D(s),title:s.active?"Deactivate":"Activate",children:s.active?d.Icons.eyeOff:d.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:d.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:d.Icons.trash})]}),q===s.id&&e.jsx("div",{className:"cedros-admin__confirm-overlay",children:e.jsxs("div",{className:"cedros-admin__confirm-dialog",children:[e.jsx("p",{children:"Delete this FAQ?"}),e.jsxs("div",{className:"cedros-admin__confirm-actions",children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>b(null),children:"Cancel"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger",onClick:()=>T(s.id),children:"Delete"})]})]})})]},s.id))})]})]})}exports.FAQSection=R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),u=require("./index-C0g-JxJk.js"),v=require("./CedrosContext-C2RjHLaQ.js");async function E(s,l,n,c){const o=new FormData;if(o.append("file",c),n?.isAuthenticated())return n.fetchWithAuth("/admin/images/upload",{method:"POST",body:o,headers:{}});const r={};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images/upload`,{method:"POST",headers:r,body:o});if(!d.ok)throw new Error(`Upload failed: ${d.status}`);return d.json()}async function O(s,l,n,c){const o=JSON.stringify({url:c});if(n?.isAuthenticated()){await n.fetchWithAuth("/admin/images",{method:"DELETE",body:o});return}const r={"Content-Type":"application/json"};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images`,{method:"DELETE",headers:r,body:o});if(!d.ok)throw new Error(`Delete failed: ${d.status}`)}function R({serverUrl:s,apiKey:l,authManager:n}){const[c,o]=i.useState([]),[r,d]=i.useState(!1),[x,j]=i.useState(null),[C,m]=i.useState(null),[_,S]=i.useState(null),[p,f]=i.useState(!1),[h,g]=i.useState(null),b=i.useRef(null),D=i.useCallback(async t=>{d(!0),m(null);try{const a=await E(s,l,n,t);o(y=>[{url:a.url,thumbUrl:a.thumbUrl,uploadedAt:new Date().toISOString()},...y]),g(null),b.current&&(b.current.value="")}catch(a){v.getLogger().error("[ImagesSection] Upload failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Upload failed. Check file type and try again.")}finally{d(!1)}},[s,l,n]),w=t=>{const a=t.target.files?.[0]??null;g(a),m(null)},I=()=>{h&&D(h)},U=t=>{t.preventDefault(),f(!0)},N=()=>f(!1),k=t=>{t.preventDefault(),f(!1);const a=t.dataTransfer.files?.[0];a&&a.type.startsWith("image/")?(g(a),m(null)):a&&m("Only image files are accepted.")},T=i.useCallback(async t=>{j(t),m(null);try{await O(s,l,n,t),o(a=>a.filter(y=>y.url!==t))}catch(a){v.getLogger().error("[ImagesSection] Delete failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Failed to delete image.")}finally{j(null)}},[s,l,n]),L=async t=>{try{await navigator.clipboard.writeText(t),S(t),setTimeout(()=>S(null),2e3)}catch{m("Could not copy to clipboard.")}},A=["cedros-admin__drop-zone",p?"cedros-admin__drop-zone--active":""].filter(Boolean).join(" ");return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(u.ErrorBanner,{message:C}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Image Upload"})}),e.jsxs("div",{className:A,onDragOver:U,onDragLeave:N,onDrop:k,role:"region","aria-label":"Image drop zone",style:{border:"2px dashed",borderColor:p?"var(--cedros-accent, #6366f1)":"var(--cedros-border, #e2e8f0)",borderRadius:"0.5rem",padding:"1.5rem",textAlign:"center",marginBottom:"1rem",transition:"border-color 0.15s",backgroundColor:p?"var(--cedros-accent-subtle, rgba(99,102,241,0.06))":void 0},children:[e.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:"Drag and drop an image here, or select a file below"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"center",alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{ref:b,id:"cedros-image-file-input",type:"file",accept:"image/*",className:"cedros-admin__input",style:{maxWidth:260},onChange:w,"aria-label":"Select image file"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:I,disabled:!h||r,"aria-busy":r,children:r?e.jsxs(e.Fragment,{children:[u.Icons.loading," Uploading..."]}):"Upload"})]}),h&&!r&&e.jsxs("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",opacity:.65},children:["Selected: ",h.name," (",(h.size/1024).toFixed(1)," KB)"]})]}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Uploaded This Session",c.length>0&&e.jsx("span",{className:"cedros-admin__section-badge",style:{marginLeft:"0.5rem"},children:c.length})]})}),c.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No images uploaded yet."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Preview"}),e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Uploaded"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:c.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{width:72},children:e.jsx("img",{src:t.thumbUrl,alt:"Thumbnail preview",style:{width:56,height:56,objectFit:"cover",borderRadius:"0.25rem",display:"block"}})}),e.jsx("td",{style:{maxWidth:320,wordBreak:"break-all"},children:e.jsx("code",{style:{fontSize:"0.8rem"},children:t.url})}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:u.formatDateTime(t.uploadedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem"},children:[e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>L(t.url),"aria-label":"Copy URL to clipboard",title:"Copy URL",children:[_===t.url?u.Icons.check:u.Icons.eye,_===t.url?"Copied":"Copy URL"]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--destructive",onClick:()=>T(t.url),disabled:x===t.url,"aria-label":"Delete image",title:"Delete",children:[x===t.url?u.Icons.loading:u.Icons.trash,"Delete"]})]})})]},t.url))})]})})]})}exports.ImagesSection=R;
|