@arcblock/payment-service 1.29.7 → 1.29.9
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/cf.d.ts +31 -0
- package/dist/cf.js +79 -60
- package/dist/index.d.ts +17 -0
- package/dist/index.js +264 -73
- package/package.json +4 -4
- package/web/assets/{account-DETfFe4_.js → account-Clbqiiw3.js} +1 -1
- package/web/assets/{action-B_DQJlip.js → action-DENqSeOa.js} +1 -1
- package/web/assets/{actions-BtaoyTWt.js → actions-0iWP2mcx.js} +1 -1
- package/web/assets/{actions-QPa-8lfB.js → actions-BD9BAp3M.js} +1 -1
- package/web/assets/{actions-jxGAdGfb.js → actions-BJDN6Op2.js} +1 -1
- package/web/assets/{actions-DJyfN5OU.js → actions-BSNy5bOd.js} +1 -1
- package/web/assets/{actions-Bt_jST94.js → actions-CDsj5j8l.js} +1 -1
- package/web/assets/{actions-D9MHLBFH.js → actions-CSpJGOX7.js} +1 -1
- package/web/assets/{actions-BknL4OyZ.js → actions-CZL47E9r.js} +1 -1
- package/web/assets/{actions-EPYeS5p4.js → actions-D3tJgrUn.js} +1 -1
- package/web/assets/{actions-BaDh4xWX.js → actions-DGQs8fFF.js} +1 -1
- package/web/assets/{add-price-CD-utowo.js → add-price-BpnICuHO.js} +1 -1
- package/web/assets/{admin-_nEB-lHn.js → admin-CD8ViZ7D.js} +1 -1
- package/web/assets/{assign-CkV5Q2LP.js → assign-0vMUDW_C.js} +1 -1
- package/web/assets/{attempts-DySeqBYU.js → attempts-CKlxkJuE.js} +1 -1
- package/web/assets/browser-DDv4_sgY.js +1 -0
- package/web/assets/{change-payment-CPUCUEER.js → change-payment-gAlRmJpv.js} +1 -1
- package/web/assets/{change-plan-CxE-XfWc.js → change-plan-C47wfWH8.js} +1 -1
- package/web/assets/{click-boundary-y8dVA_tr.js → click-boundary-CafubiPp.js} +1 -1
- package/web/assets/{connect-CC_l_f6Q.js → connect-BHHzrwLA.js} +1 -1
- package/web/assets/{copyable-DpX04wZz.js → copyable-QrCyyiou.js} +1 -1
- package/web/assets/{create-3SsWCAOC.js → create-0PUtkJZY.js} +1 -1
- package/web/assets/{create-BkQAaSvD.js → create-BJ1asdcy.js} +1 -1
- package/web/assets/{create-kG09X9gl.js → create-Bgv5ux17.js} +1 -1
- package/web/assets/{create-BmcRybZ5.js → create-C7GOgZZM.js} +1 -1
- package/web/assets/{create-tYebjhr9.js → create-DNar5UQD.js} +1 -1
- package/web/assets/{create-Bs65p5Ne.js → create-ke4FrPx1.js} +1 -1
- package/web/assets/{credit-grant-item-list-Bk27jIc7.js → credit-grant-item-list-CeDAM3qV.js} +1 -1
- package/web/assets/{credit-overview-DmMSEs14.js → credit-overview-4zh0H02x.js} +2 -2
- package/web/assets/{currency-restrictions-DYLv4YyW.js → currency-restrictions-BcEm8W45.js} +1 -1
- package/web/assets/{currency-select-DGS-62-L.js → currency-select-B4ieQBvv.js} +1 -1
- package/web/assets/{dayjs-B9tvQIKg.js → dayjs-DUTDpcNU.js} +1 -1
- package/web/assets/{description-Ym17DL48.js → description-SnR5WxWT.js} +1 -1
- package/web/assets/detail-46aLUdJj.js +1 -0
- package/web/assets/{detail-Cr2wG4Th.js → detail-B-ceWfZr.js} +1 -1
- package/web/assets/detail-B0IHl4MI.js +1 -0
- package/web/assets/detail-B8eOBVSQ.js +15 -0
- package/web/assets/{detail-DE3OOC5M.js → detail-BO3zglCn.js} +1 -1
- package/web/assets/{detail-DG4l2CqN.js → detail-BQpDGZJQ.js} +1 -1
- package/web/assets/{detail-CxYQYu_l.js → detail-BXTsnQny.js} +1 -1
- package/web/assets/{detail-CT9Unyrf.js → detail-B_lpOomD.js} +1 -1
- package/web/assets/{detail-Do9QO5L2.js → detail-Bfnkg0A1.js} +1 -1
- package/web/assets/detail-BwH0DwAi.js +1 -0
- package/web/assets/{detail-OZeeKI69.js → detail-C1FupF1D.js} +2 -2
- package/web/assets/{detail-cwHZbY62.js → detail-CMBRd4Ct.js} +1 -1
- package/web/assets/detail-C_Zdfa0y.js +1 -0
- package/web/assets/{detail-Cb9HBSMw.js → detail-Cg505nKX.js} +1 -1
- package/web/assets/{detail-DB56SG-k.js → detail-CsGZMimg.js} +1 -1
- package/web/assets/{detail-K9EVY3r2.js → detail-Ct5QNBqu.js} +1 -1
- package/web/assets/{detail-DuO_Jn5X.js → detail-CyMhK5K_.js} +1 -1
- package/web/assets/{detail-DuWdZIyp.js → detail-DACnmls3.js} +1 -1
- package/web/assets/{detail-BJTcK7mx.js → detail-DCTb8R7F.js} +1 -1
- package/web/assets/{detail-DPCTQLOx.js → detail-DNcp_u5S.js} +1 -1
- package/web/assets/detail-DbU3p040.js +1 -0
- package/web/assets/{detail-D5KRrQDx.js → detail-Tn2R5C8i.js} +1 -1
- package/web/assets/{detail-15zxCbV9.js → detail-wU4wNf4s.js} +1 -1
- package/web/assets/{drawer-form-Cl0T1Yyt.js → drawer-form-DspWWj3x.js} +1 -1
- package/web/assets/{edit-3HUAnaXW.js → edit-Bkj-OTJh.js} +1 -1
- package/web/assets/{editor-BF5I0siU.js → editor-AmthipP2.js} +1 -1
- package/web/assets/{embed-CsNqeCd0.js → embed-rRKjDoHi.js} +1 -1
- package/web/assets/{filter-toolbar-BydfQ-79.js → filter-toolbar-DXGSTq57.js} +1 -1
- package/web/assets/{form-DSzMo9UD.js → form-B5WW-lS5.js} +1 -1
- package/web/assets/form-BmQlJZ84.js +9 -0
- package/web/assets/{form-BGm5NPDn.js → form-CAPjlw7l.js} +1 -1
- package/web/assets/{form-CKfKLGXP.js → form-DD-EiA7W.js} +3 -3
- package/web/assets/{form-P4luyUpY.js → form-cX026J4G.js} +1 -1
- package/web/assets/{gas-Qf0SSUfS.js → gas-nyR96dB0.js} +1 -1
- package/web/assets/{generateCategoricalChart-BaWwaXky.js → generateCategoricalChart-BadryV3H.js} +1 -1
- package/web/assets/{home-HbrLyxJL.js → home-_eX1aim8.js} +1 -1
- package/web/assets/index-BBHMsIxJ.js +1 -0
- package/web/assets/{index-Dr_MwbKt.js → index-BQjlhCSt.js} +1 -1
- package/web/assets/{index-DPodCQ9c.js → index-BRENdB5m.js} +1 -1
- package/web/assets/{index-9xBRL_33.js → index-BTfJ08JU.js} +1 -1
- package/web/assets/{index-DgSc1Qy8.js → index-BarN7DfU.js} +17 -17
- package/web/assets/index-BhcoukR2.js +1 -0
- package/web/assets/index-BturOfxo.js +1 -0
- package/web/assets/{index-SYTpMMMH.js → index-BzABukCz.js} +1 -1
- package/web/assets/{index-2l22EYw9.js → index-C-RT84yb.js} +1 -1
- package/web/assets/{index-C0JaS08f.js → index-C136x0O2.js} +1 -1
- package/web/assets/{index-Cw0ugaQL.js → index-CCVDDX0c.js} +1 -1
- package/web/assets/index-CDVogp6E.js +1 -0
- package/web/assets/{index-Br7_mvEw.js → index-CW8VfoJO.js} +1 -1
- package/web/assets/{index-BIoSdRvX.js → index-CbSXdD6E.js} +3 -3
- package/web/assets/{index-CdkYrABk.js → index-Cd_BD9TM.js} +1 -1
- package/web/assets/index-D-bx9Kam.js +1 -0
- package/web/assets/index-D0mynT6_.js +1 -0
- package/web/assets/index-DEiuhiEo.js +14 -0
- package/web/assets/{index-DE2KzqXl.js → index-DNGmCIRP.js} +1 -1
- package/web/assets/{index-CI_EY4YS.js → index-DSe7Dot_.js} +1 -1
- package/web/assets/{index-BFML4-2u.js → index-DcddP3R9.js} +1 -1
- package/web/assets/index-DcrGSDby.js +1 -0
- package/web/assets/{index-fByZjxLy.js → index-DeK5Pqjv.js} +1 -1
- package/web/assets/{index-Clbt8nRm.js → index-DoX0A-rP.js} +1 -1
- package/web/assets/index-Du0Ieh1F.js +49 -0
- package/web/assets/index-Dybqd298.js +1 -0
- package/web/assets/index-EXZPddtw.js +1 -0
- package/web/assets/{index-Drav4oDH.js → index-Kd_qCyRG.js} +2 -2
- package/web/assets/{index-Dc954mDP.js → index-SOzRg0yJ.js} +1 -1
- package/web/assets/{index-BMKZToMM.js → index-UYeD8rTJ.js} +2 -2
- package/web/assets/{index-DZpJPE1Z.js → index-W2uZUlFs.js} +1 -1
- package/web/assets/{index-1y9kjPIr.js → index-XaFn2ySq.js} +1 -1
- package/web/assets/{index-fswPX_qe.js → index-YG5oc8O3.js} +1 -1
- package/web/assets/{index-B1pTTyGZ.js → index-ajD9Iotk.js} +1 -1
- package/web/assets/index-brUCsnBA.js +1 -0
- package/web/assets/{index-BP53rZV9.js → index-mn5Zdrtn.js} +1 -1
- package/web/assets/index-qulrJQ4J.js +1 -0
- package/web/assets/{index.es-BWnfUzLb.js → index.es-C8dcCHdW.js} +1 -1
- package/web/assets/{info-card-C1yxhxJG.js → info-card-BvIMFQo5.js} +1 -1
- package/web/assets/{info-metric-CNse3r66.js → info-metric-Dl4ZDm0Z.js} +1 -1
- package/web/assets/{info-row-group-BeUhWnnY.js → info-row-group-CFuMWJf1.js} +1 -1
- package/web/assets/{info-row-DOK2whMn.js → info-row-jI0h_hv4.js} +1 -1
- package/web/assets/{libphonenumber-CyphiuxQ.js → libphonenumber-Qs8PCdM-.js} +1 -1
- package/web/assets/{link-3eeclTeS.js → link-CmPoIweR.js} +1 -1
- package/web/assets/{list-DnePqZ2K.js → list-BdSkPjIa.js} +1 -1
- package/web/assets/{list-jHj_5yy3.js → list-CWMEf-_C.js} +1 -1
- package/web/assets/{list-C521zE_7.js → list-CkHExntK.js} +1 -1
- package/web/assets/{list-CO0X4L3-.js → list-DLB_hd0Q.js} +1 -1
- package/web/assets/{list-D-I0msRW.js → list-DVFJwd_I.js} +2 -2
- package/web/assets/{list-D1aevUOI.js → list-DaK9287Y.js} +2 -2
- package/web/assets/{list-1OG83xc4.js → list-DghnUOc4.js} +1 -1
- package/web/assets/{list-CNmzJKIQ.js → list-eFkvVlp5.js} +1 -1
- package/web/assets/metadata-BmQTVFku.js +55 -0
- package/web/assets/{meter-event-lmNMgmIu.js → meter-event-B1JIhVpb.js} +1 -1
- package/web/assets/{metrics-C7U41HWk.js → metrics-UvxyQbUF.js} +1 -1
- package/web/assets/{overview-Cs3-8n4e.js → overview-Cxc6WKba.js} +1 -1
- package/web/assets/{overview-CH1HnSP-.js → overview-DrMaIptb.js} +1 -1
- package/web/assets/{past-due-CGGRZmXY.js → past-due-CUXkxns0.js} +1 -1
- package/web/assets/pay-omLYkqRA.js +4 -0
- package/web/assets/{payment-method-info-BsOBbA3m.js → payment-method-info-Bsf89VxV.js} +2 -2
- package/web/assets/{preview-DjYRpRA8.js → preview-BifsgUGT.js} +1 -1
- package/web/assets/{preview-CjYh9dTg.js → preview-C-H8pGVw.js} +1 -1
- package/web/assets/{pricing-table-C3Lkhq46.js → pricing-table-B3QOaAB5.js} +2 -2
- package/web/assets/{pricing-table-edE6TJGX.js → pricing-table-BUJdtkMq.js} +1 -1
- package/web/assets/{product-select-0ScZE2e8.js → product-select-ChEyoJqJ.js} +1 -1
- package/web/assets/{recharge-DcPtT8vt.js → recharge-BVT4USAO.js} +1 -1
- package/web/assets/{related-credit-grants-BygNGPfb.js → related-credit-grants-JV2ICsR5.js} +22 -22
- package/web/assets/{safe-did-address-B0fFbUph.js → safe-did-address-CiG_V6Gy.js} +1 -1
- package/web/assets/{source-data-viewer-By_Utay-.js → source-data-viewer-i1q9wNIG.js} +1 -1
- package/web/assets/{status-l6pD08fw.js → status-CUVYrUIG.js} +1 -1
- package/web/assets/subscription-BYz_k9dq.js +1 -0
- package/web/assets/{subscription-Dq22e3D1.js → subscription-DrnSPIfs.js} +1 -1
- package/web/assets/table-BrtHemkA.js +1 -0
- package/web/assets/{tax-code-select-CWhIIiXi.js → tax-code-select-TS07I0rB.js} +1 -1
- package/web/assets/{tax-utils-DqNX34-r.js → tax-utils-bPjALcVG.js} +1 -1
- package/web/assets/{uploader-DRXDz_r0.js → uploader-CsQNHG4I.js} +1 -1
- package/web/assets/{usage-records-jjJMZ6DI.js → usage-records-DAUQMJAW.js} +1 -1
- package/web/assets/{util-mDHAL0lx.js → util-DxXTXkeY.js} +1 -1
- package/web/assets/{vendor-arcblock-ChFCRdyx.js → vendor-arcblock-BTCAQSUK.js} +1 -1
- package/web/assets/{vendor-blocklet-D_i_QeSo.js → vendor-blocklet-DcLR2Cyf.js} +43 -43
- package/web/index.html +1 -1
- package/web/assets/browser-DSLTxXlL.js +0 -1
- package/web/assets/detail-ASPdMJoW.js +0 -1
- package/web/assets/detail-CIx9vkir.js +0 -1
- package/web/assets/detail-D5NbV29V.js +0 -1
- package/web/assets/detail-DVVzYhdV.js +0 -1
- package/web/assets/detail-Dqc0OfCQ.js +0 -1
- package/web/assets/detail-uhlID8jD.js +0 -15
- package/web/assets/form-BXAuSawq.js +0 -9
- package/web/assets/index-0HK7CYm4.js +0 -1
- package/web/assets/index-BJ_E6bEO.js +0 -1
- package/web/assets/index-Bnyh4rlV.js +0 -1
- package/web/assets/index-BoQ7wf3O.js +0 -1
- package/web/assets/index-C68x-aau.js +0 -1
- package/web/assets/index-C8s2QKoe.js +0 -1
- package/web/assets/index-Cn7O-OP7.js +0 -49
- package/web/assets/index-DU39aG5u.js +0 -1
- package/web/assets/index-DtbqgSK4.js +0 -1
- package/web/assets/index-DuRu9NWB.js +0 -14
- package/web/assets/index-WMKOiUez.js +0 -1
- package/web/assets/index-dmHgoplS.js +0 -1
- package/web/assets/index-txVTkoDD.js +0 -1
- package/web/assets/metadata-CMSHcSXi.js +0 -55
- package/web/assets/pay-CSpHBUh_.js +0 -4
- package/web/assets/subscription-DcwhSOpa.js +0 -1
- package/web/assets/table-BRU4Enia.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as F,j as e,aQ as ee,aT as te,ad as R,a3 as m,q as x,$ as z,w as O,I as ie,ci as se,u as re,O as U,bX as ne,A as E,B as c,z as ae,bv as oe,N as B,Y as C,x as I,be as ce,bf as le}from"./vendor-mui-BXZut9Pz.js";import{V as M,X as H,Y as k,O as de}from"./vendor-blocklet-D_i_QeSo.js";import{a as L,Y as q,e as S,k as A,x as me,f as xe,n as pe,j as N,T as ue,d as ge,b8 as D}from"./index-DgSc1Qy8.js";import{l as he}from"./lodash-B4Ozcv0x.js";import{C as Y}from"./copyable-DpX04wZz.js";import{E as fe}from"./list-D1aevUOI.js";import{I as $}from"./info-metric-CNse3r66.js";import{I as _}from"./info-row-DOK2whMn.js";import{I as je}from"./info-row-group-BeUhWnnY.js";import{M as ye}from"./editor-BF5I0siU.js";import{M as be}from"./list-C521zE_7.js";import{P as ve}from"./actions-D9MHLBFH.js";import{A as _e}from"./add-price-CD-utowo.js";import{u as G,P as Ce}from"./product-select-0ScZE2e8.js";import{m as Q,n as T,g as we}from"./util-mDHAL0lx.js";import{I as V}from"./info-card-C1yxhxJG.js";import{E as ke}from"./edit-3HUAnaXW.js";import{S as w}from"./header-ivXuPt06.js";import{L as Pe,a as Se}from"./vendor-react-BPknnnEA.js";import{P as Ie}from"./actions-QPa-8lfB.js";import"./table-BRU4Enia.js";import"./form-BGm5NPDn.js";import"./actions-jxGAdGfb.js";import"./click-boundary-y8dVA_tr.js";import"./assign-CkV5Q2LP.js";import"./form-P4luyUpY.js";import"./collapse-CSrlJ0eG.js";import"./currency-select-DGS-62-L.js";import"./currency-GstdXsJf.js";import"./uploader-DRXDz_r0.js";import"./tax-code-select-CWhIIiXi.js";import"./collapse-BvbJGg1V.js";function Ae({data:r,onSelect:i,valid:o}){const{t:b,locale:j}=M(),{products:y}=G(),{settings:d}=L(),[p,n]=F.useState("empty"),g=t=>{t.target.value&&t.target.value!=="empty"&&(n(t.target.value),i(t.target.value))},a=q(d.paymentMethods,r?.default_price?.currency_id||"")||d.baseCurrency;return e.jsx(ee,{error:!o,sx:{width:"100%"},children:e.jsxs(te,{value:p,sx:{minWidth:300},size:"small",onChange:g,MenuProps:{style:{maxHeight:480}},children:[e.jsx(R,{value:"empty",children:e.jsx(m,{direction:"row",sx:{alignItems:"center"},children:e.jsx(x,{children:b("admin.product.find")})})}),y.filter(t=>t.id!==r.id&&Q(t,r)).map(t=>e.jsx(R,{value:t.id,children:e.jsx(V,{name:t.name,description:T(t,a,j),logo:t.images[0]})},t.id))]})})}function Ne({data:r,onChange:i}){const{locale:o,t:b}=M(),{settings:j}=L(),[y,d]=H({loading:!1}),{products:p}=G(),[n,g]=F.useState(!1),a=async()=>{try{d({loading:!0}),await S.put(`/api/products/${r.id}`,{cross_sell:{cross_sells_to_id:""}}).then(l=>l.data),d({loading:!1}),i()}catch(l){console.error(l),k.error(A(l)),d({loading:!1})}},t=async l=>{try{const v=p.find(P=>P.id===l);if(!v)throw new Error("no product found");if(!Q(v,r)){g(!0);return}d({loading:!0}),await S.put(`/api/products/${r.id}`,{cross_sell:{cross_sells_to_id:l}}).then(P=>P.data),d({loading:!1}),i()}catch(v){console.error(v),k.error(A(v)),d({loading:!1})}};if(y.loading)return e.jsx(O,{});const f=q(j.paymentMethods,r?.default_price?.currency_id||"")||j.baseCurrency;if(r.cross_sell?.cross_sells_to_id){const l=r.cross_sell.cross_sells_to;return e.jsxs(m,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(V,{name:l.name,description:T(l,f,o),logo:l.images[0]}),e.jsx(ie,{size:"small",sx:{ml:1},onClick:a,children:e.jsx(se,{color:"error",sx:{opacity:.75}})})]})}return e.jsxs(e.Fragment,{children:[e.jsx(Ae,{data:r,onSelect:t,valid:!n}),n&&e.jsx(x,{color:"error",children:b("admin.product.currencyNotAligned")})]})}function Me({data:r,onChange:i}){return e.jsx(Ce,{children:e.jsx(z,{container:!0,children:e.jsx(z,{size:{xs:12},children:e.jsx(Ne,{data:r,onChange:i})})})})}function Le({product:r,onChange:i}){const{t:o,locale:b}=M(),{settings:j}=L(),y=re(),d=me(window.location.href),p=[{label:o("admin.price.name"),name:"name",minWidth:180,options:{sort:!1,customBodyRenderLite:(n,g)=>{const a=r.prices[g],t=d.price_id===a.id&&d.currency_id,f=t?q(j.paymentMethods,d.currency_id||""):a.currency,l=y.palette.mode==="dark"?"#2e3035":"#FFF9C4";return e.jsx(Pe,{to:`/admin/products/${a.id}`,color:"text.primary",children:e.jsxs(m,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[a.locked&&e.jsx(U,{title:o("admin.price.locked"),children:e.jsx(ne,{sx:{color:"text.secondary"}})}),e.jsx(x,{component:"span",sx:{backgroundColor:t?l:"transparent",whiteSpace:"nowrap"},children:xe(a,f||a.currency,"",1,!0,b)}),e.jsx(x,{component:"span",children:a.id===r.default_price_id&&e.jsx(pe,{label:"default",color:"info",sx:{height:18}})})]})})}}},{label:o("common.id"),name:"id",options:{sort:!1,customBodyRender:n=>e.jsx(Y,{text:n})}},{label:o("common.createdAt"),name:"created_at",minWidth:120,options:{sort:!0,customBodyRender:n=>N(n)}},{label:o("common.updatedAt"),name:"updated_at",minWidth:120,options:{customBodyRender:n=>N(n)}},{label:o("admin.price.inventory"),name:"id",minWidth:120,options:{sort:!1,customBodyRenderLite:(n,g)=>{const a=r.prices[g];let t="";return a.nickname&&(t=`${a.nickname}:`),t+=`${a.quantity_available?o("admin.price.quantityAvailable.format",{num:a.quantity_available}):o("admin.price.quantityAvailable.noLimit")}`,t+=` / ${o("admin.price.quantitySold.format",{num:a.quantity_sold})}`,t+=` / ${a.quantity_limit_per_checkout?o("admin.price.quantityLimitPerCheckout.format",{num:a.quantity_limit_per_checkout}):o("admin.price.quantityLimitPerCheckout.noLimit")}`,t}}},{label:o("common.actions"),name:"id",width:100,align:"center",options:{sort:!1,customBodyRenderLite:(n,g)=>{const a=r.prices[g];return e.jsx(Ie,{data:a,onChange:i,setAsDefault:a.id===r.default_price_id,product:r})}}}];return e.jsx(ue,{toolbar:!1,footer:!1,data:r.prices,columns:p,options:{count:r.prices.length,page:0,rowsPerPage:20},emptyNodeText:o("empty.pricing")})}const qe=r=>S.get(`/api/products/${r}`).then(i=>i.data);function pt(r){const{t:i,locale:o}=M(),{isMobile:b}=ge(),j=Se(),{settings:y,setLivemode:d}=L(),[p,n]=H({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:g,error:a,data:t,runAsync:f}=de(()=>qe(r.id),{onSuccess:s=>{d(!!s.livemode)}});if(a)return e.jsx(E,{severity:"error",children:a.message});if(g||!t)return e.jsx(O,{});const l=s=>async u=>{try{n(h=>({loading:{...h.loading,[s]:!0}})),await S.put(`/api/products/${r.id}`,u).then(h=>h.data),k.success(i("common.saved")),D("product.updated"),f()}catch(h){console.error(h),k.error(A(h))}finally{n(h=>({loading:{...h.loading,[s]:!1}}))}},v=async s=>{try{n(u=>({loading:{...u.loading,price:!0}})),await S.post("/api/prices",{...s,product_id:r.id}),k.success(i("common.saved")),D("price.created"),f()}catch(u){throw console.error(u),k.error(A(u)),u}finally{n(u=>({loading:{...u.loading,price:!1}}))}},P=l("metadata"),X=l("product"),J=s=>{s==="remove"?j("/admin/products"):f()},K=t.locked||!he.isEmpty(t.prices)&&t.prices.some(s=>s.locked),W=()=>{n(s=>({editing:{...s.editing,metadata:!0}}))},Z=q(y.paymentMethods,t?.default_price?.currency_id)||y.baseCurrency;return e.jsxs(Ee,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(c,{children:[t.active===!1&&e.jsxs(E,{severity:"warning",children:[e.jsx(ae,{children:i("admin.product.archived")}),i("admin.product.archivedTip")]}),K&&e.jsx(E,{severity:"warning",sx:{mb:1},children:i("admin.product.locked")}),e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>we("/admin/products"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(oe,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:i("admin.products")})]}),e.jsx(ve,{data:t,onChange:J,variant:"normal"})]}),e.jsxs(c,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[t.images.length>0&&e.jsx(B,{src:t.images[0],alt:t.name,variant:"square",sx:{width:"52px",height:"52px"}}),e.jsxs(m,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(x,{variant:"h2",sx:{color:"text.primary"},children:t.name}),e.jsx(x,{variant:"subtitle1",sx:{color:"text.lighter"},children:T(t,Z,o)})]})]})}),e.jsxs(m,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx($,{label:i("common.id"),value:e.jsx(Y,{text:r.id,style:{marginLeft:4}}),divider:!0}),e.jsx($,{label:i("common.createdAt"),value:N(t.created_at),divider:!0})]})]}),e.jsx(C,{})]}),e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(c,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(c,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(w,{title:i("admin.details"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>n(s=>({editing:{...s.editing,product:!0}})),children:i("common.edit")})}),e.jsxs(je,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(_,{label:i("admin.product.name.label"),value:t.name}),e.jsx(_,{label:i("admin.product.description.label"),value:t.description}),e.jsx(_,{label:i("admin.product.statement_descriptor.label"),value:t.statement_descriptor}),e.jsx(_,{label:i("admin.product.unit_label.label"),value:t.unit_label}),e.jsx(_,{label:i("admin.product.features.label"),value:t.features.map(s=>s.name).join(",")}),e.jsx(_,{label:i("common.updatedAt"),value:N(t.updated_at)}),e.jsx(_,{label:i("admin.product.image.label"),value:t.images.length?e.jsx(B,{src:t.images[0],alt:t.name,variant:"square",sx:{width:"160px",height:"160px"}}):e.jsx(x,{variant:"body2",sx:{color:"text.lighter"},children:i("empty.image")})}),p.editing.product&&e.jsx(ke,{product:t,loading:p.loading.product,onSave:X,onCancel:()=>n(s=>({editing:{...s.editing,product:!1}}))})]})]}),e.jsx(C,{}),e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("admin.product.pricing"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>n(s=>({adding:{...s.adding,price:!0}})),children:i("admin.price.add")})}),e.jsxs(c,{className:"section-body",children:[e.jsx(Le,{product:t,onChange:f}),p.adding.price&&e.jsx(_e,{loading:p.loading.price,onSave:v,productType:t.type,onCancel:()=>n(s=>({adding:{...s.adding,price:!1}}))})]})]}),e.jsx(C,{}),t.type==="service"&&e.jsxs(e.Fragment,{children:[e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("admin.product.vendorConfig.title"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>n(s=>({editing:{...s.editing,product:!0}})),children:i("common.edit")})}),e.jsx(c,{className:"section-body",children:t.vendor_config&&t.vendor_config.length>0?e.jsxs(m,{spacing:2,children:[(()=>{const s=t.vendor_config.filter(u=>u.commission_type==="percentage").reduce((u,h)=>u+(h.commission_rate||0),0);return e.jsx(x,{variant:"body2",sx:{color:"text.secondary",mb:1},children:i("admin.product.vendorConfig.totalCommission",{total:s.toFixed(0)})})})(),t.vendor_config.map(s=>e.jsx(c,{sx:{p:2,border:"1px solid",borderColor:"divider",borderRadius:1,backgroundColor:"background.paper",maxWidth:"600px"},children:e.jsxs(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(c,{children:[e.jsx(x,{variant:"body1",sx:{color:"text.primary",fontWeight:500},children:s.name||s.vendor_key||s.vendor_id}),s.description&&e.jsx(x,{variant:"body2",sx:{color:"text.secondary",mt:.5},children:s.description})]}),e.jsxs(m,{direction:"row",spacing:3,sx:{alignItems:"center"},children:[e.jsx(x,{variant:"body2",sx:{color:"text.secondary"},children:s.commission_type==="percentage"?i("admin.vendor.commission"):i("admin.vendor.fixedAmount")}),e.jsxs(x,{variant:"body1",sx:{color:"text.primary",fontWeight:600},children:[s.commission_rate,s.commission_type==="percentage"?"%":""]})]})]})},`vendor-${s.vendor_id}`))]}):e.jsx(x,{variant:"body2",sx:{color:"text.secondary",textAlign:"center",py:2},children:i("admin.product.vendorConfig.empty")})})]}),e.jsx(C,{})]}),e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("admin.events.title")}),e.jsx(c,{className:"section-body",children:e.jsx(fe,{features:{toolbar:!1},object_id:[t.id,...t.prices.map(s=>s.id)].join(",")})})]})]}),b&&e.jsx(C,{}),e.jsxs(c,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(c,{className:"section",children:[e.jsx(w,{title:e.jsxs(m,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(x,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},children:i("admin.product.cross_sell.title")}),e.jsx(U,{title:i("admin.product.currencyNotAligned"),children:e.jsx(ce,{sx:{color:"text.lighter"},fontSize:"small"})})]})}),e.jsx(c,{className:"section-body",children:e.jsx(Me,{data:t,onChange:f})})]}),e.jsx(C,{}),e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("common.metadata.label"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:p.editing.metadata,onClick:W,children:i("common.edit")})}),e.jsxs(c,{className:"section-body",children:[e.jsx(be,{data:t.metadata,handleEditMetadata:W}),p.editing.metadata&&e.jsx(ye,{data:t,loading:p.loading.metadata,onSave:P,onCancel:()=>n(s=>({editing:{...s.editing,metadata:!1}}))})]})]})]})]})]})}const Ee=le(m)``;export{pt as default};
|
|
1
|
+
import{r as F,j as e,aQ as ee,aT as te,ad as R,a3 as m,q as x,$ as z,w as O,I as ie,ci as se,u as re,O as U,bX as ne,A as E,B as c,z as ae,bv as oe,N as B,Y as C,x as I,be as ce,bf as le}from"./vendor-mui-BXZut9Pz.js";import{V as M,Y as H,Z as k,P as de}from"./vendor-blocklet-DcLR2Cyf.js";import{a as L,Y as q,e as S,k as A,x as me,f as xe,n as pe,j as N,T as ue,d as ge,b8 as D}from"./index-BarN7DfU.js";import{l as he}from"./lodash-B4Ozcv0x.js";import{C as Y}from"./copyable-QrCyyiou.js";import{E as fe}from"./list-DaK9287Y.js";import{I as $}from"./info-metric-Dl4ZDm0Z.js";import{I as _}from"./info-row-jI0h_hv4.js";import{I as je}from"./info-row-group-CFuMWJf1.js";import{M as ye}from"./editor-AmthipP2.js";import{M as be}from"./list-CkHExntK.js";import{P as ve}from"./actions-CSpJGOX7.js";import{A as _e}from"./add-price-BpnICuHO.js";import{u as G,P as Ce}from"./product-select-ChEyoJqJ.js";import{m as Q,n as T,g as we}from"./util-DxXTXkeY.js";import{I as V}from"./info-card-BvIMFQo5.js";import{E as ke}from"./edit-Bkj-OTJh.js";import{S as w}from"./header-ivXuPt06.js";import{L as Pe,a as Se}from"./vendor-react-BPknnnEA.js";import{P as Ie}from"./actions-BD9BAp3M.js";import"./table-BrtHemkA.js";import"./form-CAPjlw7l.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./assign-0vMUDW_C.js";import"./form-cX026J4G.js";import"./collapse-CSrlJ0eG.js";import"./currency-select-B4ieQBvv.js";import"./currency-GstdXsJf.js";import"./uploader-CsQNHG4I.js";import"./tax-code-select-TS07I0rB.js";import"./collapse-BvbJGg1V.js";function Ae({data:r,onSelect:i,valid:o}){const{t:b,locale:j}=M(),{products:y}=G(),{settings:d}=L(),[p,n]=F.useState("empty"),g=t=>{t.target.value&&t.target.value!=="empty"&&(n(t.target.value),i(t.target.value))},a=q(d.paymentMethods,r?.default_price?.currency_id||"")||d.baseCurrency;return e.jsx(ee,{error:!o,sx:{width:"100%"},children:e.jsxs(te,{value:p,sx:{minWidth:300},size:"small",onChange:g,MenuProps:{style:{maxHeight:480}},children:[e.jsx(R,{value:"empty",children:e.jsx(m,{direction:"row",sx:{alignItems:"center"},children:e.jsx(x,{children:b("admin.product.find")})})}),y.filter(t=>t.id!==r.id&&Q(t,r)).map(t=>e.jsx(R,{value:t.id,children:e.jsx(V,{name:t.name,description:T(t,a,j),logo:t.images[0]})},t.id))]})})}function Ne({data:r,onChange:i}){const{locale:o,t:b}=M(),{settings:j}=L(),[y,d]=H({loading:!1}),{products:p}=G(),[n,g]=F.useState(!1),a=async()=>{try{d({loading:!0}),await S.put(`/api/products/${r.id}`,{cross_sell:{cross_sells_to_id:""}}).then(l=>l.data),d({loading:!1}),i()}catch(l){console.error(l),k.error(A(l)),d({loading:!1})}},t=async l=>{try{const v=p.find(P=>P.id===l);if(!v)throw new Error("no product found");if(!Q(v,r)){g(!0);return}d({loading:!0}),await S.put(`/api/products/${r.id}`,{cross_sell:{cross_sells_to_id:l}}).then(P=>P.data),d({loading:!1}),i()}catch(v){console.error(v),k.error(A(v)),d({loading:!1})}};if(y.loading)return e.jsx(O,{});const f=q(j.paymentMethods,r?.default_price?.currency_id||"")||j.baseCurrency;if(r.cross_sell?.cross_sells_to_id){const l=r.cross_sell.cross_sells_to;return e.jsxs(m,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(V,{name:l.name,description:T(l,f,o),logo:l.images[0]}),e.jsx(ie,{size:"small",sx:{ml:1},onClick:a,children:e.jsx(se,{color:"error",sx:{opacity:.75}})})]})}return e.jsxs(e.Fragment,{children:[e.jsx(Ae,{data:r,onSelect:t,valid:!n}),n&&e.jsx(x,{color:"error",children:b("admin.product.currencyNotAligned")})]})}function Me({data:r,onChange:i}){return e.jsx(Ce,{children:e.jsx(z,{container:!0,children:e.jsx(z,{size:{xs:12},children:e.jsx(Ne,{data:r,onChange:i})})})})}function Le({product:r,onChange:i}){const{t:o,locale:b}=M(),{settings:j}=L(),y=re(),d=me(window.location.href),p=[{label:o("admin.price.name"),name:"name",minWidth:180,options:{sort:!1,customBodyRenderLite:(n,g)=>{const a=r.prices[g],t=d.price_id===a.id&&d.currency_id,f=t?q(j.paymentMethods,d.currency_id||""):a.currency,l=y.palette.mode==="dark"?"#2e3035":"#FFF9C4";return e.jsx(Pe,{to:`/admin/products/${a.id}`,color:"text.primary",children:e.jsxs(m,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[a.locked&&e.jsx(U,{title:o("admin.price.locked"),children:e.jsx(ne,{sx:{color:"text.secondary"}})}),e.jsx(x,{component:"span",sx:{backgroundColor:t?l:"transparent",whiteSpace:"nowrap"},children:xe(a,f||a.currency,"",1,!0,b)}),e.jsx(x,{component:"span",children:a.id===r.default_price_id&&e.jsx(pe,{label:"default",color:"info",sx:{height:18}})})]})})}}},{label:o("common.id"),name:"id",options:{sort:!1,customBodyRender:n=>e.jsx(Y,{text:n})}},{label:o("common.createdAt"),name:"created_at",minWidth:120,options:{sort:!0,customBodyRender:n=>N(n)}},{label:o("common.updatedAt"),name:"updated_at",minWidth:120,options:{customBodyRender:n=>N(n)}},{label:o("admin.price.inventory"),name:"id",minWidth:120,options:{sort:!1,customBodyRenderLite:(n,g)=>{const a=r.prices[g];let t="";return a.nickname&&(t=`${a.nickname}:`),t+=`${a.quantity_available?o("admin.price.quantityAvailable.format",{num:a.quantity_available}):o("admin.price.quantityAvailable.noLimit")}`,t+=` / ${o("admin.price.quantitySold.format",{num:a.quantity_sold})}`,t+=` / ${a.quantity_limit_per_checkout?o("admin.price.quantityLimitPerCheckout.format",{num:a.quantity_limit_per_checkout}):o("admin.price.quantityLimitPerCheckout.noLimit")}`,t}}},{label:o("common.actions"),name:"id",width:100,align:"center",options:{sort:!1,customBodyRenderLite:(n,g)=>{const a=r.prices[g];return e.jsx(Ie,{data:a,onChange:i,setAsDefault:a.id===r.default_price_id,product:r})}}}];return e.jsx(ue,{toolbar:!1,footer:!1,data:r.prices,columns:p,options:{count:r.prices.length,page:0,rowsPerPage:20},emptyNodeText:o("empty.pricing")})}const qe=r=>S.get(`/api/products/${r}`).then(i=>i.data);function pt(r){const{t:i,locale:o}=M(),{isMobile:b}=ge(),j=Se(),{settings:y,setLivemode:d}=L(),[p,n]=H({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:g,error:a,data:t,runAsync:f}=de(()=>qe(r.id),{onSuccess:s=>{d(!!s.livemode)}});if(a)return e.jsx(E,{severity:"error",children:a.message});if(g||!t)return e.jsx(O,{});const l=s=>async u=>{try{n(h=>({loading:{...h.loading,[s]:!0}})),await S.put(`/api/products/${r.id}`,u).then(h=>h.data),k.success(i("common.saved")),D("product.updated"),f()}catch(h){console.error(h),k.error(A(h))}finally{n(h=>({loading:{...h.loading,[s]:!1}}))}},v=async s=>{try{n(u=>({loading:{...u.loading,price:!0}})),await S.post("/api/prices",{...s,product_id:r.id}),k.success(i("common.saved")),D("price.created"),f()}catch(u){throw console.error(u),k.error(A(u)),u}finally{n(u=>({loading:{...u.loading,price:!1}}))}},P=l("metadata"),X=l("product"),Z=s=>{s==="remove"?j("/admin/products"):f()},J=t.locked||!he.isEmpty(t.prices)&&t.prices.some(s=>s.locked),W=()=>{n(s=>({editing:{...s.editing,metadata:!0}}))},K=q(y.paymentMethods,t?.default_price?.currency_id)||y.baseCurrency;return e.jsxs(Ee,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(c,{children:[t.active===!1&&e.jsxs(E,{severity:"warning",children:[e.jsx(ae,{children:i("admin.product.archived")}),i("admin.product.archivedTip")]}),J&&e.jsx(E,{severity:"warning",sx:{mb:1},children:i("admin.product.locked")}),e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>we("/admin/products"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(oe,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:i("admin.products")})]}),e.jsx(ve,{data:t,onChange:Z,variant:"normal"})]}),e.jsxs(c,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[t.images.length>0&&e.jsx(B,{src:t.images[0],alt:t.name,variant:"square",sx:{width:"52px",height:"52px"}}),e.jsxs(m,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(x,{variant:"h2",sx:{color:"text.primary"},children:t.name}),e.jsx(x,{variant:"subtitle1",sx:{color:"text.lighter"},children:T(t,K,o)})]})]})}),e.jsxs(m,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx($,{label:i("common.id"),value:e.jsx(Y,{text:r.id,style:{marginLeft:4}}),divider:!0}),e.jsx($,{label:i("common.createdAt"),value:N(t.created_at),divider:!0})]})]}),e.jsx(C,{})]}),e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(c,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(c,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(w,{title:i("admin.details"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>n(s=>({editing:{...s.editing,product:!0}})),children:i("common.edit")})}),e.jsxs(je,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(_,{label:i("admin.product.name.label"),value:t.name}),e.jsx(_,{label:i("admin.product.description.label"),value:t.description}),e.jsx(_,{label:i("admin.product.statement_descriptor.label"),value:t.statement_descriptor}),e.jsx(_,{label:i("admin.product.unit_label.label"),value:t.unit_label}),e.jsx(_,{label:i("admin.product.features.label"),value:t.features.map(s=>s.name).join(",")}),e.jsx(_,{label:i("common.updatedAt"),value:N(t.updated_at)}),e.jsx(_,{label:i("admin.product.image.label"),value:t.images.length?e.jsx(B,{src:t.images[0],alt:t.name,variant:"square",sx:{width:"160px",height:"160px"}}):e.jsx(x,{variant:"body2",sx:{color:"text.lighter"},children:i("empty.image")})}),p.editing.product&&e.jsx(ke,{product:t,loading:p.loading.product,onSave:X,onCancel:()=>n(s=>({editing:{...s.editing,product:!1}}))})]})]}),e.jsx(C,{}),e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("admin.product.pricing"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>n(s=>({adding:{...s.adding,price:!0}})),children:i("admin.price.add")})}),e.jsxs(c,{className:"section-body",children:[e.jsx(Le,{product:t,onChange:f}),p.adding.price&&e.jsx(_e,{loading:p.loading.price,onSave:v,productType:t.type,onCancel:()=>n(s=>({adding:{...s.adding,price:!1}}))})]})]}),e.jsx(C,{}),t.type==="service"&&e.jsxs(e.Fragment,{children:[e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("admin.product.vendorConfig.title"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>n(s=>({editing:{...s.editing,product:!0}})),children:i("common.edit")})}),e.jsx(c,{className:"section-body",children:t.vendor_config&&t.vendor_config.length>0?e.jsxs(m,{spacing:2,children:[(()=>{const s=t.vendor_config.filter(u=>u.commission_type==="percentage").reduce((u,h)=>u+(h.commission_rate||0),0);return e.jsx(x,{variant:"body2",sx:{color:"text.secondary",mb:1},children:i("admin.product.vendorConfig.totalCommission",{total:s.toFixed(0)})})})(),t.vendor_config.map(s=>e.jsx(c,{sx:{p:2,border:"1px solid",borderColor:"divider",borderRadius:1,backgroundColor:"background.paper",maxWidth:"600px"},children:e.jsxs(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(c,{children:[e.jsx(x,{variant:"body1",sx:{color:"text.primary",fontWeight:500},children:s.name||s.vendor_key||s.vendor_id}),s.description&&e.jsx(x,{variant:"body2",sx:{color:"text.secondary",mt:.5},children:s.description})]}),e.jsxs(m,{direction:"row",spacing:3,sx:{alignItems:"center"},children:[e.jsx(x,{variant:"body2",sx:{color:"text.secondary"},children:s.commission_type==="percentage"?i("admin.vendor.commission"):i("admin.vendor.fixedAmount")}),e.jsxs(x,{variant:"body1",sx:{color:"text.primary",fontWeight:600},children:[s.commission_rate,s.commission_type==="percentage"?"%":""]})]})]})},`vendor-${s.vendor_id}`))]}):e.jsx(x,{variant:"body2",sx:{color:"text.secondary",textAlign:"center",py:2},children:i("admin.product.vendorConfig.empty")})})]}),e.jsx(C,{})]}),e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("admin.events.title")}),e.jsx(c,{className:"section-body",children:e.jsx(fe,{features:{toolbar:!1},object_id:[t.id,...t.prices.map(s=>s.id)].join(",")})})]})]}),b&&e.jsx(C,{}),e.jsxs(c,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(c,{className:"section",children:[e.jsx(w,{title:e.jsxs(m,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(x,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},children:i("admin.product.cross_sell.title")}),e.jsx(U,{title:i("admin.product.currencyNotAligned"),children:e.jsx(ce,{sx:{color:"text.lighter"},fontSize:"small"})})]})}),e.jsx(c,{className:"section-body",children:e.jsx(Me,{data:t,onChange:f})})]}),e.jsx(C,{}),e.jsxs(c,{className:"section",children:[e.jsx(w,{title:i("common.metadata.label"),children:e.jsx(I,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:p.editing.metadata,onClick:W,children:i("common.edit")})}),e.jsxs(c,{className:"section-body",children:[e.jsx(be,{data:t.metadata,handleEditMetadata:W}),p.editing.metadata&&e.jsx(ye,{data:t,loading:p.loading.metadata,onSave:P,onCancel:()=>n(s=>({editing:{...s.editing,metadata:!1}}))})]})]})]})]})]})}const Ee=le(m)``;export{pt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A,w as R,B as n,a3 as i,bv as T,q as $,N as E,Y as d,O as B,be as L,x as
|
|
1
|
+
import{j as e,A,w as R,B as n,a3 as i,bv as T,q as $,N as E,Y as d,O as B,be as L,x as W,bf as z}from"./vendor-mui-BXZut9Pz.js";import{V as O,Y as H,P as q,Z as _}from"./vendor-blocklet-DcLR2Cyf.js";import{d as G,i as P,a5 as U,n as I,bd as w,j,p as F,e as M,k as Y}from"./index-BarN7DfU.js";import{T as J}from"./gas-nyR96dB0.js";import{L as u}from"./vendor-react-BPknnnEA.js";import{l as V}from"./lodash-B4Ozcv0x.js";import{C as Z}from"./copyable-QrCyyiou.js";import{C as K}from"./link-CmPoIweR.js";import{E as Q}from"./list-DaK9287Y.js";import{I as C}from"./info-metric-Dl4ZDm0Z.js";import{I as s}from"./info-row-jI0h_hv4.js";import{M as X}from"./editor-AmthipP2.js";import{M as ee}from"./list-CkHExntK.js";import{R as te}from"./actions-0iWP2mcx.js";import{S as x}from"./header-ivXuPt06.js";import{g as ae}from"./util-DxXTXkeY.js";import{I as se}from"./info-row-group-CFuMWJf1.js";import"./table-BrtHemkA.js";import"./form-CAPjlw7l.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";const ne=c=>M.get(`/api/refunds/${c}`).then(a=>a.data),o="column",r="flex-start";function Se(c){const{t:a}=O(),{isMobile:k}=G(),[f,p]=H({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:S,error:h,data:t,runAsync:y}=q(()=>ne(c.id));if(h)return e.jsx(A,{severity:"error",children:h.message});if(S||!t)return e.jsx(R,{});const N=(m=>async D=>{try{p(l=>({loading:{...l.loading,[m]:!0}})),await M.put(`/api/refunds/${c.id}`,D).then(l=>l.data),_.success(a("common.saved")),y()}catch(l){console.error(l),_.error(Y(l))}finally{p(l=>({loading:{...l.loading,[m]:!1}}))}})("metadata"),g=t.paymentCurrency,b=[P(t?.amount,g.decimal),g.symbol].join(" "),v=()=>{p(m=>({editing:{...m.editing,metadata:!0}}))};return e.jsxs(ie,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(n,{children:[e.jsxs(i,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(i,{direction:"row",onClick:()=>ae("/admin/payments/refunds"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx($,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.refunds")})]}),e.jsx(te,{data:t,variant:"normal",onChange:()=>y()})]}),e.jsxs(n,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(i,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(i,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(E,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(i,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(U,{amount:b,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(Z,{text:c.id})]})]})}),e.jsxs(i,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(C,{label:a("common.status"),value:e.jsx(I,{label:t.status,color:w(t.status)}),divider:!0}),e.jsx(C,{label:a("common.customer"),value:e.jsx(K,{customer:t.customer})})]})]}),e.jsx(d,{})]}),e.jsxs(i,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(n,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(n,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(x,{title:a("admin.details")}),e.jsxs(se,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(s,{label:a("common.status"),value:e.jsxs(i,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(I,{label:t.status,color:w(t.status)}),t.last_attempt_error&&t.status!=="canceled"&&e.jsx(B,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify({...t.last_attempt_error,next_attempt:t.next_attempt?j(t.next_attempt*1e3):"-",attempt_count:t.attempt_count,type:V.startCase(t.last_attempt_error?.type)},null,2)}),children:e.jsx(L,{fontSize:"small",color:"error"})})]})}),e.jsx(s,{label:a("common.amount"),value:b}),e.jsx(s,{label:a("common.type"),value:a(`refund.type.${t.type}`)}),e.jsx(s,{label:a("common.createdAt"),value:j(t.created_at)}),e.jsx(s,{label:a("common.description"),value:t.description}),e.jsx(s,{label:a("common.updatedAt"),value:j(t.updated_at)})]})]}),e.jsx(d,{}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.events.title")}),e.jsx(n,{className:"section-body",children:e.jsx(Q,{features:{toolbar:!1},object_id:t.id})})]})]}),k&&e.jsx(d,{}),e.jsxs(n,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[t.paymentMethod&&e.jsxs(e.Fragment,{children:[e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.paymentMethod._name")}),e.jsxs(i,{children:[e.jsx(s,{label:a("common.id"),value:t.paymentMethod.id,direction:o,alignItems:r}),e.jsx(s,{label:a("admin.paymentMethod.type"),value:t.paymentMethod.type,direction:o,alignItems:r}),e.jsx(s,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod.name})`,direction:o,alignItems:r}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(s,{label:a("common.txGas"),value:e.jsx(J,{details:t.payment_details,method:t.paymentMethod}),direction:o,alignItems:r}),e.jsx(s,{label:a("common.txHash"),value:e.jsx(F,{details:t.payment_details,method:t.paymentMethod}),direction:o,alignItems:r})]})]}),e.jsx(d,{})]}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.connections")}),e.jsxs(i,{children:[e.jsx(s,{label:a("admin.subscription.name"),value:t.subscription?e.jsx(u,{to:`/admin/billing/${t.subscription.id}`,children:t.subscription.id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.invoice.name"),value:t.invoice_id?e.jsx(u,{to:`/admin/billing/${t.invoice_id}`,children:t.invoice_id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.customers"),value:t.customer_id?e.jsx(u,{to:`/admin/customers/${t.customer_id}`,children:t.customer_id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.payments"),value:t.payment_intent_id?e.jsx(u,{to:`/admin/payments/${t.payment_intent_id}`,children:t.payment_intent_id}):"",direction:o,alignItems:r})]})]}),e.jsx(d,{}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("common.metadata.label"),children:e.jsx(W,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:f.editing.metadata,onClick:v,children:a("common.edit")})}),e.jsxs(n,{className:"section-body",children:[e.jsx(ee,{data:t.metadata,handleEditMetadata:v}),f.editing.metadata&&e.jsx(X,{data:t,loading:f.loading.metadata,onSave:N,onCancel:()=>p(m=>({editing:{...m.editing,metadata:!1}}))})]})]})]})]})]})}const ie=z(i)``;export{Se as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,B as x,a3 as w,ck as re,a2 as F,N as se,q as A,x as T,r as M,cD as ue,bp as X,bs as fe,bt as te,bg as pe,a1 as xe,aF as ge,A as W,aN as he,aM as ae,w as ye,z as ve,bv as je,Y as $,cA as be,bf as Ce}from"./vendor-mui-BXZut9Pz.js";import{V as G,Y as J,$ as _e,B as y,Z as Y,O as De,P as ie,H as ne}from"./vendor-blocklet-DcLR2Cyf.js";import{d as Q,aW as H,N as oe,e as _,k as Z,a as de,j as U,T as le,Y as we,n as ke,h as Se,F as Me}from"./index-BarN7DfU.js";import{C as Ee}from"./copyable-QrCyyiou.js";import{I as K}from"./info-metric-Dl4ZDm0Z.js";import{I as z}from"./info-row-jI0h_hv4.js";import{I as Te}from"./info-row-group-CFuMWJf1.js";import{M as Ie}from"./editor-AmthipP2.js";import{M as Ae}from"./list-CkHExntK.js";import{M as Pe}from"./actions-BSNy5bOd.js";import{S as B}from"./header-ivXuPt06.js";import{n as Ye,g as Le}from"./util-DxXTXkeY.js";import{L as R,a as Oe}from"./vendor-react-BPknnnEA.js";import{R as ze,A as Re,C as Ne,a as $e,D as Be,g as Fe}from"./overview-Cxc6WKba.js";import{C as He}from"./link-CmPoIweR.js";import{X as We,Y as Ue,T as Ge}from"./generateCategoricalChart-BadryV3H.js";import Ve from"./create-ke4FrPx1.js";import{I as qe}from"./info-card-BvIMFQo5.js";import{P as Ke}from"./actions-CSpJGOX7.js";import{M as Xe}from"./form-B5WW-lS5.js";import{D as Ze}from"./drawer-form-DspWWj3x.js";import"./lodash-B4Ozcv0x.js";import"./form-CAPjlw7l.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./currency-select-B4ieQBvv.js";import"./currency-GstdXsJf.js";import"./collapse-CSrlJ0eG.js";import"./form-cX026J4G.js";import"./product-select-ChEyoJqJ.js";import"./uploader-CsQNHG4I.js";import"./tax-code-select-TS07I0rB.js";import"./collapse-BvbJGg1V.js";import"./assign-0vMUDW_C.js";import"./edit-Bkj-OTJh.js";const Je=c=>_.post("/api/meter-events",{event_name:c.event_name,payload:{customer_id:c.customer_id,value:c.value,subscription_id:c.subscription_id||void 0},timestamp:c.timestamp,identifier:`manual_${Date.now()}`,metadata:{source:"manual",created_by:"admin"},source_data:[{key:"origin",label:"created_by",value:"Admin",type:"text"}]}).then(a=>a.data);function Qe({open:c,onClose:a,meterId:d,customers:r,onSuccess:C}){const{t:n}=G(),{isMobile:m}=Q("md"),[i,g]=J({loading:!1,form:{customer_id:"",value:"",subscription_id:"",timestamp:new Date}}),k=l=>l.name||l.email||l.did||l.id,s=()=>{g({form:{customer_id:"",value:"",subscription_id:"",timestamp:new Date}}),a()},o=async()=>{if(!i.form.customer_id||!i.form.value){Y.error(n("admin.meterEvent.add.validation"));return}g({loading:!0});try{const p=(await _.get(`/api/meters/${d}`)).data;await Je({event_name:p.event_name,customer_id:i.form.customer_id,value:i.form.value,subscription_id:i.form.subscription_id,timestamp:y(i.form.timestamp).unix()}),Y.success(n("admin.meterEvent.add.success")),s(),C()}catch(l){console.error("Failed to add usage:",l),Y.error(Z(l))}finally{g({loading:!1})}};return e.jsx(_e,{open:c,onClose:s,maxWidth:"sm",fullWidth:!0,fullScreen:m,title:n("admin.meterEvent.add.title"),actions:e.jsxs(e.Fragment,{children:[e.jsx(T,{onClick:s,variant:"outlined",disabled:i.loading,children:n("common.cancel")}),e.jsx(T,{onClick:o,variant:"contained",disabled:i.loading,children:n("admin.meterEvent.add.submit")})]}),children:e.jsx(x,{children:e.jsxs(w,{spacing:3,children:[e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.customerId")}),e.jsx(re,{options:r,getOptionLabel:k,value:r.find(l=>l.id===i.form.customer_id)||null,onChange:(l,p)=>g({form:{...i.form,customer_id:p?.id||""}}),renderOption:(l,p)=>e.jsxs(x,{component:"li",...l,sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(se,{src:oe(p.did,p?.updated_at?new Date(p.updated_at).toISOString():void 0,24),sx:{width:24,height:24},alt:k(p)}),k(p)]}),renderInput:l=>e.jsx(F,{...l,placeholder:n("admin.meterEvent.add.customerIdPlaceholder"),fullWidth:!0})})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.value")}),e.jsx(F,{type:"number",fullWidth:!0,value:i.form.value,onChange:l=>g({form:{...i.form,value:l.target.value}}),placeholder:n("admin.meterEvent.add.valuePlaceholder")})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.subscriptionId")}),e.jsx(F,{fullWidth:!0,value:i.form.subscription_id,onChange:l=>g({form:{...i.form,subscription_id:l.target.value}}),placeholder:n("admin.meterEvent.add.subscriptionIdPlaceholder")}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary",mt:.5,display:"block"},children:n("admin.meterEvent.add.subscriptionIdHint")})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.timestamp")}),e.jsx(F,{type:"datetime-local",fullWidth:!0,value:y(i.form.timestamp).format("YYYY-MM-DDTHH:mm"),onChange:l=>g({form:{...i.form,timestamp:new Date(l.target.value)}}),InputLabelProps:{shrink:!0}}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary",mt:.5,display:"block"},children:n("admin.meterEvent.add.timestampHint")})]})]})})})}const et=(c,a={})=>{const d=new URLSearchParams;return d.append("meter_id",c),a.page!==void 0&&d.append("page",String(a.page)),a.pageSize!==void 0&&d.append("pageSize",String(a.pageSize)),a.start!==void 0&&d.append("start",String(a.start)),a.end!==void 0&&d.append("end",String(a.end)),a.customer_id&&d.append("customer_id",a.customer_id),_.get(`/api/meter-events?${d.toString()}`).then(r=>r.data)},tt=(c,a,d,r,C)=>{const n=new URLSearchParams;return n.append("meter_id",c),n.append("start",a.toString()),n.append("end",d.toString()),r&&n.append("customer_id",r),C&&n.append("granularity",C),_.get(`/api/meter-events/stats?${n.toString()}`).then(m=>m.data)},at=()=>_.get("/api/customers?limit=100").then(c=>c.data),nt=(c,a,d)=>{const r=[],C=y(c),n=y(a),m=y();if(d==="hour"){let i=C.startOf("hour");const g=n.isAfter(m)?m:n;for(;i.isBefore(g)||i.isSame(g,"hour");)r.push({date:i.format("HH:mm"),fullDate:i.format("YYYY-MM-DD HH:mm"),timestamp:i.unix().toString(),event_count:0,total_value:0}),i=i.add(1,"hour")}else{let i=C.startOf("day");const g=n.isAfter(m,"day")?m.startOf("day"):n;for(;i.isBefore(g)||i.isSame(g,"day");)r.push({date:i.format("MM/DD"),fullDate:i.format("YYYY-MM-DD"),timestamp:i.unix().toString(),event_count:0,total_value:0}),i=i.add(1,"day")}return r};function rt({meterId:c,paymentCurrency:a}){const{t:d}=G(),{isMobile:r}=Q("md"),{livemode:C}=de(),n=y().endOf("day").toDate(),[m,i]=De(`meter-events-${c}`,{defaultValue:{pageSize:10,page:1,start:y().subtract(30,"day").startOf("day").unix(),end:y().endOf("day").unix()}}),{data:g={list:[],count:0},refresh:k,loading:s}=ie(()=>et(c,m),{refreshDeps:[m]}),[o,l]=J({stats:[],customers:[],statsLoading:!1,anchorEl:null,startDate:y().subtract(30,"day").startOf("day").toDate(),endDate:n,selectedCustomer:null,chartType:"event_count",addUsageDialog:!1}),p=M.useMemo(()=>{const t=y(o.startDate);return y(o.endDate).diff(t,"day")===0?"hour":"day"},[o.startDate,o.endDate]),P=M.useMemo(()=>{if(o.statsLoading)return[];const t=nt(o.startDate,o.endDate,p);if(!o.stats.length)return t;const u=new Map;return o.stats.forEach(f=>{let D,q;p==="hour"?(D=y(f.timestamp).format("HH:mm"),q=y(f.timestamp).format("YYYY-MM-DD HH:mm")):(D=y(f.timestamp).format("MM/DD"),q=y(f.timestamp).format("YYYY-MM-DD")),u.set(D,{...f,date:D,fullDate:q})}),t.map(f=>u.get(f.date)||f)},[o.stats,o.statsLoading,o.startDate,o.endDate,p]),I=async()=>{l({statsLoading:!0});try{const t=await tt(c,y(o.startDate).unix(),y(o.endDate).unix(),o.selectedCustomer?.id,p);l({stats:t.list,statsLoading:!1})}catch(t){console.error("Failed to fetch stats:",t),l({statsLoading:!1})}},N=async()=>{try{const t=await at();if(l({customers:t.list}),m.customer_id&&t.list.length>0){const u=t.list.find(f=>f.id===m.customer_id);u&&l({selectedCustomer:u})}}catch(t){console.error("Failed to fetch customers:",t)}};M.useEffect(()=>{N()},[c]),M.useEffect(()=>{m?.start&&m?.end&&l({startDate:y.unix(m.start).toDate(),endDate:y.unix(m.end).toDate()})},[m?.start,m?.end]),M.useEffect(()=>{I()},[o.startDate,o.endDate,o.selectedCustomer,p]);const h=({page:t,rowsPerPage:u})=>{m.pageSize!==u?i(f=>({...f,pageSize:u,page:1})):m.page!==t+1&&i(f=>({...f,page:t+1}))},v=t=>{o.anchorEl?l({anchorEl:null}):l({anchorEl:t.currentTarget})},L=t=>{const u=y(t.startDate).startOf("day").unix(),f=y(t.endDate).endOf("day").unix();i(D=>({...D,start:u,end:f,page:1})),l({startDate:t.startDate,endDate:y(t.endDate).endOf("day").toDate(),anchorEl:null})},S=(t,u)=>{u!==null&&l({chartType:u})},O=t=>{i(u=>({...u,customer_id:t?.id,page:1})),l({selectedCustomer:t})},E=t=>t.name||t.email||t.did||t.id,b=()=>{l({addUsageDialog:!0})},j=()=>{l({addUsageDialog:!1})},V=()=>{k(),I()},ee=!!o.anchorEl,ce=ee?"date-range-picker-popover":void 0,me=[{label:d("admin.meter.events.value"),name:"value",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];if(!f)return null;const D=ne(f.payload.value||"0",a.decimal);return e.jsx(R,{to:`/admin/billing/${f.id}`,children:`${D} ${a.symbol}`})}}},{label:d("admin.meter.events.customer"),name:"customer",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];return!f||!f?.customer?"-":e.jsx(He,{customer:f.customer,size:"small"})}}},{label:d("admin.meter.events.subscription"),name:"subscription",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];if(!f)return"-";const D=f.payload?.subscription_id;return D?e.jsx(R,{to:`/admin/billing/${D}`,children:e.jsx(A,{variant:"body2",sx:{color:"text.link"},children:f?.subscription?.description||D})}):"-"}}},{label:d("admin.meter.events.reportTime"),name:"created_at",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];return e.jsx(R,{to:`/admin/billing/${f?.id}`,children:f?U(f.created_at):"-"})}}}];return e.jsxs(x,{children:[e.jsxs(x,{sx:{mb:3},children:[e.jsxs(w,{direction:r?"column":"row",spacing:2,sx:{alignItems:r?"stretch":"center",flexWrap:"wrap"},children:[e.jsxs(T,{variant:"outlined",startIcon:e.jsx(ue,{}),onClick:v,size:"large",sx:{minWidth:r?"100%":200,justifyContent:r?"flex-start":"center",color:"text.secondary",borderColor:"grey.300","&:hover":{borderColor:"primary.main"},backgroundColor:"grey.50"},children:[y(o.startDate).format("YYYY-MM-DD")," - ",y(o.endDate).format("YYYY-MM-DD")]}),e.jsx(re,{options:o.customers,getOptionLabel:E,value:o.selectedCustomer,onChange:(t,u)=>O(u),sx:{minWidth:r?"100%":200,flex:r?1:"none"},renderInput:t=>e.jsx(F,{...t,label:d("admin.meter.events.filterByCustomer"),size:"small"}),renderOption:(t,u)=>e.jsxs(x,{component:"li",...t,sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(se,{src:oe(u.did,u?.updated_at?new Date(u.updated_at).toISOString():void 0,24),sx:{width:24,height:24},alt:E(u)}),E(u)]})}),!C&&e.jsx(T,{variant:"outlined",startIcon:e.jsx(X,{}),onClick:b,sx:{minWidth:r?"100%":"auto",color:"text.link"},children:d("admin.meterEvent.add.button")})]}),e.jsx(x,{sx:{mt:2,display:"flex",justifyContent:r?"center":"flex-end"},children:e.jsxs(fe,{value:o.chartType,exclusive:!0,onChange:S,size:"small",sx:{width:r?"100%":"auto","& .MuiToggleButton-root":{flex:r?1:"none"}},children:[e.jsx(te,{value:"event_count",children:d("admin.meter.events.eventCount")}),e.jsx(te,{value:"total_value",children:d("admin.meter.events.totalValue")})]})})]}),e.jsx(pe,{sx:{mb:3},children:e.jsx(x,{sx:{height:r?250:300,position:"relative",pr:r?1:2,pl:r?.5:1},children:o.statsLoading?e.jsx(x,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0},children:e.jsx(xe,{variant:"rectangular",width:"100%",height:"100%"})}):e.jsx(ze,{width:"100%",height:"100%",children:e.jsxs(Re,{data:P,margin:{top:10,right:r?10:30,left:r?5:10,bottom:p==="hour"?r?50:60:r?30:40},children:[e.jsx(Ne,{strokeDasharray:"3 3"}),e.jsx(We,{dataKey:"date",tick:{fontSize:r?10:11},angle:p==="hour"?-45:0,textAnchor:p==="hour"?"end":"middle",height:p==="hour"?r?50:60:r?30:40,interval:(()=>{const t=P.length;return r?t>20?Math.floor(t/6):t>10?Math.floor(t/4):t>5?1:0:p==="hour"?t>24?Math.floor(t/12):t>12?1:0:t>30?Math.floor(t/15):t>15?1:0})()}),e.jsx(Ue,{tick:{fontSize:r?9:11},width:r?35:40,tickFormatter:t=>r&&t>=1e3?`${(t/1e3).toFixed(1)}k`:t.toString()}),e.jsx(Ge,{labelFormatter:t=>P.find(f=>f.date===t)?.fullDate||t,formatter:(t,u)=>[u==="event_count"?t:ne(t,a.decimal),d(u==="event_count"?"admin.meter.events.eventCount":"admin.meter.events.totalValue")],contentStyle:{fontSize:r?"12px":"14px",padding:r?"8px":"10px"}}),e.jsx($e,{type:"monotone",dataKey:o.chartType,stroke:o.chartType==="event_count"?"#8884d8":"#82ca9d",fill:o.chartType==="event_count"?"#8884d8":"#82ca9d",fillOpacity:.6,strokeWidth:r?1.5:2})]})})})}),e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:e.jsx(A,{variant:"body2",sx:{color:"text.secondary"},children:d("admin.meter.events.count",{count:g.count})})}),e.jsx(le,{data:g.list,columns:me,onChange:h,options:{count:g.count,page:m.page-1,rowsPerPage:m.pageSize,responsive:r?"vertical":"standard"},loading:s,emptyNodeText:d("admin.meter.events.empty")}),e.jsx(ge,{id:ce,open:ee,anchorEl:o.anchorEl,onClose:()=>l({anchorEl:null}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Be,{open:!0,toggle:v,maxDate:n,definedRanges:Fe(n.toISOString()),onChange:L})}),e.jsx(Qe,{open:o.addUsageDialog,onClose:j,meterId:c,customers:o.customers,paymentCurrency:a,onSuccess:V})]})}const st=c=>_.get(`/api/products?meter_id=${c}`).then(a=>a.data),it=c=>_.get(`/api/products?type=credit&meter_id=${c}`).then(a=>a.data);function ot({meterId:c,meter:a=void 0}){const{t:d,locale:r}=G(),{settings:C}=de(),[n,m]=M.useState([]),[i,g]=M.useState(!1),[k,s]=M.useState(!1),[o,l]=M.useState(null),[p,P]=M.useState("credit"),I=async(E=p)=>{g(!0),l(null);try{const b=E==="meter"?await st(c):await it(c);m(b.list)}catch(b){console.error("Failed to fetch products:",b),l("Failed to load products")}finally{g(!1)}};M.useEffect(()=>{I()},[c,p]);const N=(E,b)=>{P(b)},h=()=>{s(!0)},v=()=>{s(!1),I()};if(o)return e.jsx(W,{severity:"error",sx:{mt:1},children:o});const L=[{label:d("admin.product.name.label"),name:"name",options:{filter:!1,customBodyRenderLite:(E,b)=>{const j=n[b];if(!j)return null;const V=we(C.paymentMethods,j.prices[0]?.currency_id??"")||C.baseCurrency;return e.jsx(R,{to:`/admin/products/${j.id}`,children:e.jsx(qe,{name:j.name,description:Ye(j,V,r),logo:j.images[0]})})}}},{label:d("common.status"),name:"active",options:{filter:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(R,{to:`/admin/products/${j.id}`,children:e.jsx(ke,{label:j?.active?"Active":"Archived",color:j?.active?"success":"default"})}):null}}},{label:d("common.createdAt"),name:"created_at",options:{sort:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(R,{to:`/admin/products/${j.id}`,children:U(j.created_at)}):null}}},{label:d("common.actions"),name:"id",width:100,align:"center",options:{sort:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(Ke,{data:j,onChange:()=>I()}):null}}}],O=p==="meter"?{text:d("admin.meter.products.emptyTip"),buttonText:d("admin.meter.products.create")}:{text:d("admin.meter.creditProducts.emptyTip"),buttonText:d("admin.creditProduct.create")};return e.jsxs(x,{children:[e.jsx(w,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(he,{value:p,onChange:N,sx:{flex:"1 0 auto",maxWidth:"100%",fontSize:14,borderBottom:1,borderColor:"divider",".Mui-selected":{fontSize:"14px !important",color:"primary.main"}},children:[e.jsx(ae,{label:d("admin.meter.products.creditCharge"),value:"credit"}),e.jsx(ae,{label:d("admin.meter.products.meterService"),value:"meter"})]})}),e.jsx(w,{direction:"row",sx:{justifyContent:"flex-end",mb:2},children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link",float:"right"},startIcon:e.jsx(X,{}),onClick:h,children:d(p==="meter"?"admin.meter.products.create":"admin.creditProduct.create")})}),e.jsx(le,{hasRowLink:!0,data:n,columns:L,options:{count:n.length,page:0,rowsPerPage:n.length,pagination:!1,search:!1,filter:!1,sort:!1,viewColumns:!1,download:!1,print:!1,selectableRows:"none"},loading:i,emptyNodeText:e.jsxs(x,{children:[e.jsx(A,{children:O.text}),e.jsx(T,{size:"small",variant:"text",startIcon:e.jsx(X,{}),onClick:h,sx:{mt:1,color:"text.link"},children:O.buttonText})]})}),k&&e.jsx(Ve,{open:k,onClose:v,onSubmit:()=>I(p),mode:p==="credit"?"credit":"standard",meterId:c,initialPrice:p==="meter"?{currency_id:a?.currency_id||"",priceModel:"credit_metered"}:{metadata:{credit_config:{currency_id:a?.currency_id||""}},name:a?.unit||""}})]})}const dt=c=>_.get(`/api/meters/${c}`).then(a=>a.data);function Ut(c){const{t:a}=G(),{isMobile:d}=Q(),r=Oe(),C=h=>{switch(h){case"sum":return a("admin.meter.aggregationMethod.sumHint");case"count":return a("admin.meter.aggregationMethod.countHint");case"last":return a("admin.meter.aggregationMethod.lastHint");default:return""}},[n,m]=J({editing:{metadata:!1,meter:!1},loading:{metadata:!1,meter:!1},creating:{product:!1,creditProduct:!1},tokenConfig:{name:"",symbol:"",tokenFactoryAddress:""}}),i=Se({defaultValues:{name:"",event_name:"",aggregation_method:"sum",unit:"",description:"",metadata:{},mode:"OffChain"}}),{loading:g,error:k,data:s,runAsync:o}=ie(()=>dt(c.id));if(k)return e.jsx(W,{severity:"error",children:k.message});if(g||!s)return e.jsx(ye,{});const l=async h=>{try{m(v=>({loading:{...v.loading,metadata:!0}})),await _.put(`/api/meters/${c.id}`,h),Y.success(a("common.saved")),o()}catch(v){console.error(v),Y.error(Z(v))}finally{m(v=>({loading:{...v.loading,metadata:!1}}))}},p=h=>{h==="delete"?r("/admin/billing/meters"):o()},P=()=>{m(h=>({editing:{...h.editing,metadata:!0}}))},I=()=>{const h=!!s.paymentCurrency?.token_config;i.reset({name:s.name,event_name:s.event_name,aggregation_method:s.aggregation_method,unit:s.unit,description:s.description||"",metadata:s.metadata||{},mode:h?"OnChain":"OffChain"}),m(v=>({editing:{...v.editing,meter:!0},tokenConfig:{name:"",symbol:"",tokenFactoryAddress:""}}))},N=async h=>{try{m(S=>({loading:{...S.loading,meter:!0}}));const v=s.paymentCurrency?.id,L=!!s.paymentCurrency?.token_config;if(v&&!L&&h.mode==="OnChain"){let{tokenFactoryAddress:S}=n.tokenConfig;if(!S&&n.tokenConfig.symbol){const{data:O}=await _.post("/api/credit-tokens",{name:n.tokenConfig.name,symbol:n.tokenConfig.symbol});S=O.address}S&&await _.put(`/api/payment-currencies/${v}/token-config`,{token_factory_address:S})}v&&L&&h.mode==="OffChain"&&await _.delete(`/api/payment-currencies/${v}/token-config`),delete h.mode,await _.put(`/api/meters/${c.id}`,h),Y.success(a("admin.meter.saved")),m(S=>({editing:{...S.editing,meter:!1}})),o()}catch(v){console.error(v),Y.error(Z(v))}finally{m(v=>({loading:{...v.loading,meter:!1}}))}};return e.jsxs(lt,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(x,{children:[s.status==="inactive"&&e.jsxs(W,{severity:"warning",sx:{mb:2},children:[e.jsx(ve,{children:a("admin.meter.inactive")}),a("admin.meter.inactiveTip")]}),e.jsxs(w,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(w,{direction:"row",onClick:()=>Le("/admin/meters"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(je,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(A,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.meters")})]}),e.jsx(Pe,{data:s,variant:"normal",onChange:p})]}),e.jsxs(x,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(w,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(w,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsxs(w,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(A,{variant:"h2",sx:{color:"text.primary"},children:s.name}),e.jsxs(A,{variant:"subtitle1",sx:{color:"text.lighter"},children:[s.event_name," • ",s.unit]})]})})}),e.jsxs(w,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(K,{label:a("common.id"),value:e.jsx(Ee,{text:c.id,style:{marginLeft:4}}),divider:!0}),e.jsx(K,{label:a("common.createdAt"),value:U(s.created_at),divider:!0}),s.paymentCurrency?.recharge_config?.base_price_id&&e.jsx(K,{label:a("admin.meter.rechargePackage.priceId"),tip:a("admin.meter.rechargePackage.tooltip",{name:s.paymentCurrency.name}),value:e.jsx(T,{variant:"text",size:"small",onClick:()=>r(`/admin/products/${s.paymentCurrency.recharge_config.base_price_id}`),sx:{p:0,minWidth:"auto",textAlign:"left",ml:.5,color:"text.link"},children:s.paymentCurrency.recharge_config.base_price_id}),divider:!0})]})]}),e.jsx($,{})]}),e.jsxs(w,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".meter-column-1":{minWidth:{xs:"100%",lg:"600px"}},".meter-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(x,{className:"meter-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(x,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(B,{title:a("admin.details"),children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:n.editing.meter,onClick:I,children:a("common.edit")})}),e.jsxs(Te,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(z,{label:a("admin.meter.name.label"),value:s.name}),e.jsx(z,{label:a("admin.meter.eventName.label"),value:s.event_name}),e.jsx(z,{label:a("admin.meter.aggregationMethod.label"),value:s.aggregation_method}),e.jsx(z,{label:a("admin.meter.unit.label"),value:s.unit}),e.jsx(z,{label:a("admin.meter.description.label"),value:s.description||"-"}),e.jsx(z,{label:a("common.updatedAt"),value:U(s.updated_at)})]})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("admin.meter.events.title")}),e.jsx(x,{className:"section-body",children:e.jsx(rt,{meterId:s.id,paymentCurrency:s.paymentCurrency})})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx(B,{title:a("admin.meter.products.title")})}),e.jsx(x,{className:"section-body",children:e.jsx(ot,{meterId:s.id,meter:s})})]})]}),d&&e.jsx($,{}),e.jsxs(x,{className:"meter-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("admin.meter.usageGuide.title")}),e.jsx(x,{className:"section-body",children:e.jsx(W,{severity:"info",sx:{mb:2},children:e.jsx(A,{variant:"body2",children:a("admin.meter.usageGuide.tip",{eventName:s.event_name,aggregationMethodHint:C(s.aggregation_method),unit:s.unit})})})})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("common.metadata.label"),children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:n.editing.metadata,onClick:P,children:a("common.edit")})}),e.jsxs(x,{className:"section-body",children:[e.jsx(Ae,{data:s.metadata,handleEditMetadata:P}),n.editing.metadata&&e.jsx(Ie,{data:s,loading:n.loading.metadata,onSave:l,onCancel:()=>m(h=>({editing:{...h.editing,metadata:!1}}))})]})]})]})]}),n.editing.meter&&e.jsx(Ze,{icon:e.jsx(be,{}),text:a("admin.meter.edit"),open:n.editing.meter,onClose:()=>m(h=>({editing:{...h.editing,meter:!1}})),width:640,addons:e.jsx(T,{variant:"contained",size:"small",disabled:n.loading.meter,onClick:i.handleSubmit(N),children:a("admin.meter.save")}),children:e.jsx(Me,{...i,children:e.jsx(Xe,{mode:"edit",paymentCurrency:s.paymentCurrency,tokenConfig:n.tokenConfig,onTokenConfigChange:h=>m({tokenConfig:h})})})})]})}const lt=Ce(w)``;export{Ut as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,r as T,q as l,B as c,w as G,a3 as x,x as S,bf as H,u as Q,A as
|
|
1
|
+
import{j as e,r as T,q as l,B as c,w as G,a3 as x,x as S,bf as H,u as Q,A as P,bv as X,O as E,Y as k}from"./vendor-mui-BXZut9Pz.js";import{V as $,P as F,ah as ee,Y as te,Z as N,F as se}from"./vendor-blocklet-DcLR2Cyf.js";import{i as O,n as w,o as q,j as b,p as A,T as ae,q as ne,e as K,d as oe,a as ie,u as re,k as W,r as ce,s as le,t as de,v as me,l as pe,w as ue}from"./index-BarN7DfU.js";import{T as xe}from"./gas-nyR96dB0.js";import{b as he,e as ye,L as fe}from"./vendor-react-BPknnnEA.js";import{l as j}from"./lodash-B4Ozcv0x.js";import{C as ge}from"./currency-GstdXsJf.js";import{C as be}from"./link-CmPoIweR.js";import{I as h}from"./info-row-jI0h_hv4.js";import{D as je,R as ve,I as _e}from"./related-credit-grants-JV2ICsR5.js";import{g as we}from"./util-DxXTXkeY.js";import{I}from"./info-metric-Dl4ZDm0Z.js";import{I as Ce}from"./info-row-group-CFuMWJf1.js";import{u as ke}from"./browser-DDv4_sgY.js";import"./browser-Bb9g-cvG.js";import"./usage-records-DAUQMJAW.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./generateCategoricalChart-BadryV3H.js";const Ie=s=>{const o={};return s.forEach(a=>{const r=new Date(a.created_at).toLocaleDateString();o[r]||(o[r]=[]),o[r]?.push(a)}),o},U=(s={})=>{const o=new URLSearchParams;return Object.keys(s).forEach(a=>{o.set(a,String(s[a]))}),K.get(`/api/refunds?${o.toString()}`).then(a=>a.data)},R=10,Se=T.memo(({invoice_id:s})=>{const o="invoice-table",{t:a,locale:r}=$(),[m,y]=T.useState({pageSize:R,page:1}),{loading:f,data:p={list:[],count:0}}=F(()=>U({...m,invoice_id:s}),{refreshDeps:[m]}),u=[{label:a("common.amount"),name:"id",width:80,align:"right",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsxs(l,{component:"strong",sx:{fontWeight:600},children:[O(t?.amount,t?.paymentCurrency.decimal),t?.paymentCurrency.symbol]})}}},{label:a("common.status"),name:"status",width:100,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:t.status,color:q(t.status)})}}},{label:a("common.type"),name:"type",width:80,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:a(`refund.type.${t.type}`)})}}},{label:a("common.description"),name:"description",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return t.description?j.capitalize(j.toLower(t.description.replace(/_/g," "))):t.id}}},{label:a("common.createdAt"),name:"created_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.created_at)}}},{label:a("common.updatedAt"),name:"updated_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.updated_at)}}},{label:a("common.txHash"),name:"",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i],v=t.payment_details;return["arcblock","ethereum","base"].map(C=>!!v?.[C]?.tx_hash).find(Boolean)?e.jsx(c,{sx:{".MuiTypography-root":{color:"text.link"}},children:e.jsx(A,{details:v,method:t.paymentMethod,mode:"customer"})}):a("common.none")}}}],d=({page:n,rowsPerPage:i})=>{m.pageSize!==i?y(t=>({...t,pageSize:i,page:1})):m.page!==n+1&&y(t=>({...t,page:n+1}))};return e.jsx(Re,{children:e.jsx(ae,{hasRowLink:!0,durable:`__${o}__`,durableKeys:["page","rowsPerPage","searchText"],data:p.list,columns:u,options:{count:p.count,page:m.page-1,rowsPerPage:m.pageSize},loading:f,onChange:d,toolbar:!1,sx:{mt:2},showMobile:!1,locale:r,mobileTDFlexDirection:"row",emptyNodeText:a("payment.customer.refund.emptyList")})})}),Re=H(c)`
|
|
2
2
|
@media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
|
|
3
3
|
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root {
|
|
4
4
|
> div {
|
|
@@ -11,7 +11,7 @@ import{j as e,r as T,q as l,B as c,w as G,a3 as x,x as S,bf as H,u as Q,A as $,b
|
|
|
11
11
|
padding-right: 20px;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
`,Te=T.memo(({invoice_id:s})=>{const{t:o}=P(),{data:a,loadMore:r,loadingMore:m,loading:y}=ee(u=>{const d=u?Math.ceil(u.list.length/R)+1:1;return U({page:d,pageSize:R,invoice_id:s})},{reloadDeps:[s]});if(y||!a)return e.jsx(G,{});if(a&&a.list.length===0)return e.jsx(l,{sx:{color:"text.secondary"},children:o("payment.customer.refund.empty")});const f=a&&a.list.length<a.count,p=Ie(a.list);return e.jsxs(x,{direction:"column",sx:{gap:1,mt:1},children:[Object.entries(p).map(([u,d])=>e.jsxs(c,{children:[e.jsx(l,{sx:{fontWeight:"bold",color:"text.secondary",mt:2,mb:1},children:u}),d.map(n=>e.jsxs(x,{direction:{xs:"column",sm:"row"},sx:{gap:{xs:.5,sm:1.5,md:3},flexWrap:"nowrap",my:1},children:[e.jsx(c,{sx:{flex:3},children:e.jsx(l,{children:ne(n.created_at)})}),e.jsx(c,{sx:{flex:2},children:e.jsxs(l,{sx:{textAlign:"right"},children:[F(n.amount,n.paymentCurrency.decimal)," ",n.paymentCurrency.symbol]})}),e.jsx(c,{sx:{flex:3},children:e.jsx(w,{label:n.status,color:q(n.status)})}),e.jsx(c,{sx:{flex:3},children:e.jsx(l,{children:n.description?j.capitalize(j.toLower(n.description.replace(/_/g," "))):"-"})}),e.jsx(c,{sx:{flex:3,minWidth:"220px"},children:(n.payment_details?.arcblock?.tx_hash||n.payment_details?.ethereum?.tx_hash||n.payment_details?.base?.tx_hash)&&e.jsx(A,{details:n.payment_details,method:n.paymentMethod,mode:"customer"})})]},n.id))]},u)),e.jsxs(c,{children:[f&&e.jsx(S,{variant:"text",type:"button",color:"inherit",onClick:r,disabled:m,children:m?o("common.loadingMore",{resource:o("payment.customer.payments")}):o("common.loadMore",{resource:o("payment.customer.payments")})}),!f&&a.count>R&&e.jsx(l,{sx:{color:"text.secondary"},children:o("common.noMore",{resource:o("payment.customer.payments")})})]})]})});function De({type:s="list",...o}){return s==="table"?e.jsx(Se,{...o}):e.jsx(Te,{...o})}const Me=s=>K.get(`/api/invoices/${s}`).then(o=>o.data);function Qe(){const{t:s,locale:o}=P(),[a]=he(),{isMobile:r}=oe(),{connect:m}=ie(),y=ye(),f=Q(),p=ke(),[u,d]=te({downloading:!1,paying:!1}),{loading:n,error:i,data:t,runAsync:v}=O(()=>Me(y.id)),g=a.get("action"),{session:C}=re(),D=t?.checkoutSession?.submit_type==="donate",E=()=>{d({paying:!0}),m.open({action:"collect",saveConnect:!1,locale:o,extraParams:{invoiceId:y.id,action:g,allowCreatePI:t?.status==="uncollectible"},messages:{scan:"",title:s(`payment.customer.invoice.${g||"pay"}`),success:s(`payment.customer.invoice.${g||"pay"}Success`),error:s(`payment.customer.invoice.${g||"pay"}Error`),confirm:""},onSuccess:async()=>{m.close(),d({paying:!1}),await v()},onClose:()=>{m.close(),d({paying:!1})},onError:_=>{d({paying:!1}),N.error(W(_))}})},Y=()=>{d({paying:!0}),m.close()};if(T.useEffect(()=>{i?.response?.status===403?Y():["pay","renew"].includes(g)&&["open","uncollectible"].includes(t?.status)&&E()},[i]),t?.customer?.did&&C?.user?.did&&t.customer.did!==C.user.did)return e.jsx($,{severity:"error",children:s("common.accessDenied")});if(i)return e.jsx($,{severity:"error",children:W(i)});if(n||!t)return e.jsx(G,{});const M=t.paymentMethod?.type==="arcblock"&&["stake","stake_overdraft_protection"].includes(t.billing_reason),L=t.paymentMethod?.type==="arcblock"&&t.billing_reason.includes("slash_stake"),V=t.billing_reason==="overdraft_protection",B=t.paymentIntent?.payment_details||t.metadata?.payment_details,X=["open","paid","uncollectible"].includes(t.status)&&!D&&!j.isEmpty(t.lines);return e.jsxs(Le,{direction:"column",spacing:3,children:[e.jsxs(x,{direction:"row",sx:{justifyContent:"space-between"},children:[p?e.jsx(c,{}):e.jsxs(x,{direction:"row",onClick:()=>we("/customer"),sx:{alignItems:"center",fontWeight:"normal",padding:"10px 0",cursor:"pointer"},children:[e.jsx(Z,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(l,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("common.previous")})]}),e.jsxs(x,{direction:"row",spacing:1,sx:{justifyContent:"flex-end",alignItems:"center"},children:[X&&e.jsx(je,{data:t}),t?.paymentLink?.donation_settings?.reference&&e.jsx(S,{variant:"outlined",onClick:()=>{window.open(t?.paymentLink?.donation_settings?.reference,"_blank")},children:s("customer.payout.viewReference")}),["open","uncollectible"].includes(t.status)&&!V&&(t.paymentMethod?.type==="stripe"?e.jsx(ce,{invoice:t,paymentMethod:t.paymentMethod,onSuccess:async()=>{N.close(),d({paying:!1}),await v()},onError:()=>{d({paying:!1})},onClose:()=>{d({paying:!1})},children:(_,J)=>e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying||J,onClick:()=>{d({paying:!0}),_()},children:s("payment.customer.invoice.pay")})}):e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying,onClick:E,children:s("payment.customer.invoice.pay")}))]})]}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx($,{severity:"warning",sx:{mt:2},children:e.jsx(l,{variant:"body2",children:s("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"})})}),e.jsxs(c,{sx:{mt:r?"0 !important":4,display:"flex",border:r?`1px solid ${f.palette.divider}`:"none",borderRadius:r?1:0,p:r?2:0,gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(x,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(x,{direction:"row",sx:{alignItems:"center",flexWrap:"wrap",gap:1},children:e.jsx(l,{variant:"h1",children:t.number})})}),e.jsxs(x,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},".info-metric-label":{mb:r?.5:1},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"},gap:{xs:1,sm:1,md:3}},children:[e.jsx(I,{label:s("common.status"),value:e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(z,{title:t.status==="void"?s("payment.customer.invoice.noPaymentRequired"):"",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(w,{label:t.status,color:le(t.status)})})}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(z,{title:s("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"}),arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(w,{label:s("payment.customer.invoice.slippageExceeded"),color:"warning"})})})]}),divider:!0}),t.subscription&&e.jsx(I,{label:s("admin.subscription.name"),value:e.jsx(fe,{to:`/customer/subscription/${t.subscription.id}`,children:e.jsx(l,{variant:"body1",sx:{color:"text.link"},children:t.subscription.description||t.subscription.id})}),divider:!0}),e.jsx(I,{label:s("common.createdAt"),value:b(t.created_at),divider:!0}),t.period_start>0&&t.period_end>0&&e.jsx(I,{label:s("admin.subscription.currentPeriod"),value:[b(t.period_start*1e3),b(t.period_end*1e3)].join(" ~ "),divider:!0})]})]}),e.jsx(k,{}),e.jsxs(c,{className:"section",sx:{containerType:"inline-size",border:r?_=>`1px solid ${_.palette.divider}`:"none",borderRadius:r?1:0,p:r?2:0},children:[e.jsx(l,{variant:"h3",className:"section-header",sx:{mb:3},children:s("payment.customer.invoice.details")}),e.jsxs(Ce,{sx:{display:"grid",columnGap:16,gridTemplateColumns:{xs:"repeat(1, 1fr)",lg:"repeat(2, 1fr)"},"@container (min-width: 980px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:r?.5:1,flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"flex-start",lg:"center"},"@container (min-width: 980px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary",fontSize:14,lineHeight:1},".tx-link-text":{fontSize:14,lineHeight:1}},children:[e.jsx(h,{label:s("admin.invoice.billTo"),value:e.jsx(be,{customer:t.customer,linked:!1,size:"small"})}),e.jsx(h,{label:s("admin.invoice.from"),value:t.statement_descriptor||blocklet.appName}),e.jsx(h,{label:s("admin.invoice.description"),value:de(t,o)?.description}),t.status_transitions?.paid_at&&e.jsx(h,{label:s("admin.invoice.paidAt"),value:b(t.status_transitions.paid_at*1e3)}),e.jsx(h,{label:s("admin.paymentCurrency.name"),value:e.jsx(ge,{logo:t.paymentCurrency.logo,name:`${t.paymentCurrency.symbol} (${t.paymentMethod.name})`})}),(M||L)&&e.jsx(h,{label:s(L?"common.slashStakeAmount":"common.stakeAmount"),value:`${me(t.total,t.paymentCurrency.decimal)} ${t.paymentCurrency.symbol}`}),(!!t.paymentIntent?.payment_details?.ethereum||!!t.paymentIntent?.payment_details?.base)&&e.jsx(h,{label:s("common.txGas"),value:e.jsx(xe,{details:t.paymentIntent.payment_details,method:t.paymentMethod})}),B&&e.jsx(h,{label:s(M?"common.stakeTxHash":`common.${B?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(A,{details:B,method:t.paymentMethod,mode:"customer"})}),t?.relatedInvoice&&e.jsx(h,{label:s("customer.invoice.relatedInvoice"),value:e.jsx(l,{variant:"body1",component:"a",onClick:()=>{window.open(se(pe(),`/customer/invoice/${t.relatedInvoice?.id}`),"_self")},sx:{color:"text.link",cursor:"pointer"},children:t.relatedInvoice?.number})})]})]}),D&&!j.isEmpty(t.paymentIntent?.beneficiaries)&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsx(c,{className:"section",children:e.jsx(l,{variant:"h3",className:"section-header",children:s("customer.invoice.donation")})}),e.jsx(c,{sx:{maxWidth:800},children:e.jsx(ue,{data:t?.paymentIntent?.beneficiaries,currency:t.paymentCurrency,totalAmount:t?.amount_paid})})]}),t?.relatedCreditGrants&&t.relatedCreditGrants.length>0&&e.jsx(ve,{grants:t.relatedCreditGrants}),!L&&!D&&e.jsxs(e.Fragment,{children:[!M&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsxs(c,{className:"section",children:[e.jsx(l,{variant:"h3",className:"section-header",sx:{mb:1.5},children:s("admin.invoiceItems")}),e.jsx(_e,{invoice:t,simple:!0})]})]}),e.jsx(k,{}),e.jsxs(c,{className:"section",children:[e.jsx(l,{variant:"h3",className:"section-header",children:s("admin.refunds")}),e.jsx(c,{className:"section-body",children:e.jsx(De,{invoice_id:t.id,type:"table"})})]})]})]})}const Le=H(x)`
|
|
14
|
+
`,Te=T.memo(({invoice_id:s})=>{const{t:o}=$(),{data:a,loadMore:r,loadingMore:m,loading:y}=ee(u=>{const d=u?Math.ceil(u.list.length/R)+1:1;return U({page:d,pageSize:R,invoice_id:s})},{reloadDeps:[s]});if(y||!a)return e.jsx(G,{});if(a&&a.list.length===0)return e.jsx(l,{sx:{color:"text.secondary"},children:o("payment.customer.refund.empty")});const f=a&&a.list.length<a.count,p=Ie(a.list);return e.jsxs(x,{direction:"column",sx:{gap:1,mt:1},children:[Object.entries(p).map(([u,d])=>e.jsxs(c,{children:[e.jsx(l,{sx:{fontWeight:"bold",color:"text.secondary",mt:2,mb:1},children:u}),d.map(n=>e.jsxs(x,{direction:{xs:"column",sm:"row"},sx:{gap:{xs:.5,sm:1.5,md:3},flexWrap:"nowrap",my:1},children:[e.jsx(c,{sx:{flex:3},children:e.jsx(l,{children:ne(n.created_at)})}),e.jsx(c,{sx:{flex:2},children:e.jsxs(l,{sx:{textAlign:"right"},children:[O(n.amount,n.paymentCurrency.decimal)," ",n.paymentCurrency.symbol]})}),e.jsx(c,{sx:{flex:3},children:e.jsx(w,{label:n.status,color:q(n.status)})}),e.jsx(c,{sx:{flex:3},children:e.jsx(l,{children:n.description?j.capitalize(j.toLower(n.description.replace(/_/g," "))):"-"})}),e.jsx(c,{sx:{flex:3,minWidth:"220px"},children:(n.payment_details?.arcblock?.tx_hash||n.payment_details?.ethereum?.tx_hash||n.payment_details?.base?.tx_hash)&&e.jsx(A,{details:n.payment_details,method:n.paymentMethod,mode:"customer"})})]},n.id))]},u)),e.jsxs(c,{children:[f&&e.jsx(S,{variant:"text",type:"button",color:"inherit",onClick:r,disabled:m,children:m?o("common.loadingMore",{resource:o("payment.customer.payments")}):o("common.loadMore",{resource:o("payment.customer.payments")})}),!f&&a.count>R&&e.jsx(l,{sx:{color:"text.secondary"},children:o("common.noMore",{resource:o("payment.customer.payments")})})]})]})});function De({type:s="list",...o}){return s==="table"?e.jsx(Se,{...o}):e.jsx(Te,{...o})}const Me=s=>K.get(`/api/invoices/${s}`).then(o=>o.data);function Qe(){const{t:s,locale:o}=$(),[a]=he(),{isMobile:r}=oe(),{connect:m}=ie(),y=ye(),f=Q(),p=ke(),[u,d]=te({downloading:!1,paying:!1}),{loading:n,error:i,data:t,runAsync:v}=F(()=>Me(y.id)),g=a.get("action"),{session:C}=re(),D=t?.checkoutSession?.submit_type==="donate",z=()=>{d({paying:!0}),m.open({action:"collect",saveConnect:!1,locale:o,extraParams:{invoiceId:y.id,action:g,allowCreatePI:t?.status==="uncollectible"},messages:{scan:"",title:s(`payment.customer.invoice.${g||"pay"}`),success:s(`payment.customer.invoice.${g||"pay"}Success`),error:s(`payment.customer.invoice.${g||"pay"}Error`),confirm:""},onSuccess:async()=>{m.close(),d({paying:!1}),await v()},onClose:()=>{m.close(),d({paying:!1})},onError:_=>{d({paying:!1}),N.error(W(_))}})},Y=()=>{d({paying:!0}),m.close()};if(T.useEffect(()=>{i?.response?.status===403?Y():["pay","renew"].includes(g)&&["open","uncollectible"].includes(t?.status)&&z()},[i]),t?.customer?.did&&C?.user?.did&&t.customer.did!==C.user.did)return e.jsx(P,{severity:"error",children:s("common.accessDenied")});if(i)return e.jsx(P,{severity:"error",children:W(i)});if(n||!t)return e.jsx(G,{});const M=t.paymentMethod?.type==="arcblock"&&["stake","stake_overdraft_protection"].includes(t.billing_reason),L=t.paymentMethod?.type==="arcblock"&&t.billing_reason.includes("slash_stake"),V=t.billing_reason==="overdraft_protection",B=t.paymentIntent?.payment_details||t.metadata?.payment_details,Z=["open","paid","uncollectible"].includes(t.status)&&!D&&!j.isEmpty(t.lines);return e.jsxs(Le,{direction:"column",spacing:3,children:[e.jsxs(x,{direction:"row",sx:{justifyContent:"space-between"},children:[p?e.jsx(c,{}):e.jsxs(x,{direction:"row",onClick:()=>we("/customer"),sx:{alignItems:"center",fontWeight:"normal",padding:"10px 0",cursor:"pointer"},children:[e.jsx(X,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(l,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("common.previous")})]}),e.jsxs(x,{direction:"row",spacing:1,sx:{justifyContent:"flex-end",alignItems:"center"},children:[Z&&e.jsx(je,{data:t}),t?.paymentLink?.donation_settings?.reference&&e.jsx(S,{variant:"outlined",onClick:()=>{window.open(t?.paymentLink?.donation_settings?.reference,"_blank")},children:s("customer.payout.viewReference")}),["open","uncollectible"].includes(t.status)&&!V&&(t.paymentMethod?.type==="stripe"?e.jsx(ce,{invoice:t,paymentMethod:t.paymentMethod,onSuccess:async()=>{N.close(),d({paying:!1}),await v()},onError:()=>{d({paying:!1})},onClose:()=>{d({paying:!1})},children:(_,J)=>e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying||J,onClick:()=>{d({paying:!0}),_()},children:s("payment.customer.invoice.pay")})}):e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying,onClick:z,children:s("payment.customer.invoice.pay")}))]})]}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(P,{severity:"warning",sx:{mt:2},children:e.jsx(l,{variant:"body2",children:s("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"})})}),e.jsxs(c,{sx:{mt:r?"0 !important":4,display:"flex",border:r?`1px solid ${f.palette.divider}`:"none",borderRadius:r?1:0,p:r?2:0,gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(x,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(x,{direction:"row",sx:{alignItems:"center",flexWrap:"wrap",gap:1},children:e.jsx(l,{variant:"h1",children:t.number})})}),e.jsxs(x,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},".info-metric-label":{mb:r?.5:1},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"},gap:{xs:1,sm:1,md:3}},children:[e.jsx(I,{label:s("common.status"),value:e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(E,{title:t.status==="void"?s("payment.customer.invoice.noPaymentRequired"):"",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(w,{label:t.status,color:le(t.status)})})}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(E,{title:s("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"}),arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(w,{label:s("payment.customer.invoice.slippageExceeded"),color:"warning"})})})]}),divider:!0}),t.subscription&&e.jsx(I,{label:s("admin.subscription.name"),value:e.jsx(fe,{to:`/customer/subscription/${t.subscription.id}`,children:e.jsx(l,{variant:"body1",sx:{color:"text.link"},children:t.subscription.description||t.subscription.id})}),divider:!0}),e.jsx(I,{label:s("common.createdAt"),value:b(t.created_at),divider:!0}),t.period_start>0&&t.period_end>0&&e.jsx(I,{label:s("admin.subscription.currentPeriod"),value:[b(t.period_start*1e3),b(t.period_end*1e3)].join(" ~ "),divider:!0})]})]}),e.jsx(k,{}),e.jsxs(c,{className:"section",sx:{containerType:"inline-size",border:r?_=>`1px solid ${_.palette.divider}`:"none",borderRadius:r?1:0,p:r?2:0},children:[e.jsx(l,{variant:"h3",className:"section-header",sx:{mb:3},children:s("payment.customer.invoice.details")}),e.jsxs(Ce,{sx:{display:"grid",columnGap:16,gridTemplateColumns:{xs:"repeat(1, 1fr)",lg:"repeat(2, 1fr)"},"@container (min-width: 980px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:r?.5:1,flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"flex-start",lg:"center"},"@container (min-width: 980px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary",fontSize:14,lineHeight:1},".tx-link-text":{fontSize:14,lineHeight:1}},children:[e.jsx(h,{label:s("admin.invoice.billTo"),value:e.jsx(be,{customer:t.customer,linked:!1,size:"small"})}),e.jsx(h,{label:s("admin.invoice.from"),value:t.statement_descriptor||blocklet.appName}),e.jsx(h,{label:s("admin.invoice.description"),value:de(t,o)?.description}),t.status_transitions?.paid_at&&e.jsx(h,{label:s("admin.invoice.paidAt"),value:b(t.status_transitions.paid_at*1e3)}),e.jsx(h,{label:s("admin.paymentCurrency.name"),value:e.jsx(ge,{logo:t.paymentCurrency.logo,name:`${t.paymentCurrency.symbol} (${t.paymentMethod.name})`})}),(M||L)&&e.jsx(h,{label:s(L?"common.slashStakeAmount":"common.stakeAmount"),value:`${me(t.total,t.paymentCurrency.decimal)} ${t.paymentCurrency.symbol}`}),(!!t.paymentIntent?.payment_details?.ethereum||!!t.paymentIntent?.payment_details?.base)&&e.jsx(h,{label:s("common.txGas"),value:e.jsx(xe,{details:t.paymentIntent.payment_details,method:t.paymentMethod})}),B&&e.jsx(h,{label:s(M?"common.stakeTxHash":`common.${B?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(A,{details:B,method:t.paymentMethod,mode:"customer"})}),t?.relatedInvoice&&e.jsx(h,{label:s("customer.invoice.relatedInvoice"),value:e.jsx(l,{variant:"body1",component:"a",onClick:()=>{window.open(se(pe(),`/customer/invoice/${t.relatedInvoice?.id}`),"_self")},sx:{color:"text.link",cursor:"pointer"},children:t.relatedInvoice?.number})})]})]}),D&&!j.isEmpty(t.paymentIntent?.beneficiaries)&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsx(c,{className:"section",children:e.jsx(l,{variant:"h3",className:"section-header",children:s("customer.invoice.donation")})}),e.jsx(c,{sx:{maxWidth:800},children:e.jsx(ue,{data:t?.paymentIntent?.beneficiaries,currency:t.paymentCurrency,totalAmount:t?.amount_paid})})]}),t?.relatedCreditGrants&&t.relatedCreditGrants.length>0&&e.jsx(ve,{grants:t.relatedCreditGrants}),!L&&!D&&e.jsxs(e.Fragment,{children:[!M&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsxs(c,{className:"section",children:[e.jsx(l,{variant:"h3",className:"section-header",sx:{mb:1.5},children:s("admin.invoiceItems")}),e.jsx(_e,{invoice:t,simple:!0})]})]}),e.jsx(k,{}),e.jsxs(c,{className:"section",children:[e.jsx(l,{variant:"h3",className:"section-header",children:s("admin.refunds")}),e.jsx(c,{className:"section-body",children:e.jsx(De,{invoice_id:t.id,type:"table"})})]})]})]})}const Le=H(x)`
|
|
15
15
|
.invoice-summary-wrapper {
|
|
16
16
|
display: 'grid';
|
|
17
17
|
grid-template-columns: '50% 50%';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as v,w as C,B as o,a3 as r,bv as I,q as p,x as A,N as D,Y as
|
|
1
|
+
import{j as e,A as v,w as C,B as o,a3 as r,bv as I,q as p,x as A,N as D,Y as P,bf as N}from"./vendor-mui-BXZut9Pz.js";import{V as S,P as _}from"./vendor-blocklet-DcLR2Cyf.js";import{d as R,i as B,a5 as W,n as M,a6 as T,a7 as f,j as L,p as q,e as z}from"./index-BarN7DfU.js";import{I as y}from"./info-metric-Dl4ZDm0Z.js";import{I as l}from"./info-row-jI0h_hv4.js";import{S as H}from"./header-ivXuPt06.js";import{g as O}from"./util-DxXTXkeY.js";import{C as j}from"./link-CmPoIweR.js";import{I as E}from"./info-row-group-CFuMWJf1.js";import{u as F}from"./browser-DDv4_sgY.js";import{e as G}from"./vendor-react-BPknnnEA.js";import"./lodash-B4Ozcv0x.js";const U=t=>z.get(`/api/payouts/${t}`).then(n=>n.data);function oe(){const{t,locale:n}=S(),{isMobile:g}=R(),h=F(),m=G(),{loading:w,error:c,data:s}=_(()=>U(m.id),{ready:!!m.id});if(c)return e.jsx(v,{severity:"error",children:c.message});if(w||!s)return e.jsx(C,{});const x=s.paymentCurrency,b=[B(s?.amount,x.decimal),x.symbol].join(" "),{paymentIntent:a,paymentLink:d}=s||{},i=a?.customer?.metadata?.anonymous;return e.jsxs(V,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(o,{children:[e.jsxs(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[h?e.jsx(o,{}):e.jsxs(r,{direction:"row",onClick:()=>O("/customer/payouts"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(I,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("common.previous")})]}),d?.donation_settings?.reference&&e.jsx(A,{variant:"outlined",onClick:()=>{window.open(d?.donation_settings?.reference,"_blank")},children:t("customer.payout.viewReference")})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(r,{direction:"row",sx:{alignItems:"center"},children:e.jsxs(r,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(D,{src:s.paymentCurrency.logo,alt:s.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsx(r,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:e.jsx(W,{amount:b,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}})})]})})}),e.jsxs(r,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(y,{label:t("common.status"),value:e.jsx(M,{label:s.status,color:T(s.status)}),divider:!0}),e.jsx(y,{label:t("customer.payout.payer"),value:e.jsx(j,{customer:a.customer,cardProps:{onAvatarClick:()=>{i||window.open(f(a?.customer?.did,n),"_blank")},renderName:u=>e.jsx(p,{variant:"subtitle1",sx:{...i?{}:{cursor:"pointer","&:hover":{color:"text.link"}}},onClick:()=>{if(i)return;const k=f(u?.did,n);window.open(k,"_blank")},children:u.fullName})},linked:!1}),divider:!0})]})]}),e.jsx(P,{})]}),e.jsx(r,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:e.jsx(o,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(o,{className:"section",children:[e.jsx(H,{title:t("common.detail")}),e.jsxs(E,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",lg:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"flex-start",lg:"center"}}},children:[e.jsx(l,{label:t("common.createdAt"),value:L(s.created_at)}),a&&a.payment_details&&e.jsx(l,{label:t("customer.payout.payTxHash"),value:e.jsx(q,{details:a.payment_details,method:s.paymentMethod,mode:"customer"})}),e.jsx(l,{label:t("customer.payout.receiver"),value:e.jsx(j,{customer:s.customer,linked:!1,size:g?"default":"small"})})]})]})})})]})}const V=N(r)``;export{oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,A as I,w as L,B as s,a3 as n,bv as $,q as m,O as z,Y as c,x as B,bf as G}from"./vendor-mui-BXZut9Pz.js";import{V as P,Y as H,P as O,Z as w}from"./vendor-blocklet-DcLR2Cyf.js";import{d as U,v as q,n as C,s as F,j as x,p as k,w as Y,e as T,k as V}from"./index-BarN7DfU.js";import{T as Z}from"./gas-nyR96dB0.js";import{L as f}from"./vendor-react-BPknnnEA.js";import{l as N}from"./lodash-B4Ozcv0x.js";import{C as J}from"./copyable-QrCyyiou.js";import{C as D}from"./currency-GstdXsJf.js";import{C as K}from"./link-CmPoIweR.js";import{E as Q}from"./list-DaK9287Y.js";import{I as i}from"./info-row-jI0h_hv4.js";import{D as X,R as ee,I as te}from"./related-credit-grants-JV2ICsR5.js";import{I as ae}from"./action-DENqSeOa.js";import{M as se}from"./editor-AmthipP2.js";import{M as ie}from"./list-CkHExntK.js";import{P as ne}from"./list-DghnUOc4.js";import{R as oe}from"./list-DLB_hd0Q.js";import{S as d}from"./header-ivXuPt06.js";import{g as re}from"./util-DxXTXkeY.js";import{I as h}from"./info-metric-Dl4ZDm0Z.js";import{I as le}from"./info-row-group-CFuMWJf1.js";import"./table-BrtHemkA.js";import"./browser-Bb9g-cvG.js";import"./usage-records-DAUQMJAW.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./generateCategoricalChart-BadryV3H.js";import"./form-CAPjlw7l.js";import"./cache-state-lld4zuDg.js";import"./filter-toolbar-DXGSTq57.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./actions-D3tJgrUn.js";import"./actions-0iWP2mcx.js";const me=p=>T.get(`/api/invoices/${p}?sync=true`).then(a=>a.data),M="column",S="flex-start";function Fe(p){const{t:a}=P(),{isMobile:y}=U(),[j,u]=H({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:R,error:b,data:t,runAsync:g}=O(()=>me(p.id));if(b)return e.jsx(I,{severity:"error",children:b.message});if(R||!t)return e.jsx(L,{});const E=(o=>async r=>{try{u(l=>({loading:{...l.loading,[o]:!0}})),await T.put(`/api/invoices/${p.id}`,r).then(l=>l.data),w.success(a("common.saved")),g()}catch(l){console.error(l),w.error(V(l))}finally{u(l=>({loading:{...l.loading,[o]:!1}}))}})("metadata"),v=()=>{u(o=>({editing:{...o.editing,metadata:!0}}))},W=o=>{let r=o;return r.startsWith("Slash stake")&&(r=a("payment.invoice.reason.slashStake")),r.startsWith("Subscription ")&&(r=a(`payment.invoice.reason.${r.replace("Subscription ","")}`)),r},_=t?.checkoutSession?.submit_type==="donate",A=["open","paid","uncollectible"].includes(t.status)&&!_&&!N.isEmpty(t.lines);return e.jsxs(ce,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(s,{children:[e.jsxs(n,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n,{direction:"row",onClick:()=>re("/admin/billing/invoices"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx($,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(m,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.invoices")})]}),e.jsxs(s,{style:{display:"flex",gap:"10px"},children:[A&&e.jsx(X,{data:t}),e.jsx(ae,{data:t,onChange:g,variant:"normal"})]})]}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(I,{severity:"warning",sx:{mt:2},children:e.jsx(m,{variant:"body2",children:a("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"})})}),e.jsxs(s,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(n,{direction:"column",sx:{gap:1},children:[e.jsxs(n,{direction:"row",sx:{alignItems:"center"},children:[e.jsx(m,{variant:"h2",sx:{fontWeight:600},children:t.number}),e.jsx(m,{variant:"h2",sx:{fontWeight:600,mx:1},children:"for"}),e.jsxs(m,{variant:"h2",sx:{fontWeight:600},children:[q(t.total,t.paymentCurrency.decimal)," ",t.paymentCurrency.symbol]})]}),e.jsx(J,{text:p.id,style:{marginLeft:4}})]}),e.jsxs(n,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(h,{label:a("common.status"),value:e.jsxs(n,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(C,{label:t.status,color:F(t.status)}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(z,{title:a("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"}),arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(C,{label:a("payment.customer.invoice.slippageExceeded"),color:"warning"})})})]}),divider:!0}),t.subscription&&e.jsx(h,{label:a("admin.subscription.name"),value:e.jsx(f,{to:`/admin/billing/${t.subscription.id}`,children:e.jsx(m,{variant:"body1",sx:{color:"text.link"},children:t.subscription.description||t.subscription.id})}),divider:!0}),e.jsx(h,{label:a("common.createdAt"),value:x(t.created_at),divider:!0}),e.jsx(h,{label:a("admin.subscription.currentPeriod"),value:t.period_start&&t.period_end?[x(t.period_start*1e3),x(t.period_end*1e3)].join(" ~ "):""})]})]}),e.jsx(c,{})]}),e.jsxs(n,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(s,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(d,{title:a("admin.details")}),e.jsxs(le,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(i,{label:a("admin.invoice.billTo"),value:e.jsx(K,{customer:t.customer,size:y?"default":"small"})}),e.jsx(i,{label:a("admin.invoice.from"),value:t.statement_descriptor||blocklet.appName}),e.jsx(i,{label:a("admin.invoice.description"),value:W(t.description||"")}),e.jsx(i,{label:a("admin.invoice.billing"),value:t.collection_method}),t.status_transitions?.finalized_at&&e.jsx(i,{label:a("admin.invoice.finalizedAt"),value:x(t.status_transitions.finalized_at*1e3)}),t.status_transitions?.paid_at&&e.jsx(i,{label:a("admin.invoice.paidAt"),value:x(t.status_transitions.paid_at*1e3)}),e.jsx(i,{label:a("admin.paymentMethod._name"),value:e.jsx(D,{logo:t.paymentMethod?.logo,name:t.paymentMethod?.name})}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:e.jsx(D,{logo:t.paymentCurrency.logo,name:`${t.paymentCurrency.symbol} (${t.paymentMethod?.name})`})}),(!!t.paymentIntent?.payment_details?.ethereum||!!t.paymentIntent?.payment_details?.base)&&e.jsx(i,{label:a("common.txGas"),value:e.jsx(Z,{details:t.paymentIntent.payment_details,method:t.paymentMethod})}),t.paymentIntent&&t.paymentIntent.payment_details&&e.jsx(i,{label:a(`common.${t.paymentIntent.payment_details?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(k,{details:t.paymentIntent.payment_details,method:t.paymentMethod,mode:"customer"})}),["stake","stake_overdraft_protection"].includes(t.billing_reason)&&t?.metadata?.payment_details?.arcblock?.tx_hash&&e.jsx(i,{label:a("common.stakeTxHash"),value:e.jsx(k,{details:{arcblock:{tx_hash:t.metadata?.payment_details?.arcblock?.tx_hash,payer:""}},method:t.paymentMethod})})]})]}),t?.relatedCreditGrants&&t.relatedCreditGrants.length>0&&e.jsx(ee,{grants:t.relatedCreditGrants,mode:"dashboard"}),e.jsx(c,{}),e.jsxs(s,{className:"section",children:[e.jsx(d,{title:a("admin.summary")}),e.jsx(m,{variant:"body2",sx:{color:"text.secondary",mb:2,fontSize:"0.875rem"},children:a("admin.invoice.billingContextNote")}),e.jsx(s,{className:"section-body",children:e.jsx(te,{invoice:t,emptyNodeText:a("empty.summary"),mode:"admin"})})]}),e.jsx(c,{}),_&&!N.isEmpty(t.paymentIntent?.beneficiaries)&&e.jsxs(e.Fragment,{children:[e.jsx(s,{className:"section",children:e.jsx(m,{variant:"h3",className:"section-header",children:a("customer.invoice.donation")})}),e.jsx(s,{sx:{maxWidth:800},children:e.jsx(Y,{data:t?.paymentIntent?.beneficiaries,currency:t.paymentCurrency,totalAmount:t?.amount_paid})}),e.jsx(c,{})]}),e.jsxs(s,{className:"section",children:[e.jsx(d,{title:a("admin.payments")}),e.jsx(s,{className:"section-body",children:e.jsx(ne,{features:{customer:!1,toolbar:!1},invoice_id:t.id})})]}),e.jsx(c,{}),e.jsxs(s,{className:"section",children:[e.jsx(d,{title:a("admin.refunds")}),e.jsx(s,{className:"section-body",children:e.jsx(oe,{features:{customer:!1,toolbar:!1},invoice_id:t.id})})]}),e.jsx(c,{}),e.jsxs(s,{className:"section",children:[e.jsx(d,{title:a("admin.events.title")}),e.jsx(s,{className:"section-body",children:e.jsx(Q,{features:{toolbar:!1},object_id:[t.id,t.payment_intent_id].filter(Boolean).join(",")})})]})]}),y&&e.jsx(c,{}),e.jsxs(s,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",children:[e.jsx(d,{title:a("admin.connections")}),e.jsxs(n,{children:[e.jsx(i,{label:a("admin.subscription.name"),value:t.subscription?e.jsx(f,{to:`/admin/billing/${t.subscription.id}`,children:t.subscription.id}):"",direction:M,alignItems:S}),e.jsx(i,{label:a("admin.paymentIntent.name"),value:t.payment_intent_id?e.jsx(f,{to:`/admin/payments/${t.payment_intent_id}`,children:t.payment_intent_id}):"",direction:M,alignItems:S})]})]}),e.jsx(c,{}),e.jsxs(s,{className:"section",children:[e.jsx(d,{title:a("common.metadata.label"),children:e.jsx(B,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:j.editing.metadata,onClick:v,children:a("common.edit")})}),e.jsxs(s,{className:"section-body",children:[e.jsx(ie,{data:t.metadata,handleEditMetadata:v}),j.editing.metadata&&e.jsx(se,{data:t,loading:j.loading.metadata,onSave:E,onCancel:()=>u(o=>({editing:{...o.editing,metadata:!1}}))})]})]})]})]})]})}const ce=G(n)``;export{Fe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,j as e,w as K,q as C,B as p,a2 as V,a3 as b,x as P,N as G,A as J,z as le,bv as me,Y as R,bH as ue,bf as pe}from"./vendor-mui-BXZut9Pz.js";import{V as B,N as xe,O as Q,$ as fe,X as he,Y as T}from"./vendor-blocklet-D_i_QeSo.js";import{b9 as E,n as Z,j as O,T as ee,e as k,d as oe,a as te,aM as ge,Y as q,f as je,I as ye,b8 as z,k as F,v as X}from"./index-DgSc1Qy8.js";import{C as ne}from"./copyable-DpX04wZz.js";import{E as be}from"./list-D1aevUOI.js";import{I as A}from"./info-metric-CNse3r66.js";import{I as w}from"./info-row-DOK2whMn.js";import{I as Ce}from"./info-row-group-BeUhWnnY.js";import{M as ve}from"./editor-BF5I0siU.js";import{M as _e}from"./list-C521zE_7.js";import{S as M}from"./header-ivXuPt06.js";import{g as we}from"./util-mDHAL0lx.js";import{L as U,a as Se}from"./vendor-react-BPknnnEA.js";import{P as Re,a as ae,C as Me,A as De}from"./currency-restrictions-DYLv4YyW.js";import"./table-BRU4Enia.js";import"./lodash-B4Ozcv0x.js";import"./form-BGm5NPDn.js";import"./index-Clbt8nRm.js";import"./collapse-CSrlJ0eG.js";import"./drawer-form-Cl0T1Yyt.js";import"./currency-select-DGS-62-L.js";import"./currency-GstdXsJf.js";import"./product-select-0ScZE2e8.js";import"./form-P4luyUpY.js";import"./info-card-C1yxhxJG.js";import"./uploader-DRXDz_r0.js";import"./tax-code-select-CWhIIiXi.js";import"./collapse-BvbJGg1V.js";import"./actions-jxGAdGfb.js";import"./link-DMWJcQvZ.js";import"./link-3eeclTeS.js";import"./description-Ym17DL48.js";import"./status-l6pD08fw.js";const Le=(s,o={})=>{const h=new URLSearchParams;return h.set("coupon_id",s),Object.keys(o).forEach(x=>{const r=o[x];r!==""&&r!==void 0&&r!==null&&(typeof r=="object"?Object.keys(r).length>0&&h.set(x,JSON.stringify(r)):h.set(x,String(r)))}),k.get(`/api/promotion-codes?${h.toString()}`).then(x=>x.data)};function Te({couponId:s}){const{t:o}=B(),[h,x]=v.useState(!1),[r,y]=v.useState(null),[d,c]=xe(`promotion-codes-${s}`,{defaultValue:{pageSize:20,page:1}}),{data:l={list:[],count:0},refresh:a,loading:_}=Q(()=>Le(s,d),{refreshDeps:[d,s]});E("promotion-code.created",()=>a(),[]),E("promotion-code.updated",()=>a(),[]),E("promotion-code.deleted",()=>a(),[]),v.useEffect(()=>{a()},[d,s]);const S=(t,u)=>{t==="edit"&&u?(y(u),x(!0)):a()},j=()=>{x(!1),y(null)},m=l?.list||[];if(_)return e.jsx(K,{});const W=[{label:o("admin.promotionCode.code"),name:"code",options:{filter:!0,customBodyRenderLite:(t,u)=>{const i=m?.[u];return e.jsx(ne,{text:i.code,children:e.jsx(U,{to:`/admin/products/coupons/promotion-codes/${i.id}`,children:e.jsx(C,{sx:{color:"text.primary",fontWeight:500,mr:1},children:i.code})})})}}},{label:o("admin.promotionCode.status"),name:"active",options:{filter:!0,customBodyRenderLite:(t,u)=>{const i=m?.[u],$=i.expires_at&&Math.floor(Date.now()/1e3)>i.expires_at,I=i.max_redemptions&&i.times_redeemed>=i.max_redemptions;let D=o("admin.promotionCode.active"),L="success";return i.active||(D=o("admin.promotionCode.inactive"),L="default"),$?(D=o("admin.promotionCode.expired"),L="warning"):I&&(D=o("admin.promotionCode.maxedOut"),L="warning"),e.jsx(Z,{label:D,color:L})}}},{label:o("admin.promotionCode.redemptions"),name:"redemptions",options:{filter:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u],$=i.max_redemptions||o("admin.coupon.unlimited");return`${i.times_redeemed||0} / ${$}`}}},{label:o("admin.promotionCode.expires"),name:"expires_at",options:{filter:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u];return i.expires_at?O(i.expires_at*1e3):"—"}}},{label:o("admin.promotionCode.created"),name:"created_at",options:{filter:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u];return O(i.created_at)}}},{label:o("admin.promotionCode.actions"),name:"actions",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u];return e.jsx(Re,{data:i,onChange:S,variant:"compact"})}}}],N=({page:t,rowsPerPage:u})=>{d.pageSize!==u?c(i=>({...i,pageSize:u,page:1})):d.page!==t+1&&c(i=>({...i,page:t+1}))};return e.jsxs(e.Fragment,{children:[e.jsx(ee,{hasRowLink:!1,toolbar:!1,footer:!1,data:m,columns:W,options:{count:l?.count,page:d.page-1,rowsPerPage:d.pageSize,onSearchChange:t=>{c(t?{...d,q:{"like-code":t},pageSize:100,page:1}:{...d,pageSize:100,page:1,q:void 0})}},loading:_,onChange:N}),e.jsx(ae,{open:h,onClose:j,onSubmit:a,couponId:s,promotionCode:r,isEditing:!0})]})}function Pe({open:s,onClose:o,onSave:h,initialName:x,initialDescription:r="",loading:y=!1}){const{t:d}=B(),[c,l]=v.useState(x),[a,_]=v.useState(r);v.useEffect(()=>{s&&(l(x),_(r))},[s,x,r]);const S=async()=>{c.trim()&&(await h({name:c.trim(),description:a.trim()}),o())},j=()=>{l(x),_(r),o()};return e.jsx(fe,{open:s,onClose:j,maxWidth:"sm",fullWidth:!0,title:d("admin.coupon.updateCouponDetails"),PaperProps:{sx:{borderRadius:2}},actions:e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(P,{variant:"outlined",onClick:j,disabled:y,children:d("common.cancel")}),e.jsx(P,{variant:"contained",onClick:S,disabled:y||!c.trim()||c.trim()===x&&a.trim()===r,children:d("admin.coupon.updateCouponButton")})]}),children:e.jsxs(p,{children:[e.jsx(C,{variant:"h6",sx:{mb:2},children:d("admin.coupon.name")}),e.jsx(V,{autoFocus:!0,fullWidth:!0,value:c,onChange:m=>l(m.target.value),variant:"outlined",sx:{mb:1},inputProps:{maxLength:64}}),e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mb:3},children:d("admin.coupon.nameWillAppear")}),e.jsx(C,{variant:"h6",sx:{mb:2},children:d("admin.coupon.desc")}),e.jsx(V,{fullWidth:!0,value:a,onChange:m=>_(m.target.value),variant:"outlined",multiline:!0,minRows:2,maxRows:4,sx:{mb:1},placeholder:d("admin.coupon.desc"),slotProps:{htmlInput:{maxLength:250}}}),e.jsx(C,{variant:"body2",sx:{color:"text.secondary"},children:d("admin.coupon.descriptionInternal")})]})})}function Oe({products:s}){const{t:o}=B(),{isMobile:h}=oe(),{settings:x}=te(),r=c=>{if(!c.prices||c.prices.length===0)return null;if(c.prices.length===1){const l=c.prices[0];if(l){const a=q(x.paymentMethods,l.currency_id??"")||x.baseCurrency;return je(l,a)}}return o("admin.price.count",{count:c.prices.length})},y=h?{width:24,height:24}:{width:48,height:48},d=[{label:o("admin.subscription.product"),name:"name",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return e.jsxs(b,{sx:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:{xs:1,sm:2}},children:[e.jsx(p,{children:a.images&&a.images.length>0?e.jsx(G,{src:a.images[0],alt:a.name,variant:"rounded",sx:y},a.id):e.jsx(G,{variant:"rounded",sx:y,children:a.name.slice(0,1)},a.id)}),e.jsxs(p,{children:[e.jsx(C,{sx:{color:"text.primary",fontWeight:600},children:e.jsx(U,{to:`/admin/products/${a.id}`,children:e.jsx(ge,{text:a.name,maxLength:h?20:50,useWidth:!0})})}),!h&&e.jsx(C,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:r(a)})]})]})}}},h&&{label:o("admin.product.pricing"),name:"prices",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return e.jsx(U,{to:`/admin/products/${a.id}`,children:r(a)})}}},{label:o("admin.product.type.label"),name:"type",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return o(`admin.product.type.${a.type}`)}}},{label:o("common.created"),name:"created_at",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return O(a.created_at)}}}].filter(Boolean);return e.jsx(ee,{data:s,columns:d,loading:!1,footer:!1,toolbar:!1,components:{TableToolbar:()=>null,TableFooter:()=>null},mobileTDFlexDirection:"row",options:{count:s.length,page:0,rowsPerPage:100,selectableRows:"none",pagination:!1},emptyNodeText:o("admin.coupon.noApplicableProducts")})}const $e=s=>k.get(`/api/coupons/${s}`).then(o=>o.data);function ho(s){const{t:o}=B(),{isMobile:h}=oe(),x=Se(),{settings:r,setLivemode:y}=te(),[d,c]=v.useState(!1),[l,a]=v.useState(!1),[_,S]=v.useState(!1),[j,m]=he({editing:{metadata:!1},loading:{metadata:!1,coupon:!1,delete:!1}}),{loading:W,error:N,data:t,runAsync:u}=Q(()=>$e(s.id),{onSuccess:n=>{y(!!n.livemode)}});if(N)return e.jsx(J,{severity:"error",children:N.message});if(W||!t)return e.jsx(K,{});const i=n=>async f=>{try{m(g=>({loading:{...g.loading,[n]:!0}})),await k.put(`/api/coupons/${s.id}`,f),T.success(o("common.saved")),z("coupon.updated"),u()}catch(g){console.error(g),T.error(F(g))}finally{m(g=>({loading:{...g.loading,[n]:!1}}))}},$=async n=>{try{m(f=>({loading:{...f.loading,metadata:!0}})),await k.put(`/api/coupons/${s.id}`,{metadata:n.metadata}),T.success(o("common.saved")),z("coupon.updated"),u()}catch(f){console.error(f),T.error(F(f))}finally{m(f=>({loading:{...f.loading,metadata:!1}}))}},I=async n=>{await i("coupon")(n)},D=async()=>{try{m(n=>({loading:{...n.loading,delete:!0}})),await k.delete(`/api/coupons/${s.id}`),T.success(o("admin.coupon.deletedSuccessfully")),z("coupon.deleted"),x("/admin/products/coupons")}catch(n){console.error(n),T.error(F(n))}finally{m(n=>({loading:{...n.loading,delete:!1}})),S(!1)}},L=()=>{S(!0)},H=!t?.locked&&(!t?.promotion_codes||t.promotion_codes.length===0),Y=()=>{m(n=>({editing:{...n.editing,metadata:!0}}))},se=n=>{let f="";if(n.percent_off&&n.percent_off>0&&(f=`${n.percent_off}%`),n.amount_off&&n.amount_off!=="0"){const g=q(r.paymentMethods,n.currency_id)||r.baseCurrency;f=`${X(n.amount_off,g.decimal)} ${g.symbol}`}return f?o(`admin.coupon.couponTerms.${n.duration}`,{couponOff:f,months:n.duration_in_months}):o("admin.coupon.noDiscount")},ie=()=>{if(t.percent_off&&t.percent_off>0)return o("admin.coupon.couponTermsPercentage",{percent:t.percent_off});if(t.amount_off&&t.amount_off!=="0"){const n=q(r.paymentMethods,t.currency_id)||r.baseCurrency;return o("admin.coupon.couponTermsFixedAmount",{amount:X(t.amount_off,n.decimal),symbol:n.symbol})}return o("admin.coupon.noDiscount")},re=()=>t.duration==="repeating"&&t.duration_in_months?o(`admin.coupon.couponTermsDuration.${t.duration}`,{months:t.duration_in_months}):o(`admin.coupon.couponTermsDuration.${t.duration}`),ce=()=>{const n=t.max_redemptions?t.max_redemptions.toString():o("admin.coupon.unlimited");return`${t.times_redeemed||0} / ${n}`},de=(()=>{const n=r.paymentMethods?.flatMap(g=>g.payment_currencies)||[];if(t.percent_off)return n;const f=new Set;return t.currency_id&&f.add(t.currency_id),t.currency_options&&typeof t.currency_options=="object"&&Object.keys(t.currency_options).forEach(g=>{f.add(g)}),n.filter(g=>f.has(g.id))})();return e.jsxs(ke,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(p,{children:[!t.valid&&e.jsxs(J,{severity:"warning",children:[e.jsx(le,{children:o("admin.coupon.inactive")}),o("admin.coupon.inactiveTip")]}),e.jsxs(b,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(b,{direction:"row",onClick:()=>we("/admin/products/coupons"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(me,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(C,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:o("admin.coupons")})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(P,{variant:"contained",color:"primary",onClick:()=>a(!0),children:o("common.edit")}),H&&e.jsx(P,{variant:"outlined",color:"error",onClick:L,disabled:j.loading.delete,title:!H&&t?.promotion_codes?.length>0?o("admin.coupon.cannotDeleteWithPromotionCodes"):void 0,children:j.loading.delete?o("common.deleting"):o("common.delete")})]})]}),e.jsxs(p,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(b,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(b,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(C,{variant:"h2",sx:{color:"text.primary"},children:t.name}),e.jsx(C,{variant:"subtitle1",sx:{color:"text.lighter"},children:se(t)})]})}),e.jsxs(b,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(A,{label:o("admin.coupon.id"),value:e.jsx(ne,{text:s.id,style:{marginLeft:4}}),divider:!0}),e.jsx(A,{label:o("admin.coupon.redemptions"),value:ce(),divider:!0}),e.jsx(A,{label:o("common.status"),value:e.jsx(Z,{label:t.valid?o("common.active"):o("common.inactive"),color:t.valid?"success":"default"}),divider:!0}),e.jsx(A,{label:o("common.created"),value:O(t.created_at),divider:!0})]})]}),e.jsx(R,{})]}),e.jsxs(b,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".coupon-column-1":{minWidth:{xs:"100%",lg:"600px"}},".coupon-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(p,{className:"coupon-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(p,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(M,{title:o("common.details")}),e.jsxs(Ce,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(w,{label:o("admin.coupon.name"),value:t.name}),t.description&&e.jsx(w,{label:o("admin.coupon.desc"),value:t.description}),e.jsx(w,{label:o("admin.coupon.discount"),value:ie()}),e.jsx(w,{label:o("admin.coupon.duration"),value:re()}),e.jsx(w,{label:o("admin.coupon.maxRedemptions"),value:t.max_redemptions||o("admin.coupon.unlimited")}),e.jsx(w,{label:o("admin.coupon.timesRedeemed"),value:t.times_redeemed||0}),e.jsx(w,{label:o("admin.coupon.expires"),value:t.redeem_by?O(t.redeem_by*1e3):o("common.never")}),e.jsx(w,{label:o("admin.coupon.updated"),value:O(t.updated_at)})]})]}),e.jsx(R,{}),t.currency_options&&Object.keys(t.currency_options).length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.currencies")}),e.jsx(p,{className:"section-body",children:e.jsx(Me,{currencyOptions:t.currency_options,type:"coupon"})})]}),e.jsx(R,{})]}),t.applied_products&&t.applied_products.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.applicableProducts")}),e.jsx(p,{className:"section-body",children:e.jsx(Oe,{products:t.applied_products})})]}),e.jsx(R,{})]}),e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.promotionCodes"),children:e.jsx(P,{variant:"text",color:"inherit",size:"small",startIcon:e.jsx(ue,{}),sx:{color:"text.link"},onClick:()=>c(!0),children:o("admin.coupon.addPromotionCode")})}),e.jsx(p,{className:"section-body",children:e.jsx(Te,{couponId:s.id})})]}),e.jsx(R,{}),e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.activeRedemptions")}),e.jsx(p,{className:"section-body",children:e.jsx(De,{couponId:s.id})})]}),e.jsx(R,{}),e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("common.events")}),e.jsx(p,{className:"section-body",children:e.jsx(be,{features:{toolbar:!1},object_id:t.id})})]})]}),h&&e.jsx(R,{}),e.jsx(p,{className:"coupon-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("common.metadata.label"),children:e.jsx(P,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:j.editing.metadata,onClick:Y,children:o("common.edit")})}),e.jsxs(p,{className:"section-body",children:[e.jsx(_e,{data:t.metadata,handleEditMetadata:Y}),j.editing.metadata&&e.jsx(ve,{data:t,loading:j.loading.metadata,onSave:$,onCancel:()=>m(n=>({editing:{...n.editing,metadata:!1}}))})]})]})})]}),e.jsx(ae,{open:d,onClose:()=>c(!1),onSubmit:()=>c(!1),couponId:s.id,availableCurrencies:de}),e.jsx(Pe,{open:l,onClose:()=>a(!1),onSave:I,initialName:t.name,initialDescription:t.description||"",loading:j.loading.coupon}),_&&e.jsx(ye,{onConfirm:D,onCancel:()=>S(!1),title:o("admin.coupon.deleteConfirmTitle"),message:o("admin.coupon.deleteConfirmMessage"),loading:j.loading.delete})]})}const ke=pe(b)``;export{ho as default};
|
|
1
|
+
import{r as v,j as e,w as K,q as C,B as p,a2 as V,a3 as b,x as P,N as G,A as J,z as le,bv as me,Y as R,bH as ue,bf as pe}from"./vendor-mui-BXZut9Pz.js";import{V as B,O as xe,P as Q,$ as fe,Y as he,Z as T}from"./vendor-blocklet-DcLR2Cyf.js";import{b9 as E,n as X,j as O,T as ee,e as k,d as oe,a as te,aM as ge,Y as q,f as je,I as ye,b8 as z,k as F,v as Z}from"./index-BarN7DfU.js";import{C as ne}from"./copyable-QrCyyiou.js";import{E as be}from"./list-DaK9287Y.js";import{I as A}from"./info-metric-Dl4ZDm0Z.js";import{I as w}from"./info-row-jI0h_hv4.js";import{I as Ce}from"./info-row-group-CFuMWJf1.js";import{M as ve}from"./editor-AmthipP2.js";import{M as _e}from"./list-CkHExntK.js";import{S as M}from"./header-ivXuPt06.js";import{g as we}from"./util-DxXTXkeY.js";import{L as U,a as Se}from"./vendor-react-BPknnnEA.js";import{P as Re,a as ae,C as Me,A as De}from"./currency-restrictions-BcEm8W45.js";import"./table-BrtHemkA.js";import"./lodash-B4Ozcv0x.js";import"./form-CAPjlw7l.js";import"./index-DoX0A-rP.js";import"./collapse-CSrlJ0eG.js";import"./drawer-form-DspWWj3x.js";import"./currency-select-B4ieQBvv.js";import"./currency-GstdXsJf.js";import"./product-select-ChEyoJqJ.js";import"./form-cX026J4G.js";import"./info-card-BvIMFQo5.js";import"./uploader-CsQNHG4I.js";import"./tax-code-select-TS07I0rB.js";import"./collapse-BvbJGg1V.js";import"./actions-BJDN6Op2.js";import"./link-DMWJcQvZ.js";import"./link-CmPoIweR.js";import"./description-SnR5WxWT.js";import"./status-CUVYrUIG.js";const Le=(s,o={})=>{const h=new URLSearchParams;return h.set("coupon_id",s),Object.keys(o).forEach(x=>{const r=o[x];r!==""&&r!==void 0&&r!==null&&(typeof r=="object"?Object.keys(r).length>0&&h.set(x,JSON.stringify(r)):h.set(x,String(r)))}),k.get(`/api/promotion-codes?${h.toString()}`).then(x=>x.data)};function Te({couponId:s}){const{t:o}=B(),[h,x]=v.useState(!1),[r,y]=v.useState(null),[d,c]=xe(`promotion-codes-${s}`,{defaultValue:{pageSize:20,page:1}}),{data:l={list:[],count:0},refresh:a,loading:_}=Q(()=>Le(s,d),{refreshDeps:[d,s]});E("promotion-code.created",()=>a(),[]),E("promotion-code.updated",()=>a(),[]),E("promotion-code.deleted",()=>a(),[]),v.useEffect(()=>{a()},[d,s]);const S=(t,u)=>{t==="edit"&&u?(y(u),x(!0)):a()},j=()=>{x(!1),y(null)},m=l?.list||[];if(_)return e.jsx(K,{});const W=[{label:o("admin.promotionCode.code"),name:"code",options:{filter:!0,customBodyRenderLite:(t,u)=>{const i=m?.[u];return e.jsx(ne,{text:i.code,children:e.jsx(U,{to:`/admin/products/coupons/promotion-codes/${i.id}`,children:e.jsx(C,{sx:{color:"text.primary",fontWeight:500,mr:1},children:i.code})})})}}},{label:o("admin.promotionCode.status"),name:"active",options:{filter:!0,customBodyRenderLite:(t,u)=>{const i=m?.[u],$=i.expires_at&&Math.floor(Date.now()/1e3)>i.expires_at,N=i.max_redemptions&&i.times_redeemed>=i.max_redemptions;let D=o("admin.promotionCode.active"),L="success";return i.active||(D=o("admin.promotionCode.inactive"),L="default"),$?(D=o("admin.promotionCode.expired"),L="warning"):N&&(D=o("admin.promotionCode.maxedOut"),L="warning"),e.jsx(X,{label:D,color:L})}}},{label:o("admin.promotionCode.redemptions"),name:"redemptions",options:{filter:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u],$=i.max_redemptions||o("admin.coupon.unlimited");return`${i.times_redeemed||0} / ${$}`}}},{label:o("admin.promotionCode.expires"),name:"expires_at",options:{filter:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u];return i.expires_at?O(i.expires_at*1e3):"—"}}},{label:o("admin.promotionCode.created"),name:"created_at",options:{filter:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u];return O(i.created_at)}}},{label:o("admin.promotionCode.actions"),name:"actions",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const i=m?.[u];return e.jsx(Re,{data:i,onChange:S,variant:"compact"})}}}],I=({page:t,rowsPerPage:u})=>{d.pageSize!==u?c(i=>({...i,pageSize:u,page:1})):d.page!==t+1&&c(i=>({...i,page:t+1}))};return e.jsxs(e.Fragment,{children:[e.jsx(ee,{hasRowLink:!1,toolbar:!1,footer:!1,data:m,columns:W,options:{count:l?.count,page:d.page-1,rowsPerPage:d.pageSize,onSearchChange:t=>{c(t?{...d,q:{"like-code":t},pageSize:100,page:1}:{...d,pageSize:100,page:1,q:void 0})}},loading:_,onChange:I}),e.jsx(ae,{open:h,onClose:j,onSubmit:a,couponId:s,promotionCode:r,isEditing:!0})]})}function Pe({open:s,onClose:o,onSave:h,initialName:x,initialDescription:r="",loading:y=!1}){const{t:d}=B(),[c,l]=v.useState(x),[a,_]=v.useState(r);v.useEffect(()=>{s&&(l(x),_(r))},[s,x,r]);const S=async()=>{c.trim()&&(await h({name:c.trim(),description:a.trim()}),o())},j=()=>{l(x),_(r),o()};return e.jsx(fe,{open:s,onClose:j,maxWidth:"sm",fullWidth:!0,title:d("admin.coupon.updateCouponDetails"),PaperProps:{sx:{borderRadius:2}},actions:e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(P,{variant:"outlined",onClick:j,disabled:y,children:d("common.cancel")}),e.jsx(P,{variant:"contained",onClick:S,disabled:y||!c.trim()||c.trim()===x&&a.trim()===r,children:d("admin.coupon.updateCouponButton")})]}),children:e.jsxs(p,{children:[e.jsx(C,{variant:"h6",sx:{mb:2},children:d("admin.coupon.name")}),e.jsx(V,{autoFocus:!0,fullWidth:!0,value:c,onChange:m=>l(m.target.value),variant:"outlined",sx:{mb:1},inputProps:{maxLength:64}}),e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mb:3},children:d("admin.coupon.nameWillAppear")}),e.jsx(C,{variant:"h6",sx:{mb:2},children:d("admin.coupon.desc")}),e.jsx(V,{fullWidth:!0,value:a,onChange:m=>_(m.target.value),variant:"outlined",multiline:!0,minRows:2,maxRows:4,sx:{mb:1},placeholder:d("admin.coupon.desc"),slotProps:{htmlInput:{maxLength:250}}}),e.jsx(C,{variant:"body2",sx:{color:"text.secondary"},children:d("admin.coupon.descriptionInternal")})]})})}function Oe({products:s}){const{t:o}=B(),{isMobile:h}=oe(),{settings:x}=te(),r=c=>{if(!c.prices||c.prices.length===0)return null;if(c.prices.length===1){const l=c.prices[0];if(l){const a=q(x.paymentMethods,l.currency_id??"")||x.baseCurrency;return je(l,a)}}return o("admin.price.count",{count:c.prices.length})},y=h?{width:24,height:24}:{width:48,height:48},d=[{label:o("admin.subscription.product"),name:"name",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return e.jsxs(b,{sx:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:{xs:1,sm:2}},children:[e.jsx(p,{children:a.images&&a.images.length>0?e.jsx(G,{src:a.images[0],alt:a.name,variant:"rounded",sx:y},a.id):e.jsx(G,{variant:"rounded",sx:y,children:a.name.slice(0,1)},a.id)}),e.jsxs(p,{children:[e.jsx(C,{sx:{color:"text.primary",fontWeight:600},children:e.jsx(U,{to:`/admin/products/${a.id}`,children:e.jsx(ge,{text:a.name,maxLength:h?20:50,useWidth:!0})})}),!h&&e.jsx(C,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:r(a)})]})]})}}},h&&{label:o("admin.product.pricing"),name:"prices",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return e.jsx(U,{to:`/admin/products/${a.id}`,children:r(a)})}}},{label:o("admin.product.type.label"),name:"type",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return o(`admin.product.type.${a.type}`)}}},{label:o("common.created"),name:"created_at",options:{customBodyRenderLite:(c,l)=>{const a=s[l];return O(a.created_at)}}}].filter(Boolean);return e.jsx(ee,{data:s,columns:d,loading:!1,footer:!1,toolbar:!1,components:{TableToolbar:()=>null,TableFooter:()=>null},mobileTDFlexDirection:"row",options:{count:s.length,page:0,rowsPerPage:100,selectableRows:"none",pagination:!1},emptyNodeText:o("admin.coupon.noApplicableProducts")})}const $e=s=>k.get(`/api/coupons/${s}`).then(o=>o.data);function ho(s){const{t:o}=B(),{isMobile:h}=oe(),x=Se(),{settings:r,setLivemode:y}=te(),[d,c]=v.useState(!1),[l,a]=v.useState(!1),[_,S]=v.useState(!1),[j,m]=he({editing:{metadata:!1},loading:{metadata:!1,coupon:!1,delete:!1}}),{loading:W,error:I,data:t,runAsync:u}=Q(()=>$e(s.id),{onSuccess:n=>{y(!!n.livemode)}});if(I)return e.jsx(J,{severity:"error",children:I.message});if(W||!t)return e.jsx(K,{});const i=n=>async f=>{try{m(g=>({loading:{...g.loading,[n]:!0}})),await k.put(`/api/coupons/${s.id}`,f),T.success(o("common.saved")),z("coupon.updated"),u()}catch(g){console.error(g),T.error(F(g))}finally{m(g=>({loading:{...g.loading,[n]:!1}}))}},$=async n=>{try{m(f=>({loading:{...f.loading,metadata:!0}})),await k.put(`/api/coupons/${s.id}`,{metadata:n.metadata}),T.success(o("common.saved")),z("coupon.updated"),u()}catch(f){console.error(f),T.error(F(f))}finally{m(f=>({loading:{...f.loading,metadata:!1}}))}},N=async n=>{await i("coupon")(n)},D=async()=>{try{m(n=>({loading:{...n.loading,delete:!0}})),await k.delete(`/api/coupons/${s.id}`),T.success(o("admin.coupon.deletedSuccessfully")),z("coupon.deleted"),x("/admin/products/coupons")}catch(n){console.error(n),T.error(F(n))}finally{m(n=>({loading:{...n.loading,delete:!1}})),S(!1)}},L=()=>{S(!0)},H=!t?.locked&&(!t?.promotion_codes||t.promotion_codes.length===0),Y=()=>{m(n=>({editing:{...n.editing,metadata:!0}}))},se=n=>{let f="";if(n.percent_off&&n.percent_off>0&&(f=`${n.percent_off}%`),n.amount_off&&n.amount_off!=="0"){const g=q(r.paymentMethods,n.currency_id)||r.baseCurrency;f=`${Z(n.amount_off,g.decimal)} ${g.symbol}`}return f?o(`admin.coupon.couponTerms.${n.duration}`,{couponOff:f,months:n.duration_in_months}):o("admin.coupon.noDiscount")},ie=()=>{if(t.percent_off&&t.percent_off>0)return o("admin.coupon.couponTermsPercentage",{percent:t.percent_off});if(t.amount_off&&t.amount_off!=="0"){const n=q(r.paymentMethods,t.currency_id)||r.baseCurrency;return o("admin.coupon.couponTermsFixedAmount",{amount:Z(t.amount_off,n.decimal),symbol:n.symbol})}return o("admin.coupon.noDiscount")},re=()=>t.duration==="repeating"&&t.duration_in_months?o(`admin.coupon.couponTermsDuration.${t.duration}`,{months:t.duration_in_months}):o(`admin.coupon.couponTermsDuration.${t.duration}`),ce=()=>{const n=t.max_redemptions?t.max_redemptions.toString():o("admin.coupon.unlimited");return`${t.times_redeemed||0} / ${n}`},de=(()=>{const n=r.paymentMethods?.flatMap(g=>g.payment_currencies)||[];if(t.percent_off)return n;const f=new Set;return t.currency_id&&f.add(t.currency_id),t.currency_options&&typeof t.currency_options=="object"&&Object.keys(t.currency_options).forEach(g=>{f.add(g)}),n.filter(g=>f.has(g.id))})();return e.jsxs(ke,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(p,{children:[!t.valid&&e.jsxs(J,{severity:"warning",children:[e.jsx(le,{children:o("admin.coupon.inactive")}),o("admin.coupon.inactiveTip")]}),e.jsxs(b,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(b,{direction:"row",onClick:()=>we("/admin/products/coupons"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(me,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(C,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:o("admin.coupons")})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(P,{variant:"contained",color:"primary",onClick:()=>a(!0),children:o("common.edit")}),H&&e.jsx(P,{variant:"outlined",color:"error",onClick:L,disabled:j.loading.delete,title:!H&&t?.promotion_codes?.length>0?o("admin.coupon.cannotDeleteWithPromotionCodes"):void 0,children:j.loading.delete?o("common.deleting"):o("common.delete")})]})]}),e.jsxs(p,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(b,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(b,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(C,{variant:"h2",sx:{color:"text.primary"},children:t.name}),e.jsx(C,{variant:"subtitle1",sx:{color:"text.lighter"},children:se(t)})]})}),e.jsxs(b,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(A,{label:o("admin.coupon.id"),value:e.jsx(ne,{text:s.id,style:{marginLeft:4}}),divider:!0}),e.jsx(A,{label:o("admin.coupon.redemptions"),value:ce(),divider:!0}),e.jsx(A,{label:o("common.status"),value:e.jsx(X,{label:t.valid?o("common.active"):o("common.inactive"),color:t.valid?"success":"default"}),divider:!0}),e.jsx(A,{label:o("common.created"),value:O(t.created_at),divider:!0})]})]}),e.jsx(R,{})]}),e.jsxs(b,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".coupon-column-1":{minWidth:{xs:"100%",lg:"600px"}},".coupon-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(p,{className:"coupon-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(p,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(M,{title:o("common.details")}),e.jsxs(Ce,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(w,{label:o("admin.coupon.name"),value:t.name}),t.description&&e.jsx(w,{label:o("admin.coupon.desc"),value:t.description}),e.jsx(w,{label:o("admin.coupon.discount"),value:ie()}),e.jsx(w,{label:o("admin.coupon.duration"),value:re()}),e.jsx(w,{label:o("admin.coupon.maxRedemptions"),value:t.max_redemptions||o("admin.coupon.unlimited")}),e.jsx(w,{label:o("admin.coupon.timesRedeemed"),value:t.times_redeemed||0}),e.jsx(w,{label:o("admin.coupon.expires"),value:t.redeem_by?O(t.redeem_by*1e3):o("common.never")}),e.jsx(w,{label:o("admin.coupon.updated"),value:O(t.updated_at)})]})]}),e.jsx(R,{}),t.currency_options&&Object.keys(t.currency_options).length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.currencies")}),e.jsx(p,{className:"section-body",children:e.jsx(Me,{currencyOptions:t.currency_options,type:"coupon"})})]}),e.jsx(R,{})]}),t.applied_products&&t.applied_products.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.applicableProducts")}),e.jsx(p,{className:"section-body",children:e.jsx(Oe,{products:t.applied_products})})]}),e.jsx(R,{})]}),e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.promotionCodes"),children:e.jsx(P,{variant:"text",color:"inherit",size:"small",startIcon:e.jsx(ue,{}),sx:{color:"text.link"},onClick:()=>c(!0),children:o("admin.coupon.addPromotionCode")})}),e.jsx(p,{className:"section-body",children:e.jsx(Te,{couponId:s.id})})]}),e.jsx(R,{}),e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("admin.coupon.activeRedemptions")}),e.jsx(p,{className:"section-body",children:e.jsx(De,{couponId:s.id})})]}),e.jsx(R,{}),e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("common.events")}),e.jsx(p,{className:"section-body",children:e.jsx(be,{features:{toolbar:!1},object_id:t.id})})]})]}),h&&e.jsx(R,{}),e.jsx(p,{className:"coupon-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(p,{className:"section",children:[e.jsx(M,{title:o("common.metadata.label"),children:e.jsx(P,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:j.editing.metadata,onClick:Y,children:o("common.edit")})}),e.jsxs(p,{className:"section-body",children:[e.jsx(_e,{data:t.metadata,handleEditMetadata:Y}),j.editing.metadata&&e.jsx(ve,{data:t,loading:j.loading.metadata,onSave:$,onCancel:()=>m(n=>({editing:{...n.editing,metadata:!1}}))})]})]})})]}),e.jsx(ae,{open:d,onClose:()=>c(!1),onSubmit:()=>c(!1),couponId:s.id,availableCurrencies:de}),e.jsx(Pe,{open:l,onClose:()=>a(!1),onSave:N,initialName:t.name,initialDescription:t.description||"",loading:j.loading.coupon}),_&&e.jsx(ye,{onConfirm:D,onCancel:()=>S(!1),title:o("admin.coupon.deleteConfirmTitle"),message:o("admin.coupon.deleteConfirmMessage"),loading:j.loading.delete})]})}const ke=pe(b)``;export{ho as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as M,j as e,A as B,w as E,B as s,a3 as i,bv as W,q as o,x as b,N as g,Y as x,bf as F}from"./vendor-mui-BXZut9Pz.js";import{V as
|
|
1
|
+
import{r as M,j as e,A as B,w as E,B as s,a3 as i,bv as W,q as o,x as b,N as g,Y as x,bf as F}from"./vendor-mui-BXZut9Pz.js";import{V as P,Y as L,P as R,Z as v}from"./vendor-blocklet-DcLR2Cyf.js";import{k as w,a2 as $,a3 as C,i as _,N as z,j as h,p as H,A as O,e as I}from"./index-BarN7DfU.js";import{I as u}from"./info-metric-Dl4ZDm0Z.js";import{I as c}from"./info-row-jI0h_hv4.js";import{I as q}from"./info-row-group-CFuMWJf1.js";import{C as U}from"./copyable-QrCyyiou.js";import{S as l}from"./header-ivXuPt06.js";import{M as Y}from"./list-CkHExntK.js";import{M as V}from"./editor-AmthipP2.js";import{C as Z}from"./credit-grant-item-list-CeDAM3qV.js";import{g as J}from"./util-DxXTXkeY.js";import{E as K}from"./list-DaK9287Y.js";import{a as Q}from"./vendor-react-BPknnnEA.js";import"./lodash-B4Ozcv0x.js";import"./form-CAPjlw7l.js";import"./table-BrtHemkA.js";const X=d=>I.get(`/api/credit-grants/${d}`).then(a=>a.data);function fe({id:d}){const{t:a}=P(),N=Q(),[p,m]=L({editing:{metadata:!1,creditGrant:!1},loading:{metadata:!1,creditGrant:!1}}),{loading:D,error:j,data:t,runAsync:G}=R(()=>X(d)),k=M.useCallback(()=>{J("/admin/customers")},[]);if(j)return e.jsx(B,{severity:"error",children:w(j)});if(D||!t)return e.jsx(E,{});const f=t?.status==="depleted",S=r=>{switch(r){case"granted":return a("admin.customer.creditGrants.status.granted");case"pending":return a("admin.customer.creditGrants.status.pending");case"depleted":return a("admin.customer.creditGrants.status.depleted");case"expired":return a("admin.customer.creditGrants.status.expired");case"voided":return a("admin.customer.creditGrants.status.voided");default:return r}},A=()=>{if(!t.amount||!t.remaining_amount)return 0;const r=parseFloat(t.amount),n=parseFloat(t.remaining_amount);return(r-n)/r*100},T=async r=>{try{m(n=>({loading:{...n.loading,metadata:!0}})),await I.put(`/api/credit-grants/${d}`,r),v.success(a("common.saved")),G()}catch(n){console.error(n),v.error(w(n))}finally{m(n=>({loading:{...n.loading,metadata:!1}}))}},y=()=>{m(r=>({editing:{...r.editing,metadata:!0}}))};return e.jsxs(ee,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(s,{children:[e.jsxs(i,{className:"page-header",direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(i,{direction:"row",alignItems:"center",sx:{fontWeight:"normal",cursor:"pointer"},onClick:k,children:[e.jsx(W,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(o,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.customer.creditGrants.title")})]}),t.metadata.invoice_id&&e.jsx(b,{variant:"outlined",size:"small",onClick:()=>N(`/admin/billing/${t.metadata.invoice_id}`),children:a("admin.customer.creditGrants.viewInvoice")})]}),e.jsxs(s,{mt:4,mb:3,sx:{display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(i,{direction:"row",justifyContent:"space-between",alignItems:"center",children:e.jsxs(i,{direction:"column",spacing:.5,children:[e.jsx(o,{variant:"h2",sx:{fontWeight:600},children:t.name||`${a("admin.customer.creditGrants.grant")} ${t.id.slice(-8)}`}),e.jsx(U,{text:t.id})]})}),e.jsxs(i,{className:"section-body",justifyContent:"flex-start",flexWrap:"wrap",sx:{"hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(u,{label:a("common.status"),value:e.jsx($,{status:t.status,label:S(t.status)}),divider:!0}),e.jsx(u,{label:a("admin.customer.creditGrants.originalAmount"),value:e.jsxs(i,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(g,{src:t.paymentCurrency?.logo,sx:{width:16,height:16},alt:t.paymentCurrency?.symbol}),e.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:C(_(t.amount,t.paymentCurrency.decimal),t.paymentCurrency.symbol)})]}),divider:!0}),e.jsx(u,{label:a("common.remainingCredit"),value:e.jsxs(i,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(g,{src:t.paymentCurrency?.logo,sx:{width:16,height:16},alt:t.paymentCurrency?.symbol}),e.jsx(o,{variant:"body2",color:f?"error.main":"text.secondary",children:C(_(t.remaining_amount,t.paymentCurrency.decimal),t.paymentCurrency.symbol)})]}),divider:!0}),e.jsx(u,{label:a("admin.customer.creditGrants.usage"),value:e.jsxs(o,{variant:"body2",color:f?"error.main":"text.secondary",children:[A().toFixed(1),"%"]})})]})]}),e.jsx(x,{})]}),e.jsxs(i,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".credit-grant-column-1":{minWidth:{xs:"100%",lg:"600px"}},".credit-grant-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(s,{flex:1,className:"credit-grant-column-1",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(l,{title:a("admin.details")}),e.jsxs(q,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(c,{label:a("common.customer"),value:e.jsxs(i,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(g,{src:z(t.customer?.did,t.customer?.updated_at?new Date(t.customer.updated_at).toISOString():"",24),alt:t.customer?.name,sx:{width:24,height:24}}),e.jsx(o,{children:t.customer?.name})]})}),e.jsx(c,{label:a("common.scope"),value:e.jsx(o,{children:t.applicability_config?.scope?.prices?a("common.specific"):a("common.general")})}),e.jsx(c,{label:a("admin.creditProduct.priority.label"),value:e.jsx(o,{children:t.priority})}),e.jsx(c,{label:a("common.createdAt"),value:h(t.created_at)}),e.jsx(c,{label:a("common.effectiveDate"),value:h(t.effective_at?t.effective_at*1e3:t.created_at)}),t.expires_at&&e.jsx(c,{label:a("common.expirationDate"),value:h(t.expires_at*1e3)}),t.chain_detail?.mint?.hash&&t.paymentMethod?.type==="arcblock"&&e.jsx(c,{label:a("common.mintTxHash"),value:e.jsx(H,{details:{arcblock:{tx_hash:t.chain_detail.mint.hash,payer:""}},method:t.paymentMethod,mode:"dashboard"})})]})]}),e.jsx(x,{}),t.items&&t.items.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.creditProduct.associatedPrices.label")}),e.jsx(s,{className:"section-body",children:e.jsx(Z,{data:t.items,currency:t.paymentCurrency,mode:"dashboard"})})]}),e.jsx(x,{})]}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.creditTransactions.title")}),e.jsx(s,{className:"section-body",children:e.jsx(O,{customer_id:t.customer_id,credit_grant_id:t.id,showAdminColumns:!0,showTimeFilter:!0,mode:"dashboard"})})]}),e.jsx(x,{}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.events.title")}),e.jsx(s,{className:"section-body",children:e.jsx(K,{features:{toolbar:!1},object_id:t.id})})]})]}),e.jsx(s,{className:"credit-grant-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("common.metadata.label"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:p.editing.metadata,onClick:y,children:a("common.edit")})}),e.jsxs(s,{className:"section-body",children:[e.jsx(Y,{data:t.metadata,handleEditMetadata:y}),p.editing.metadata&&e.jsx(V,{data:t,loading:p.loading.metadata,onSave:T,onCancel:()=>m(r=>({editing:{...r.editing,metadata:!1}}))})]})]})})]})]})}const ee=F(i)``;export{fe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as d,w as x,B as o,a3 as r,bv as p,q as l,Y as f,bf as u}from"./vendor-mui-BXZut9Pz.js";import{V as j,
|
|
1
|
+
import{j as e,A as d,w as x,B as o,a3 as r,bv as p,q as l,Y as f,bf as u}from"./vendor-mui-BXZut9Pz.js";import{V as j,P as h}from"./vendor-blocklet-DcLR2Cyf.js";import{j as m,e as g}from"./index-BarN7DfU.js";import{C as v}from"./copyable-QrCyyiou.js";import{I as i}from"./info-metric-Dl4ZDm0Z.js";import{S as b}from"./header-ivXuPt06.js";import{W as y}from"./attempts-CKlxkJuE.js";import{g as w}from"./util-DxXTXkeY.js";import"./vendor-react-BPknnnEA.js";import"./vendor-arcblock-BTCAQSUK.js";import"./lodash-B4Ozcv0x.js";import"./info-card-BvIMFQo5.js";const k=a=>g.get(`/api/events/${a}`).then(t=>t.data);function O(a){const{t}=j(),{loading:c,error:n,data:s}=h(()=>k(a.id));return n?e.jsx(d,{severity:"error",children:n.message}):c||!s?e.jsx(x,{}):e.jsxs(W,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(o,{children:[e.jsx(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(r,{direction:"row",onClick:()=>w("/admin/developers/events"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(p,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(l,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.events.title")})]})}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(l,{variant:"h2",sx:{fontWeight:600},children:s.type})}),e.jsxs(r,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(i,{label:t("common.id"),value:e.jsx(v,{text:a.id,style:{marginLeft:4}})}),e.jsx(i,{label:t("admin.event.pendingWebhooks"),value:s.pending_webhooks,divider:!0}),e.jsx(i,{label:t("common.createdAt"),value:m(s.created_at),divider:!0}),e.jsx(i,{label:t("common.updatedAt"),value:m(s.updated_at)})]})]}),e.jsx(f,{})]}),e.jsxs(o,{className:"section",children:[e.jsx(b,{title:t("admin.event.webhooks")}),e.jsx(o,{className:"section-body",children:e.jsx(y,{event_id:s.id,event:s})})]})]})}const W=u(r)``;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as S,w as M,B as t,a3 as d,bv as T,q as p,Y as o,x as D,bf as L}from"./vendor-mui-BXZut9Pz.js";import{V as A,X as F,O as W,Y as f}from"./vendor-blocklet-D_i_QeSo.js";import{u as z,d as R,j as l,z as B,p as _,a_ as E,A as P,e as k,k as H}from"./index-DgSc1Qy8.js";import{L as $}from"./vendor-react-BPknnnEA.js";import{C as G}from"./copyable-DpX04wZz.js";import{C as O}from"./currency-GstdXsJf.js";import{C as U}from"./link-3eeclTeS.js";import{E as V}from"./list-D1aevUOI.js";import{I as i}from"./info-row-DOK2whMn.js";import{I as q}from"./list-CNmzJKIQ.js";import{M as Y}from"./editor-BF5I0siU.js";import{M as X}from"./list-C521zE_7.js";import{R as J}from"./list-CO0X4L3-.js";import{S as c}from"./header-ivXuPt06.js";import{S as K}from"./index-BIoSdRvX.js";import{P as Q,D as Z,S as ee,V as se}from"./payment-method-info-BsOBbA3m.js";import{S as ae}from"./metrics-C7U41HWk.js";import{g as te}from"./util-mDHAL0lx.js";import{I as v}from"./info-row-group-BeUhWnnY.js";import"./table-BRU4Enia.js";import"./cache-state-lld4zuDg.js";import"./filter-toolbar-BydfQ-79.js";import"./lodash-B4Ozcv0x.js";import"./product-select-0ScZE2e8.js";import"./info-card-C1yxhxJG.js";import"./action-B_DQJlip.js";import"./actions-jxGAdGfb.js";import"./click-boundary-y8dVA_tr.js";import"./form-BGm5NPDn.js";import"./actions-BtaoyTWt.js";import"./usage-records-jjJMZ6DI.js";import"./generateCategoricalChart-BaWwaXky.js";import"./info-metric-CNse3r66.js";import"./status-l6pD08fw.js";const ie=m=>k.get(`/api/subscriptions/${m}`).then(a=>a.data);function He(m){const{t:a}=A(),{session:N}=z(),{isMobile:h}=R(),[u,x]=F({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:C,error:y,data:s,runAsync:b}=W(()=>ie(m.id));if(y)return e.jsx(S,{severity:"error",children:y.message});if(C||!s)return e.jsx(M,{});const w=(n=>async j=>{try{x(r=>({loading:{...r.loading,[n]:!0}})),await k.put(`/api/subscriptions/${m.id}`,j).then(r=>r.data),f.success(a("common.saved")),b()}catch(r){console.error(r),f.error(H(r))}finally{x(r=>({loading:{...r.loading,[n]:!1}}))}})("metadata"),g=()=>{x(n=>({editing:{...n.editing,metadata:!0}}))},I=s?.serviceType==="credit"||s?.paymentCurrency?.type==="credit"||s?.items?.some(n=>n?.price?.product?.type==="credit"||n?.price?.metadata?.credit_config);return e.jsxs(ne,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(t,{children:[e.jsxs(d,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(d,{direction:"row",onClick:()=>te("/admin/billing/subscriptions"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.subscriptions")})]}),e.jsx(K,{data:s,onChange:b,variant:"normal"})]}),e.jsxs(t,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(d,{direction:"column",sx:{gap:1},children:[e.jsx(d,{direction:"row",sx:{alignItems:"center"},children:e.jsx(p,{variant:"h2",sx:{fontWeight:600},children:s.description})}),e.jsx(G,{text:m.id})]}),e.jsx(d,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:e.jsx(ae,{subscription:s,mode:"admin"})})]}),e.jsx(o,{})]}),e.jsxs(d,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(t,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:a("admin.details")}),e.jsxs(v,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(i,{label:a("common.customer"),value:e.jsx(U,{customer:s.customer,size:h?"default":"small"})}),e.jsx(i,{label:a("common.createdAt"),value:l(s.created_at)}),e.jsx(i,{label:a("admin.subscription.currentPeriod"),value:[l(s.current_period_start*1e3),l(s.current_period_end*1e3)].join(" ~ ")}),e.jsx(i,{label:a("admin.subscription.trialingPeriod"),value:s.trial_end&&s.trial_start?[l(s.trial_start*1e3),l(s.trial_end*1e3)].join(" ~ "):""}),s.status==="paused"&&!!s.pause_collection?.resumes_at&&e.jsx(i,{label:a("common.resumesAt"),value:l(s.pause_collection.resumes_at*1e3)}),e.jsx(i,{label:a("admin.subscription.collectionMethod"),value:s.collection_method}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:e.jsx(O,{logo:s.paymentCurrency.logo,name:`${s.paymentCurrency.symbol} (${s.paymentMethod?.name})`})}),s.paymentMethodDetails&&e.jsx(i,{label:a("admin.subscription.payerAddress"),value:e.jsx(Q,{subscriptionId:s.id,customer:s.customer,paymentMethodDetails:s.paymentMethodDetails,editable:!1,paymentMethodType:s.paymentMethod?.type})}),s.payment_details&&B(s.payment_details,s.paymentMethod)&&e.jsx(i,{label:a("common.delegateTxHash"),value:e.jsx(_,{details:s.payment_details,method:s.paymentMethod})}),s.paymentMethod?.type==="arcblock"&&s.payment_details?.arcblock?.staking?.tx_hash&&e.jsx(i,{label:a("common.stakeTxHash"),value:e.jsx(_,{details:{arcblock:{tx_hash:s.payment_details?.arcblock?.staking?.tx_hash,payer:""}},method:s.paymentMethod})}),!!s.description&&e.jsx(i,{label:a("common.description"),value:s.description}),!!s.recovered_from&&e.jsx(i,{label:a("common.recoverFrom"),value:e.jsx($,{to:`/admin/billing/${s.recovered_from}`,target:"_blank",children:s.recovered_from})})]})]}),(s.payment_details?.google_play||s.payment_details?.app_store)&&e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:s.payment_details?.google_play?a("admin.subscription.iap.googlePlayTitle"):a("admin.subscription.iap.appStoreTitle")}),e.jsxs(v,{sx:{".info-row-value":{wordBreak:"break-all"}},children:[s.channel&&e.jsx(i,{label:a("admin.subscription.channel"),value:s.channel}),s.payment_details?.google_play&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.purchaseToken"),value:s.payment_details.google_play.purchase_token}),e.jsx(i,{label:a("admin.subscription.iap.orderId"),value:s.payment_details.google_play.order_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.google_play.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.google_play.expiry_time_millis?l(Number(s.payment_details.google_play.expiry_time_millis)):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.google_play.environment||s.environment||"—"})]}),s.payment_details?.app_store&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.originalTransactionId"),value:s.payment_details.app_store.original_transaction_id}),e.jsx(i,{label:a("admin.subscription.iap.transactionId"),value:s.payment_details.app_store.transaction_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.app_store.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.app_store.expires_at?l(s.payment_details.app_store.expires_at*1e3):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.app_store.environment||s.environment||"—"})]})]})]})]}),e.jsx(o,{}),s.discountStats&&e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",sx:{mb:1.5},children:a("admin.subscription.discount")}),e.jsx(t,{className:"section-body",children:e.jsx(Z,{discountStats:s.discountStats})})]}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.product.pricing")}),e.jsx(t,{className:"section-body",children:e.jsx(ee,{data:s.items,currency:s.paymentCurrency,mode:"admin"})})]}),(()=>{const n=s.items?.map(j=>j.price?.product?.vendor_config||[]).flat();return!n||n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsx(t,{className:"section",sx:{".section-header":{fontSize:{xs:"18px",md:"1.09375rem"}},".vendor-service-item":{maxWidth:"400px"}},children:e.jsx(se,{vendorServices:n,subscriptionId:s.id,isOwner:N?.user?.did===s.customer?.did,isCanceled:s.status==="canceled"})})]})})(),e.jsx(o,{sx:{my:1.5}}),I?e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditGrants.tab")}),e.jsx(t,{className:"section-body",children:e.jsx(E,{customer_id:s.customer_id,subscription_id:s.id,mode:"dashboard"})})]}),e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditTransactions.title")}),e.jsx(t,{className:"section-body",children:e.jsx(P,{customer_id:s.customer_id,subscription_id:s.id,includeGrants:!0,mode:"dashboard"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.invoices")}),e.jsx(t,{className:"section-body",children:e.jsx(q,{features:{customer:!0,toolbar:!1},subscription_id:s.id,include_staking:!0})})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.refunds")}),e.jsx(t,{className:"section-body",children:e.jsx(J,{features:{customer:!0,toolbar:!1},subscription_id:s.id})})]})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.events.title")}),e.jsx(t,{className:"section-body",children:e.jsx(V,{features:{toolbar:!1},object_id:s.id})})]})]}),h&&e.jsx(o,{}),e.jsx(t,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("common.metadata.label"),children:e.jsx(D,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:u.editing.metadata,onClick:g,children:a("common.edit")})}),e.jsxs(t,{className:"section-body",children:[e.jsx(X,{data:s.metadata,handleEditMetadata:g}),u.editing.metadata&&e.jsx(Y,{data:s,loading:u.loading.metadata,onSave:w,onCancel:()=>x(n=>({editing:{...n.editing,metadata:!1}}))})]})]})})]})]})}const ne=L(d)``;export{He as default};
|
|
1
|
+
import{j as e,A as S,w as M,B as t,a3 as d,bv as T,q as p,Y as o,x as D,bf as L}from"./vendor-mui-BXZut9Pz.js";import{V as A,Y as F,P as W,Z as f}from"./vendor-blocklet-DcLR2Cyf.js";import{u as z,d as P,j as l,z as R,p as _,a_ as B,A as E,e as k,k as H}from"./index-BarN7DfU.js";import{L as $}from"./vendor-react-BPknnnEA.js";import{C as G}from"./copyable-QrCyyiou.js";import{C as O}from"./currency-GstdXsJf.js";import{C as U}from"./link-CmPoIweR.js";import{E as V}from"./list-DaK9287Y.js";import{I as i}from"./info-row-jI0h_hv4.js";import{I as q}from"./list-eFkvVlp5.js";import{M as Y}from"./editor-AmthipP2.js";import{M as Z}from"./list-CkHExntK.js";import{R as J}from"./list-DLB_hd0Q.js";import{S as c}from"./header-ivXuPt06.js";import{S as K}from"./index-CbSXdD6E.js";import{P as Q,D as X,S as ee,V as se}from"./payment-method-info-Bsf89VxV.js";import{S as ae}from"./metrics-UvxyQbUF.js";import{g as te}from"./util-DxXTXkeY.js";import{I as v}from"./info-row-group-CFuMWJf1.js";import"./table-BrtHemkA.js";import"./cache-state-lld4zuDg.js";import"./filter-toolbar-DXGSTq57.js";import"./lodash-B4Ozcv0x.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./action-DENqSeOa.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./form-CAPjlw7l.js";import"./actions-0iWP2mcx.js";import"./usage-records-DAUQMJAW.js";import"./generateCategoricalChart-BadryV3H.js";import"./info-metric-Dl4ZDm0Z.js";import"./status-CUVYrUIG.js";const ie=m=>k.get(`/api/subscriptions/${m}`).then(a=>a.data);function He(m){const{t:a}=A(),{session:N}=z(),{isMobile:h}=P(),[u,x]=F({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:C,error:y,data:s,runAsync:b}=W(()=>ie(m.id));if(y)return e.jsx(S,{severity:"error",children:y.message});if(C||!s)return e.jsx(M,{});const w=(n=>async j=>{try{x(r=>({loading:{...r.loading,[n]:!0}})),await k.put(`/api/subscriptions/${m.id}`,j).then(r=>r.data),f.success(a("common.saved")),b()}catch(r){console.error(r),f.error(H(r))}finally{x(r=>({loading:{...r.loading,[n]:!1}}))}})("metadata"),g=()=>{x(n=>({editing:{...n.editing,metadata:!0}}))},I=s?.serviceType==="credit"||s?.paymentCurrency?.type==="credit"||s?.items?.some(n=>n?.price?.product?.type==="credit"||n?.price?.metadata?.credit_config);return e.jsxs(ne,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(t,{children:[e.jsxs(d,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(d,{direction:"row",onClick:()=>te("/admin/billing/subscriptions"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.subscriptions")})]}),e.jsx(K,{data:s,onChange:b,variant:"normal"})]}),e.jsxs(t,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(d,{direction:"column",sx:{gap:1},children:[e.jsx(d,{direction:"row",sx:{alignItems:"center"},children:e.jsx(p,{variant:"h2",sx:{fontWeight:600},children:s.description})}),e.jsx(G,{text:m.id})]}),e.jsx(d,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:e.jsx(ae,{subscription:s,mode:"admin"})})]}),e.jsx(o,{})]}),e.jsxs(d,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(t,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:a("admin.details")}),e.jsxs(v,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(i,{label:a("common.customer"),value:e.jsx(U,{customer:s.customer,size:h?"default":"small"})}),e.jsx(i,{label:a("common.createdAt"),value:l(s.created_at)}),e.jsx(i,{label:a("admin.subscription.currentPeriod"),value:[l(s.current_period_start*1e3),l(s.current_period_end*1e3)].join(" ~ ")}),e.jsx(i,{label:a("admin.subscription.trialingPeriod"),value:s.trial_end&&s.trial_start?[l(s.trial_start*1e3),l(s.trial_end*1e3)].join(" ~ "):""}),s.status==="paused"&&!!s.pause_collection?.resumes_at&&e.jsx(i,{label:a("common.resumesAt"),value:l(s.pause_collection.resumes_at*1e3)}),e.jsx(i,{label:a("admin.subscription.collectionMethod"),value:s.collection_method}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:e.jsx(O,{logo:s.paymentCurrency.logo,name:`${s.paymentCurrency.symbol} (${s.paymentMethod?.name})`})}),s.paymentMethodDetails&&e.jsx(i,{label:a("admin.subscription.payerAddress"),value:e.jsx(Q,{subscriptionId:s.id,customer:s.customer,paymentMethodDetails:s.paymentMethodDetails,editable:!1,paymentMethodType:s.paymentMethod?.type})}),s.payment_details&&R(s.payment_details,s.paymentMethod)&&e.jsx(i,{label:a("common.delegateTxHash"),value:e.jsx(_,{details:s.payment_details,method:s.paymentMethod})}),s.paymentMethod?.type==="arcblock"&&s.payment_details?.arcblock?.staking?.tx_hash&&e.jsx(i,{label:a("common.stakeTxHash"),value:e.jsx(_,{details:{arcblock:{tx_hash:s.payment_details?.arcblock?.staking?.tx_hash,payer:""}},method:s.paymentMethod})}),!!s.description&&e.jsx(i,{label:a("common.description"),value:s.description}),!!s.recovered_from&&e.jsx(i,{label:a("common.recoverFrom"),value:e.jsx($,{to:`/admin/billing/${s.recovered_from}`,target:"_blank",children:s.recovered_from})})]})]}),(s.payment_details?.google_play||s.payment_details?.app_store)&&e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:s.payment_details?.google_play?a("admin.subscription.iap.googlePlayTitle"):a("admin.subscription.iap.appStoreTitle")}),e.jsxs(v,{sx:{".info-row-value":{wordBreak:"break-all"}},children:[s.channel&&e.jsx(i,{label:a("admin.subscription.channel"),value:s.channel}),s.payment_details?.google_play&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.purchaseToken"),value:s.payment_details.google_play.purchase_token}),e.jsx(i,{label:a("admin.subscription.iap.orderId"),value:s.payment_details.google_play.order_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.google_play.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.google_play.expiry_time_millis?l(Number(s.payment_details.google_play.expiry_time_millis)):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.google_play.environment||s.environment||"—"})]}),s.payment_details?.app_store&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.originalTransactionId"),value:s.payment_details.app_store.original_transaction_id}),e.jsx(i,{label:a("admin.subscription.iap.transactionId"),value:s.payment_details.app_store.transaction_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.app_store.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.app_store.expires_at?l(s.payment_details.app_store.expires_at*1e3):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.app_store.environment||s.environment||"—"})]})]})]})]}),e.jsx(o,{}),s.discountStats&&e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",sx:{mb:1.5},children:a("admin.subscription.discount")}),e.jsx(t,{className:"section-body",children:e.jsx(X,{discountStats:s.discountStats})})]}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.product.pricing")}),e.jsx(t,{className:"section-body",children:e.jsx(ee,{data:s.items,currency:s.paymentCurrency,mode:"admin"})})]}),(()=>{const n=s.items?.map(j=>j.price?.product?.vendor_config||[]).flat();return!n||n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsx(t,{className:"section",sx:{".section-header":{fontSize:{xs:"18px",md:"1.09375rem"}},".vendor-service-item":{maxWidth:"400px"}},children:e.jsx(se,{vendorServices:n,subscriptionId:s.id,isOwner:N?.user?.did===s.customer?.did,isCanceled:s.status==="canceled"})})]})})(),e.jsx(o,{sx:{my:1.5}}),I?e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditGrants.tab")}),e.jsx(t,{className:"section-body",children:e.jsx(B,{customer_id:s.customer_id,subscription_id:s.id,mode:"dashboard"})})]}),e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditTransactions.title")}),e.jsx(t,{className:"section-body",children:e.jsx(E,{customer_id:s.customer_id,subscription_id:s.id,includeGrants:!0,mode:"dashboard"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.invoices")}),e.jsx(t,{className:"section-body",children:e.jsx(q,{features:{customer:!0,toolbar:!1},subscription_id:s.id,include_staking:!0})})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.refunds")}),e.jsx(t,{className:"section-body",children:e.jsx(J,{features:{customer:!0,toolbar:!1},subscription_id:s.id})})]})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.events.title")}),e.jsx(t,{className:"section-body",children:e.jsx(V,{features:{toolbar:!1},object_id:s.id})})]})]}),h&&e.jsx(o,{}),e.jsx(t,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("common.metadata.label"),children:e.jsx(D,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:u.editing.metadata,onClick:g,children:a("common.edit")})}),e.jsxs(t,{className:"section-body",children:[e.jsx(Z,{data:s.metadata,handleEditMetadata:g}),u.editing.metadata&&e.jsx(Y,{data:s,loading:u.loading.metadata,onSave:w,onCancel:()=>x(n=>({editing:{...n.editing,metadata:!1}}))})]})]})})]})]})}const ne=L(d)``;export{He as default};
|