@arcblock/payment-service 1.29.9 → 1.29.11
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.js +51 -51
- package/dist/index.js +196 -43
- package/package.json +3 -3
- package/web/assets/{account-Clbqiiw3.js → account-DrsnH5wP.js} +1 -1
- package/web/assets/{action-DENqSeOa.js → action-C2c0yWuW.js} +1 -1
- package/web/assets/{actions-CDsj5j8l.js → actions--FNKSNIs.js} +1 -1
- package/web/assets/{actions-BJDN6Op2.js → actions-BEUwbsq1.js} +1 -1
- package/web/assets/{actions-CSpJGOX7.js → actions-C9AfME83.js} +1 -1
- package/web/assets/{actions-BD9BAp3M.js → actions-D2-s31n3.js} +1 -1
- package/web/assets/{actions-BSNy5bOd.js → actions-DXMceTgd.js} +1 -1
- package/web/assets/{actions-0iWP2mcx.js → actions-DeCPtfTK.js} +1 -1
- package/web/assets/{actions-DGQs8fFF.js → actions-DtNZGZWf.js} +1 -1
- package/web/assets/{actions-D3tJgrUn.js → actions-JHsqbHpB.js} +1 -1
- package/web/assets/{actions-CZL47E9r.js → actions-izdZ2Mn4.js} +1 -1
- package/web/assets/{add-price-BpnICuHO.js → add-price-TdXAR3NW.js} +1 -1
- package/web/assets/{admin-CD8ViZ7D.js → admin-BpFv3eF5.js} +1 -1
- package/web/assets/{assign-0vMUDW_C.js → assign-DKRfmN7W.js} +1 -1
- package/web/assets/{attempts-CKlxkJuE.js → attempts-BfbYfiJa.js} +1 -1
- package/web/assets/browser-DF2vfpBa.js +1 -0
- package/web/assets/{change-payment-gAlRmJpv.js → change-payment-j5UC8_h0.js} +1 -1
- package/web/assets/{change-plan-C47wfWH8.js → change-plan-CtXvsIDw.js} +1 -1
- package/web/assets/{click-boundary-CafubiPp.js → click-boundary-Bi28Y0Fq.js} +1 -1
- package/web/assets/{connect-BHHzrwLA.js → connect-CXek4LAE.js} +1 -1
- package/web/assets/{copyable-QrCyyiou.js → copyable-CprMHdhV.js} +1 -1
- package/web/assets/{create-ke4FrPx1.js → create-B-Ubepl_.js} +1 -1
- package/web/assets/{create-DNar5UQD.js → create-BVt_sQ_7.js} +1 -1
- package/web/assets/{create-0PUtkJZY.js → create-BWviSWbC.js} +1 -1
- package/web/assets/{create-BJ1asdcy.js → create-C6jihslA.js} +1 -1
- package/web/assets/{create-C7GOgZZM.js → create-IaalYGmm.js} +1 -1
- package/web/assets/{create-Bgv5ux17.js → create-jzl1m8ZK.js} +1 -1
- package/web/assets/{credit-grant-item-list-CeDAM3qV.js → credit-grant-item-list-DQcvdSRs.js} +1 -1
- package/web/assets/{credit-overview-4zh0H02x.js → credit-overview-CPId2vzk.js} +1 -1
- package/web/assets/{currency-restrictions-BcEm8W45.js → currency-restrictions-Dsupz2ce.js} +1 -1
- package/web/assets/{currency-select-B4ieQBvv.js → currency-select-C8j7QQMP.js} +1 -1
- package/web/assets/{dayjs-DUTDpcNU.js → dayjs-DUNWtvju.js} +1 -1
- package/web/assets/{description-SnR5WxWT.js → description-BHxdy5I3.js} +1 -1
- package/web/assets/{detail-DNcp_u5S.js → detail-B17BN6kU.js} +1 -1
- package/web/assets/detail-BJ-hl5PK.js +10 -0
- package/web/assets/{detail-46aLUdJj.js → detail-BJEqTXDS.js} +1 -1
- package/web/assets/{detail-BQpDGZJQ.js → detail-BdC9VIc6.js} +1 -1
- package/web/assets/{detail-DbU3p040.js → detail-BkRkrKyw.js} +1 -1
- package/web/assets/{detail-DACnmls3.js → detail-BvcI9cB_.js} +1 -1
- package/web/assets/detail-C--ATvwm.js +24 -0
- package/web/assets/{detail-Cg505nKX.js → detail-CHJqYZ0W.js} +1 -1
- package/web/assets/{detail-B0IHl4MI.js → detail-CfvKZ7IV.js} +1 -1
- package/web/assets/{detail-Ct5QNBqu.js → detail-CmIweOLE.js} +1 -1
- package/web/assets/{detail-BXTsnQny.js → detail-D729Bgs6.js} +1 -1
- package/web/assets/{detail-C_Zdfa0y.js → detail-DD1YBtex.js} +1 -1
- package/web/assets/detail-DOcm4Kqg.js +15 -0
- package/web/assets/{detail-Bfnkg0A1.js → detail-DQj1mbhA.js} +1 -1
- package/web/assets/detail-DTXDMIR9.js +15 -0
- package/web/assets/{detail-CsGZMimg.js → detail-DUAJzKsu.js} +1 -1
- package/web/assets/{detail-BwH0DwAi.js → detail-De8PyTyx.js} +1 -1
- package/web/assets/{detail-B_lpOomD.js → detail-DqfxOHky.js} +1 -1
- package/web/assets/{detail-CMBRd4Ct.js → detail-Dzt5tfyZ.js} +1 -1
- package/web/assets/{detail-Tn2R5C8i.js → detail-H0dkKVyS.js} +1 -1
- package/web/assets/{detail-CyMhK5K_.js → detail-MgdgGj5J.js} +1 -1
- package/web/assets/{detail-DCTb8R7F.js → detail-WAmPM6yq.js} +1 -1
- package/web/assets/{detail-B-ceWfZr.js → detail-g6el9Fxj.js} +1 -1
- package/web/assets/did-Bqcz-NjH.js +1 -0
- package/web/assets/{drawer-form-DspWWj3x.js → drawer-form-CQjNFFWk.js} +1 -1
- package/web/assets/{edit-Bkj-OTJh.js → edit-DAU8AWzT.js} +1 -1
- package/web/assets/{editor-AmthipP2.js → editor-vZvxDUTl.js} +1 -1
- package/web/assets/{embed-rRKjDoHi.js → embed-ClYNqZbf.js} +1 -1
- package/web/assets/{filter-toolbar-DXGSTq57.js → filter-toolbar-VvmMATj0.js} +1 -1
- package/web/assets/{form-BmQlJZ84.js → form-4_MzglPj.js} +1 -1
- package/web/assets/{form-cX026J4G.js → form-AFzUvoFE.js} +1 -1
- package/web/assets/{form-B5WW-lS5.js → form-Bro99BjK.js} +1 -1
- package/web/assets/{form-CAPjlw7l.js → form-CnrBCyTJ.js} +1 -1
- package/web/assets/form-Cuvruf4H.js +16 -0
- package/web/assets/{gas-nyR96dB0.js → gas-kw2KMH1u.js} +1 -1
- package/web/assets/{generateCategoricalChart-BadryV3H.js → generateCategoricalChart-BCpuUeC_.js} +1 -1
- package/web/assets/{home-_eX1aim8.js → home-ZNJREzbw.js} +1 -1
- package/web/assets/{index-CbSXdD6E.js → index-ASk8vU2H.js} +1 -1
- package/web/assets/{index-ajD9Iotk.js → index-B4n6PvPu.js} +1 -1
- package/web/assets/{index-BarN7DfU.js → index-B4yaPb7B.js} +5 -5
- package/web/assets/{index-DSe7Dot_.js → index-BHwID_s4.js} +1 -1
- package/web/assets/index-BMcnd_jZ.js +1 -0
- package/web/assets/{index-BTfJ08JU.js → index-BRmN8ViQ.js} +1 -1
- package/web/assets/index-BdbLl6St.js +1 -0
- package/web/assets/{index-CCVDDX0c.js → index-BjKRyxNQ.js} +1 -1
- package/web/assets/index-BjLJQRKY.js +1 -0
- package/web/assets/index-BkNCPnTn.js +1 -0
- package/web/assets/index-BlAwTTmu.js +1 -0
- package/web/assets/{index-C136x0O2.js → index-BtWfmATr.js} +1 -1
- package/web/assets/{index-DNGmCIRP.js → index-C-5n472s.js} +1 -1
- package/web/assets/{index-CW8VfoJO.js → index-C3AP4jq0.js} +1 -1
- package/web/assets/{index-C-RT84yb.js → index-C3Rh1SaB.js} +1 -1
- package/web/assets/index-CDyxbCzc.js +1 -0
- package/web/assets/{index-SOzRg0yJ.js → index-CH_k9MVv.js} +1 -1
- package/web/assets/{index-XaFn2ySq.js → index-CKPfOW6M.js} +1 -1
- package/web/assets/{index-BQjlhCSt.js → index-CPFlZhA2.js} +1 -1
- package/web/assets/{index-Du0Ieh1F.js → index-CPyGjEd3.js} +2 -2
- package/web/assets/index-ChC-jsE2.js +1 -0
- package/web/assets/{index-D-bx9Kam.js → index-CiWvs3j9.js} +1 -1
- package/web/assets/{index-mn5Zdrtn.js → index-D6gv9jHh.js} +1 -1
- package/web/assets/{index-Cd_BD9TM.js → index-D7pWd60Z.js} +1 -1
- package/web/assets/{index-YG5oc8O3.js → index-DAen2-cr.js} +1 -1
- package/web/assets/{index-BRENdB5m.js → index-DNobX-Tr.js} +1 -1
- package/web/assets/{index-Kd_qCyRG.js → index-DY-g0BPU.js} +1 -1
- package/web/assets/{index-D0mynT6_.js → index-DZkpxY-C.js} +1 -1
- package/web/assets/{index-DcddP3R9.js → index-Dh9agU9O.js} +1 -1
- package/web/assets/{index-BBHMsIxJ.js → index-Dju8k6mq.js} +1 -1
- package/web/assets/{index-DeK5Pqjv.js → index-DwDNPqjF.js} +1 -1
- package/web/assets/{index-DEiuhiEo.js → index-Dze0CpfQ.js} +1 -1
- package/web/assets/{index-UYeD8rTJ.js → index-eDERHpkr.js} +1 -1
- package/web/assets/{index-BzABukCz.js → index-mgPU1lyd.js} +1 -1
- package/web/assets/{index-W2uZUlFs.js → index-olGOY5KB.js} +1 -1
- package/web/assets/{index-DoX0A-rP.js → index-oy7LrXGT.js} +1 -1
- package/web/assets/{index-qulrJQ4J.js → index-x7sBb6oM.js} +1 -1
- package/web/assets/{index.es-C8dcCHdW.js → index.es-C2Q6Owow.js} +1 -1
- package/web/assets/{info-card-BvIMFQo5.js → info-card-C9dRgztS.js} +1 -1
- package/web/assets/{info-metric-Dl4ZDm0Z.js → info-metric-ukWq8INi.js} +1 -1
- package/web/assets/{info-row-jI0h_hv4.js → info-row-CaPaNF4L.js} +1 -1
- package/web/assets/{info-row-group-CFuMWJf1.js → info-row-group-Cxo-4Gk5.js} +1 -1
- package/web/assets/{libphonenumber-Qs8PCdM-.js → libphonenumber-CTvobi0D.js} +1 -1
- package/web/assets/{link-CmPoIweR.js → link-DsltSF2Q.js} +1 -1
- package/web/assets/{list-CkHExntK.js → list-B2b-s8wM.js} +1 -1
- package/web/assets/{list-DLB_hd0Q.js → list-BzgF4i3i.js} +1 -1
- package/web/assets/{list-BdSkPjIa.js → list-Cd1O-aDi.js} +1 -1
- package/web/assets/{list-DaK9287Y.js → list-CvM46TsP.js} +1 -1
- package/web/assets/{list-CWMEf-_C.js → list-DtEjqlED.js} +1 -1
- package/web/assets/{list-DVFJwd_I.js → list-O_uCSLFq.js} +1 -1
- package/web/assets/{list-DghnUOc4.js → list-YNWVqjwW.js} +1 -1
- package/web/assets/{list-eFkvVlp5.js → list-ZaBapEXW.js} +1 -1
- package/web/assets/{metadata-BmQTVFku.js → metadata-_hV0ZaVh.js} +1 -1
- package/web/assets/{meter-event-B1JIhVpb.js → meter-event-CPVBpekF.js} +1 -1
- package/web/assets/{metrics-UvxyQbUF.js → metrics-DVPdwpyf.js} +1 -1
- package/web/assets/{overview-Cxc6WKba.js → overview-CGdVIJrJ.js} +1 -1
- package/web/assets/{overview-DrMaIptb.js → overview-CN59I5Sc.js} +1 -1
- package/web/assets/{past-due-CUXkxns0.js → past-due-C3PtU8uo.js} +1 -1
- package/web/assets/pay-XVdSNq__.js +4 -0
- package/web/assets/{payment-method-info-Bsf89VxV.js → payment-method-info-D_qR04xC.js} +1 -1
- package/web/assets/{preview-C-H8pGVw.js → preview-Bdtbh-xk.js} +1 -1
- package/web/assets/{preview-BifsgUGT.js → preview-F3lma170.js} +1 -1
- package/web/assets/{pricing-table-BUJdtkMq.js → pricing-table-Bt2WljzE.js} +1 -1
- package/web/assets/{pricing-table-B3QOaAB5.js → pricing-table-D9FGYBVa.js} +1 -1
- package/web/assets/{product-select-ChEyoJqJ.js → product-select-_72p-5lF.js} +1 -1
- package/web/assets/{recharge-BVT4USAO.js → recharge-CSlKshbU.js} +1 -1
- package/web/assets/{related-credit-grants-JV2ICsR5.js → related-credit-grants-DnKdAit6.js} +3 -3
- package/web/assets/{safe-did-address-CiG_V6Gy.js → safe-did-address-CRTPYo34.js} +1 -1
- package/web/assets/{source-data-viewer-i1q9wNIG.js → source-data-viewer-D1GShrs5.js} +1 -1
- package/web/assets/{status-CUVYrUIG.js → status-3Swm2gK5.js} +1 -1
- package/web/assets/subscription-BX00k6FU.js +1 -0
- package/web/assets/{subscription-DrnSPIfs.js → subscription-Bzeblscr.js} +1 -1
- package/web/assets/table-BN3WBnr3.js +1 -0
- package/web/assets/{tax-code-select-TS07I0rB.js → tax-code-select-j2arPbaE.js} +1 -1
- package/web/assets/{tax-utils-bPjALcVG.js → tax-utils-B8J0Kfnz.js} +1 -1
- package/web/assets/{uploader-CsQNHG4I.js → uploader-BLdAbLR6.js} +1 -1
- package/web/assets/{usage-records-DAUQMJAW.js → usage-records-BAwNs1y8.js} +1 -1
- package/web/assets/{util-DxXTXkeY.js → util-B8B3fsMa.js} +1 -1
- package/web/assets/{vendor-arcblock-BTCAQSUK.js → vendor-arcblock-D1drrE7q.js} +1 -1
- package/web/assets/{vendor-blocklet-DcLR2Cyf.js → vendor-blocklet-B67R14so.js} +2 -2
- package/web/index.html +1 -1
- package/web/assets/browser-DDv4_sgY.js +0 -1
- package/web/assets/detail-B8eOBVSQ.js +0 -15
- package/web/assets/detail-BO3zglCn.js +0 -15
- package/web/assets/detail-C1FupF1D.js +0 -24
- package/web/assets/detail-wU4wNf4s.js +0 -10
- package/web/assets/form-DD-EiA7W.js +0 -16
- package/web/assets/index-BhcoukR2.js +0 -1
- package/web/assets/index-BturOfxo.js +0 -1
- package/web/assets/index-CDVogp6E.js +0 -1
- package/web/assets/index-DcrGSDby.js +0 -1
- package/web/assets/index-Dybqd298.js +0 -1
- package/web/assets/index-EXZPddtw.js +0 -1
- package/web/assets/index-brUCsnBA.js +0 -1
- package/web/assets/pay-omLYkqRA.js +0 -4
- package/web/assets/subscription-BYz_k9dq.js +0 -1
- package/web/assets/table-BrtHemkA.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as F,j as e,B as v,q as f,a3 as q,x as Y,w as ne,aN as ie,aM as K,a7 as Z,bf as O}from"./vendor-mui-BXZut9Pz.js";import{V as H,H as $,$ as re,Z as B,Y as ce,P as ae}from"./vendor-blocklet-DcLR2Cyf.js";import{a as se,h as ue,Y as N,F as me,e as k,b8 as W,k as V,I as G,T as J,v as Q,j as A}from"./index-BarN7DfU.js";import{D as X,P as de}from"./index-DoX0A-rP.js";import{A as le}from"./actions-BJDN6Op2.js";import{L as ee}from"./link-DMWJcQvZ.js";import{C as oe}from"./link-CmPoIweR.js";import{S as pe}from"./description-SnR5WxWT.js";import{S as fe}from"./status-CUVYrUIG.js";import{a as _e}from"./vendor-react-BPknnnEA.js";function Ae({open:o,onClose:h,onSubmit:S=()=>{},couponId:t,promotionCode:s=null,isEditing:a=!1,availableCurrencies:p=[]}){const{t:m}=H(),{settings:c}=se(),w=ue({mode:"onChange",defaultValues:X}),{handleSubmit:L,reset:C,formState:{isSubmitting:P}}=w;F.useEffect(()=>{if(o)if(a&&s){const n={},_=s.restrictions?.minimum_amount_currency?N(c.paymentMethods,s.restrictions.minimum_amount_currency):null,x=s.restrictions?.minimum_amount?parseFloat($(s.restrictions.minimum_amount,_?.decimal||0)):void 0;let M=!1;if(s.restrictions?.currency_options){const I=Object.entries(s.restrictions.currency_options);M=I.length>0,I.forEach(([U,T])=>{const E=N(c.paymentMethods,U);let g=0;if(T&&typeof T=="object"&&"minimum_amount"in T){const u=T.minimum_amount;E&&u?g=parseFloat($(u||"0",E.decimal)):g=u||0}n[U]={minimum_amount:g}})}C({code:s.code||"",active:s.active??!0,max_redemptions:s.max_redemptions||void 0,description:s.description||"",expires_at:s.expires_at?new Date(s.expires_at*1e3).toISOString().slice(0,16):"",verification_type:s.verification_type||"code",limit_number_redemptions:!!s.max_redemptions,add_expiration_date:!!s.expires_at,restrictions:{first_time_transaction:s.restrictions?.first_time_transaction||!1,require_minimum_amount:M,minimum_amount:x,minimum_amount_currency:_?.id,currency_options:n},customer_dids:s.customer_dids||[],nft_addresses:s.nft_config?.addresses||[],nft_tags:s.nft_config?.tags||[],trusted_issuers:s.nft_config?.trusted_issuers||[],trusted_parents:s.nft_config?.trusted_parents||[],min_balance:s.nft_config?.min_balance||1,vc_roles:s.vc_config?.roles||[],vc_trusted_issuers:s.vc_config?.trusted_issuers||[]})}else C(X)},[o,a,s,C,c.paymentMethods]);const b=async n=>{try{const _={active:n.active,verification_type:n.verification_type,restrictions:n.restrictions,description:n.description,metadata:{}};a||(_.coupon_id=t),n.code&&n.code.trim()&&(_.code=n.code),n.limit_number_redemptions&&n.max_redemptions&&(_.max_redemptions=n.max_redemptions),n.expires_at&&(_.expires_at=Math.floor(new Date(n.expires_at).getTime()/1e3)),n.verification_type==="nft"?_.nft_config={addresses:n.nft_addresses?.filter(x=>x.trim())||[],tags:n.nft_tags?.filter(x=>x.trim())||[],trusted_issuers:n.trusted_issuers?.filter(x=>x.trim())||[],trusted_parents:n.trusted_parents?.filter(x=>x.trim())||[],min_balance:n.min_balance||1}:n.verification_type==="vc"?_.vc_config={roles:n.vc_roles?.filter(x=>x.trim())||[],trusted_issuers:n.vc_trusted_issuers?.filter(x=>x.trim())||[]}:n.verification_type==="user_restricted"&&(_.customer_dids=n.customer_dids?.filter(x=>x.trim())||[]),a&&s?(await k.put(`/api/promotion-codes/${s.id}`,_),B.success(m("common.saved")),W("promotion-code.updated")):(await k.post("/api/promotion-codes",_),B.success(m("admin.coupon.saved")),W("promotion-code.created")),S&&S(),h()}catch(_){console.error(_),B.error(V(_))}},D=()=>{C(),h()},d=m(a?"admin.promotionCode.edit":"admin.coupon.createPromotionCode");return e.jsx(re,{open:o,disableEscapeKeyDown:!0,fullWidth:!0,maxWidth:"sm",className:"base-dialog",onClose:D,showCloseButton:!1,title:d,actions:e.jsxs(q,{direction:"row",children:[e.jsx(Y,{size:"small",sx:{mr:2},onClick:D,disabled:P,children:m("common.cancel")}),e.jsxs(Y,{variant:"contained",color:"primary",size:"small",disabled:P,onClick:L(b),children:[P&&e.jsx(ne,{size:16,sx:{mr:1}}),m(a?"common.save":"admin.coupon.createPromotionCode")]})]}),children:e.jsx(me,{...w,children:e.jsxs(v,{sx:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:m("admin.coupon.promotionCodeDescription")}),e.jsx(de,{showCodeInput:!0,showExpandedOptions:!0,availableCurrencies:p})]})})})}function $e({data:o,onChange:h,variant:S="compact"}){const{t}=H(),s=!o.locked&&o.active,a=!o.locked,p=o.active,[m,c]=ce({action:"",loading:!1}),w=async()=>{try{c({loading:!0}),await k.put(`/api/promotion-codes/${o.id}/archive`).then(b=>b.data),B.success(t("common.saved")),W("promotion-code.updated"),h(m.action)}catch(b){console.error(b),B.error(V(b))}finally{c({loading:!1,action:""})}},L=async()=>{try{c({loading:!0}),await k.delete(`/api/promotion-codes/${o.id}`).then(b=>b.data),B.success(t("common.removed")),W("promotion-code.deleted"),h(m.action)}catch(b){console.error(b),B.error(V(b))}finally{c({loading:!1,action:""})}},C=()=>{c({action:"edit"}),h("edit",o)},P=[{label:t("admin.promotionCode.edit"),handler:C,color:s?"text.primary":"text.disabled",disabled:!s},{label:t("admin.promotionCode.archive"),handler:()=>c({action:"archive"}),color:p?"text.primary":"text.disabled",disabled:!p},{label:t("admin.promotionCode.delete"),handler:()=>c({action:"delete"}),color:a?"error.main":"text.disabled",disabled:!a}];return e.jsxs(e.Fragment,{children:[e.jsx(le,{variant:S,actions:P}),m.action==="archive"&&e.jsx(G,{onConfirm:w,onCancel:()=>c({action:""}),title:t("admin.promotionCode.archive"),message:t("admin.promotionCode.archiveTip")}),m.action==="delete"&&e.jsx(G,{onConfirm:L,onCancel:()=>c({action:""}),title:t("admin.promotionCode.delete"),message:t("admin.promotionCode.deleteTip")})]})}function xe(o){if((!o.couponId||o.couponId==="")&&(!o.promotionCodeId||o.promotionCodeId===""))throw new Error("Either couponId or promotionCodeId must be provided")}const be=(o,h,S,t="coupon")=>{const s=new URLSearchParams({page:h.page.toString(),pageSize:h.pageSize.toString()});s.append("type",S);const a=t==="coupon"?`/api/coupons/${o}/redemptions`:`/api/promotion-codes/${o}/redemptions`;return k.get(`${a}?${s}`).then(p=>p.data)};function ke({couponId:o="",promotionCodeId:h=""}){xe({couponId:o,promotionCodeId:h});const{t}=H(),s=_e(),[a,p]=F.useState(0),[m,c]=F.useState({page:0,pageSize:10}),[w,L]=F.useState({page:0,pageSize:10}),C=o&&o!==""?o:h,P=o&&o!==""?"coupon":"promotion-code",b=a===0?m:w,D=a===0?"customer":"subscription",{data:d={customers:[],subscriptions:[],count:0},loading:n}=ae(()=>be(C,{page:b.page+1,pageSize:b.pageSize},D,P),{refreshDeps:[C,b.page,b.pageSize,a]}),_=(g,u)=>{p(u),u===0?c({page:0,pageSize:10}):L({page:0,pageSize:10})},x=({page:g,rowsPerPage:u})=>{c({page:g,pageSize:u})},M=({page:g,rowsPerPage:u})=>{L({page:g,pageSize:u})},U=(()=>{const g=[{label:t("common.name"),name:"name",options:{customBodyRenderLite:(u,r)=>{const l=d.customers?.[r];return e.jsx(oe,{customer:l,size:"small"})}}},{label:t("common.email"),name:"email",options:{customBodyRenderLite:(u,r)=>d.customers?.[r]?.email||"—"}},{label:t("admin.coupon.usageStats"),name:"usage_stats",options:{customBodyRenderLite:(u,r)=>{const i=d.customers?.[r]?.coupon_usage_stats;return i?e.jsx(f,{variant:"body2",children:i.total_discount_records}):"—"}}}];return P==="coupon"&&g.push({label:t("admin.coupon.promotionCodesUsed"),name:"promotion_codes",options:{customBodyRenderLite:(u,r)=>{const l=d.customers?.[r],i=l?.coupon_usage_stats?.promotion_codes_used||[],z=l?.discount_records||[];if(i.length===0)return"—";const R=new Map;return z.forEach(y=>{if(y.promotion_code){const j=y.promotion_code.id||y.promotion_code.code;R.set(j,(R.get(j)||0)+1)}}),e.jsx(v,{sx:{display:"flex",flexWrap:"wrap",gap:.5,maxWidth:"200px"},children:i.map(y=>{const j=R.get(y.id||y.code)||0;return e.jsx(Z,{label:`${y.code} (${j})`,size:"small",variant:"outlined",onClick:()=>s(`/admin/products/promotion-codes/${y.id}`),sx:{cursor:"pointer","&:hover":{backgroundColor:"action.hover"}}},`${y.id||y.code}`)})})}}}),g.push({label:t("admin.coupon.totalSavings"),name:"total_savings",options:{customBodyRenderLite:(u,r)=>{const i=d.customers?.[r]?.coupon_usage_stats?.total_savings||{};return Object.keys(i).length===0?e.jsx(f,{variant:"body2",children:"—"}):e.jsx(v,{children:Object.entries(i).map(([z,R],y)=>{if(!R)return null;const j=R;return e.jsxs(f,{variant:"body2",sx:{display:"inline-flex"},children:[y>0&&"、",Q(j.amount,j.currency?.decimal||18)," ",j.currency?.symbol||""]},z)})})}}},{label:t("admin.coupon.usagePeriod"),name:"usage_period",options:{customBodyRenderLite:(u,r)=>{const i=d.customers?.[r]?.coupon_usage_stats;return i?e.jsxs(v,{children:[e.jsxs(f,{variant:"body2",children:[t("admin.coupon.firstUsed"),": ",A(i.first_used)]}),i.first_used!==i.last_used&&e.jsxs(f,{variant:"body2",sx:{color:"text.secondary"},children:[t("admin.coupon.lastUsed"),": ",A(i.last_used)]})]}):"—"}}}),g})(),E=(()=>{const g=[{label:t("admin.subscription.product"),name:"id",options:{customBodyRenderLite:(u,r)=>{const l=d.subscriptions?.[r];return e.jsx(ee,{to:`/admin/billing/${l.id}`,children:e.jsx(pe,{subscription:l})})}}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:(u,r)=>{const l=d.subscriptions?.[r];return e.jsx(ee,{to:`/admin/billing/${l.id}`,children:e.jsx(fe,{subscription:l})})}}},{label:t("common.customer"),name:"customer_info",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.customer;return e.jsx(oe,{customer:i,size:"small"})}}}];return P==="coupon"&&g.push({label:t("admin.coupon.promotionCodesUsed"),name:"promotion_code_info",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.discount_info?.promotion_code;return i?e.jsx(v,{children:e.jsx(Z,{label:i.code,size:"small",variant:"outlined",onClick:()=>s(`/admin/products/promotion-codes/${i.id}`),sx:{cursor:"pointer",mb:.5,"&:hover":{backgroundColor:"action.hover"}}})}):e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:t("admin.coupon.directCouponUsage")})}}}),g.push({label:t("admin.coupon.totalSavings"),name:"total_savings",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.discount_info?.total_savings||{};return Object.keys(i).length===0?e.jsx(f,{variant:"body2",sx:{color:"text.lighter"},children:"—"}):e.jsx(v,{children:Object.entries(i).map(([z,R],y)=>{if(!R)return null;const j=R;return e.jsxs(f,{variant:"body2",sx:{lineHeight:1.2},children:[y>0&&", ",Q(j.amount,j.currency?.decimal||18)," ",j.currency?.symbol||""]},z)})})}}},{label:t("admin.coupon.discountInfo"),name:"discount_info",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.discount_info;if(!i)return e.jsx(f,{variant:"body2",children:"—"});const z=i.coupon_info;return e.jsxs(v,{children:[e.jsxs(f,{variant:"body2",children:[t("admin.coupon.discountPeriod"),": ",A(i.discount_start*1e3),i.discount_end&&` - ${A(i.discount_end*1e3)}`]}),e.jsxs(f,{variant:"caption",sx:{color:"text.secondary"},children:[t("admin.coupon.duration"),":"," ",t(`admin.coupon.couponTermsDuration.${z.duration}`,{months:z.duration_in_months})]})]})}}},{label:t("common.created"),name:"created_at",options:{customBodyRenderLite:(u,r)=>{const l=d.subscriptions?.[r];return A(l?.created_at)}}}),g})();return e.jsxs(v,{children:[e.jsxs(ie,{value:a,onChange:_,sx:{flex:"1 0 auto",maxWidth:"100%",fontSize:14,borderBottom:1,borderColor:"divider",".Mui-selected":{fontSize:"14px !important",color:"primary.main"}},children:[e.jsx(K,{label:t("admin.coupon.customers")}),e.jsx(K,{label:t("admin.coupon.subscriptions")})]}),a===0&&e.jsx(v,{sx:{mt:2},children:d.customers?.length>0?e.jsx(J,{data:d.customers,columns:U,loading:n,toolbar:!1,options:{selectableRows:"none",serverSide:!0,count:d.count||0,page:m.page,rowsPerPage:m.pageSize,rowsPerPageOptions:[5,10,25,50]},onChange:x}):!n&&e.jsxs(v,{sx:{textAlign:"center",py:4},children:[e.jsx(f,{variant:"h6",sx:{color:"text.secondary"},children:t("admin.coupon.noCustomersFound")}),e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:t("admin.coupon.noCustomersRedeem")})]})}),a===1&&e.jsx(v,{children:d.subscriptions?.length>0?e.jsx(J,{data:d.subscriptions,columns:E,loading:n,options:{selectableRows:"none",serverSide:!0,count:d.count||0,page:w.page,rowsPerPage:w.pageSize,rowsPerPageOptions:[5,10,25,50]},onChange:M}):!n&&e.jsxs(v,{sx:{textAlign:"center",py:4},children:[e.jsx(f,{variant:"h6",sx:{color:"text.secondary"},children:t("admin.coupon.noSubscriptionsFound")}),e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:t("admin.coupon.noSubscriptionsRedeem")})]})})]})}const ge=O(q)(({theme:o})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:o.spacing(1.5,2),backgroundColor:o.palette.grey[50],borderRadius:o.shape.borderRadius,marginBottom:o.spacing(1),"&:last-child":{marginBottom:0}})),he=O(f)(({theme:o})=>({fontWeight:500,color:o.palette.text.primary,textTransform:"uppercase",fontSize:"0.875rem"})),ye=O(f)(({theme:o})=>({color:o.palette.text.secondary,fontSize:"0.875rem",fontFamily:"monospace"})),ve=O(q)(({theme:o})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:o.spacing(1,2),marginBottom:o.spacing(1),borderBottom:`1px solid ${o.palette.divider}`})),te=O(f)(({theme:o})=>({fontWeight:600,color:o.palette.text.primary,fontSize:"0.75rem",letterSpacing:"0.5px"}));function Oe({currencyOptions:o,type:h="coupon"}){const{t:S}=H(),{settings:t}=se();if(!o||Object.keys(o).length===0)return null;const s=Object.entries(o);return e.jsxs(v,{children:[e.jsxs(ve,{children:[e.jsx(te,{children:S("admin.coupon.currency")}),e.jsx(te,{children:S(h==="coupon"?"admin.coupon.discountAmount":"admin.coupon.minimumAmount")})]}),e.jsx(q,{children:s.map(([a,p])=>{const m=N(t.paymentMethods,a)||{symbol:a.toUpperCase(),name:a.toUpperCase(),decimal:18};let c;return typeof p=="string"?c=$(p,m.decimal):typeof p=="number"?c=p.toLocaleString():typeof p=="object"&&p!==null?"minimum_amount"in p?c=$(p.minimum_amount,m.decimal):"amount_off"in p?c=$(p.amount_off,m.decimal):c="0":c="0",e.jsxs(ge,{children:[e.jsx(he,{children:m.symbol}),e.jsx(ye,{children:c})]},a)})})]})}export{ke as A,Oe as C,$e as P,Ae as a};
|
|
1
|
+
import{r as F,j as e,B as v,q as f,a3 as q,x as Y,w as ne,aN as ie,aM as K,a7 as Z,bf as O}from"./vendor-mui-BXZut9Pz.js";import{V as H,H as $,$ as re,Z as B,Y as ce,P as ae}from"./vendor-blocklet-B67R14so.js";import{a as se,h as ue,Y as N,F as me,e as k,b8 as W,k as V,I as G,T as J,v as Q,j as A}from"./index-B4yaPb7B.js";import{D as X,P as de}from"./index-oy7LrXGT.js";import{A as le}from"./actions-BEUwbsq1.js";import{L as ee}from"./link-DMWJcQvZ.js";import{C as oe}from"./link-DsltSF2Q.js";import{S as pe}from"./description-BHxdy5I3.js";import{S as fe}from"./status-3Swm2gK5.js";import{a as _e}from"./vendor-react-BPknnnEA.js";function Ae({open:o,onClose:h,onSubmit:S=()=>{},couponId:t,promotionCode:s=null,isEditing:a=!1,availableCurrencies:p=[]}){const{t:m}=H(),{settings:c}=se(),w=ue({mode:"onChange",defaultValues:X}),{handleSubmit:L,reset:C,formState:{isSubmitting:P}}=w;F.useEffect(()=>{if(o)if(a&&s){const n={},_=s.restrictions?.minimum_amount_currency?N(c.paymentMethods,s.restrictions.minimum_amount_currency):null,x=s.restrictions?.minimum_amount?parseFloat($(s.restrictions.minimum_amount,_?.decimal||0)):void 0;let M=!1;if(s.restrictions?.currency_options){const I=Object.entries(s.restrictions.currency_options);M=I.length>0,I.forEach(([U,T])=>{const E=N(c.paymentMethods,U);let g=0;if(T&&typeof T=="object"&&"minimum_amount"in T){const u=T.minimum_amount;E&&u?g=parseFloat($(u||"0",E.decimal)):g=u||0}n[U]={minimum_amount:g}})}C({code:s.code||"",active:s.active??!0,max_redemptions:s.max_redemptions||void 0,description:s.description||"",expires_at:s.expires_at?new Date(s.expires_at*1e3).toISOString().slice(0,16):"",verification_type:s.verification_type||"code",limit_number_redemptions:!!s.max_redemptions,add_expiration_date:!!s.expires_at,restrictions:{first_time_transaction:s.restrictions?.first_time_transaction||!1,require_minimum_amount:M,minimum_amount:x,minimum_amount_currency:_?.id,currency_options:n},customer_dids:s.customer_dids||[],nft_addresses:s.nft_config?.addresses||[],nft_tags:s.nft_config?.tags||[],trusted_issuers:s.nft_config?.trusted_issuers||[],trusted_parents:s.nft_config?.trusted_parents||[],min_balance:s.nft_config?.min_balance||1,vc_roles:s.vc_config?.roles||[],vc_trusted_issuers:s.vc_config?.trusted_issuers||[]})}else C(X)},[o,a,s,C,c.paymentMethods]);const b=async n=>{try{const _={active:n.active,verification_type:n.verification_type,restrictions:n.restrictions,description:n.description,metadata:{}};a||(_.coupon_id=t),n.code&&n.code.trim()&&(_.code=n.code),n.limit_number_redemptions&&n.max_redemptions&&(_.max_redemptions=n.max_redemptions),n.expires_at&&(_.expires_at=Math.floor(new Date(n.expires_at).getTime()/1e3)),n.verification_type==="nft"?_.nft_config={addresses:n.nft_addresses?.filter(x=>x.trim())||[],tags:n.nft_tags?.filter(x=>x.trim())||[],trusted_issuers:n.trusted_issuers?.filter(x=>x.trim())||[],trusted_parents:n.trusted_parents?.filter(x=>x.trim())||[],min_balance:n.min_balance||1}:n.verification_type==="vc"?_.vc_config={roles:n.vc_roles?.filter(x=>x.trim())||[],trusted_issuers:n.vc_trusted_issuers?.filter(x=>x.trim())||[]}:n.verification_type==="user_restricted"&&(_.customer_dids=n.customer_dids?.filter(x=>x.trim())||[]),a&&s?(await k.put(`/api/promotion-codes/${s.id}`,_),B.success(m("common.saved")),W("promotion-code.updated")):(await k.post("/api/promotion-codes",_),B.success(m("admin.coupon.saved")),W("promotion-code.created")),S&&S(),h()}catch(_){console.error(_),B.error(V(_))}},D=()=>{C(),h()},d=m(a?"admin.promotionCode.edit":"admin.coupon.createPromotionCode");return e.jsx(re,{open:o,disableEscapeKeyDown:!0,fullWidth:!0,maxWidth:"sm",className:"base-dialog",onClose:D,showCloseButton:!1,title:d,actions:e.jsxs(q,{direction:"row",children:[e.jsx(Y,{size:"small",sx:{mr:2},onClick:D,disabled:P,children:m("common.cancel")}),e.jsxs(Y,{variant:"contained",color:"primary",size:"small",disabled:P,onClick:L(b),children:[P&&e.jsx(ne,{size:16,sx:{mr:1}}),m(a?"common.save":"admin.coupon.createPromotionCode")]})]}),children:e.jsx(me,{...w,children:e.jsxs(v,{sx:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:m("admin.coupon.promotionCodeDescription")}),e.jsx(de,{showCodeInput:!0,showExpandedOptions:!0,availableCurrencies:p})]})})})}function $e({data:o,onChange:h,variant:S="compact"}){const{t}=H(),s=!o.locked&&o.active,a=!o.locked,p=o.active,[m,c]=ce({action:"",loading:!1}),w=async()=>{try{c({loading:!0}),await k.put(`/api/promotion-codes/${o.id}/archive`).then(b=>b.data),B.success(t("common.saved")),W("promotion-code.updated"),h(m.action)}catch(b){console.error(b),B.error(V(b))}finally{c({loading:!1,action:""})}},L=async()=>{try{c({loading:!0}),await k.delete(`/api/promotion-codes/${o.id}`).then(b=>b.data),B.success(t("common.removed")),W("promotion-code.deleted"),h(m.action)}catch(b){console.error(b),B.error(V(b))}finally{c({loading:!1,action:""})}},C=()=>{c({action:"edit"}),h("edit",o)},P=[{label:t("admin.promotionCode.edit"),handler:C,color:s?"text.primary":"text.disabled",disabled:!s},{label:t("admin.promotionCode.archive"),handler:()=>c({action:"archive"}),color:p?"text.primary":"text.disabled",disabled:!p},{label:t("admin.promotionCode.delete"),handler:()=>c({action:"delete"}),color:a?"error.main":"text.disabled",disabled:!a}];return e.jsxs(e.Fragment,{children:[e.jsx(le,{variant:S,actions:P}),m.action==="archive"&&e.jsx(G,{onConfirm:w,onCancel:()=>c({action:""}),title:t("admin.promotionCode.archive"),message:t("admin.promotionCode.archiveTip")}),m.action==="delete"&&e.jsx(G,{onConfirm:L,onCancel:()=>c({action:""}),title:t("admin.promotionCode.delete"),message:t("admin.promotionCode.deleteTip")})]})}function xe(o){if((!o.couponId||o.couponId==="")&&(!o.promotionCodeId||o.promotionCodeId===""))throw new Error("Either couponId or promotionCodeId must be provided")}const be=(o,h,S,t="coupon")=>{const s=new URLSearchParams({page:h.page.toString(),pageSize:h.pageSize.toString()});s.append("type",S);const a=t==="coupon"?`/api/coupons/${o}/redemptions`:`/api/promotion-codes/${o}/redemptions`;return k.get(`${a}?${s}`).then(p=>p.data)};function ke({couponId:o="",promotionCodeId:h=""}){xe({couponId:o,promotionCodeId:h});const{t}=H(),s=_e(),[a,p]=F.useState(0),[m,c]=F.useState({page:0,pageSize:10}),[w,L]=F.useState({page:0,pageSize:10}),C=o&&o!==""?o:h,P=o&&o!==""?"coupon":"promotion-code",b=a===0?m:w,D=a===0?"customer":"subscription",{data:d={customers:[],subscriptions:[],count:0},loading:n}=ae(()=>be(C,{page:b.page+1,pageSize:b.pageSize},D,P),{refreshDeps:[C,b.page,b.pageSize,a]}),_=(g,u)=>{p(u),u===0?c({page:0,pageSize:10}):L({page:0,pageSize:10})},x=({page:g,rowsPerPage:u})=>{c({page:g,pageSize:u})},M=({page:g,rowsPerPage:u})=>{L({page:g,pageSize:u})},U=(()=>{const g=[{label:t("common.name"),name:"name",options:{customBodyRenderLite:(u,r)=>{const l=d.customers?.[r];return e.jsx(oe,{customer:l,size:"small"})}}},{label:t("common.email"),name:"email",options:{customBodyRenderLite:(u,r)=>d.customers?.[r]?.email||"—"}},{label:t("admin.coupon.usageStats"),name:"usage_stats",options:{customBodyRenderLite:(u,r)=>{const i=d.customers?.[r]?.coupon_usage_stats;return i?e.jsx(f,{variant:"body2",children:i.total_discount_records}):"—"}}}];return P==="coupon"&&g.push({label:t("admin.coupon.promotionCodesUsed"),name:"promotion_codes",options:{customBodyRenderLite:(u,r)=>{const l=d.customers?.[r],i=l?.coupon_usage_stats?.promotion_codes_used||[],z=l?.discount_records||[];if(i.length===0)return"—";const R=new Map;return z.forEach(y=>{if(y.promotion_code){const j=y.promotion_code.id||y.promotion_code.code;R.set(j,(R.get(j)||0)+1)}}),e.jsx(v,{sx:{display:"flex",flexWrap:"wrap",gap:.5,maxWidth:"200px"},children:i.map(y=>{const j=R.get(y.id||y.code)||0;return e.jsx(Z,{label:`${y.code} (${j})`,size:"small",variant:"outlined",onClick:()=>s(`/admin/products/promotion-codes/${y.id}`),sx:{cursor:"pointer","&:hover":{backgroundColor:"action.hover"}}},`${y.id||y.code}`)})})}}}),g.push({label:t("admin.coupon.totalSavings"),name:"total_savings",options:{customBodyRenderLite:(u,r)=>{const i=d.customers?.[r]?.coupon_usage_stats?.total_savings||{};return Object.keys(i).length===0?e.jsx(f,{variant:"body2",children:"—"}):e.jsx(v,{children:Object.entries(i).map(([z,R],y)=>{if(!R)return null;const j=R;return e.jsxs(f,{variant:"body2",sx:{display:"inline-flex"},children:[y>0&&"、",Q(j.amount,j.currency?.decimal||18)," ",j.currency?.symbol||""]},z)})})}}},{label:t("admin.coupon.usagePeriod"),name:"usage_period",options:{customBodyRenderLite:(u,r)=>{const i=d.customers?.[r]?.coupon_usage_stats;return i?e.jsxs(v,{children:[e.jsxs(f,{variant:"body2",children:[t("admin.coupon.firstUsed"),": ",A(i.first_used)]}),i.first_used!==i.last_used&&e.jsxs(f,{variant:"body2",sx:{color:"text.secondary"},children:[t("admin.coupon.lastUsed"),": ",A(i.last_used)]})]}):"—"}}}),g})(),E=(()=>{const g=[{label:t("admin.subscription.product"),name:"id",options:{customBodyRenderLite:(u,r)=>{const l=d.subscriptions?.[r];return e.jsx(ee,{to:`/admin/billing/${l.id}`,children:e.jsx(pe,{subscription:l})})}}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:(u,r)=>{const l=d.subscriptions?.[r];return e.jsx(ee,{to:`/admin/billing/${l.id}`,children:e.jsx(fe,{subscription:l})})}}},{label:t("common.customer"),name:"customer_info",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.customer;return e.jsx(oe,{customer:i,size:"small"})}}}];return P==="coupon"&&g.push({label:t("admin.coupon.promotionCodesUsed"),name:"promotion_code_info",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.discount_info?.promotion_code;return i?e.jsx(v,{children:e.jsx(Z,{label:i.code,size:"small",variant:"outlined",onClick:()=>s(`/admin/products/promotion-codes/${i.id}`),sx:{cursor:"pointer",mb:.5,"&:hover":{backgroundColor:"action.hover"}}})}):e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:t("admin.coupon.directCouponUsage")})}}}),g.push({label:t("admin.coupon.totalSavings"),name:"total_savings",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.discount_info?.total_savings||{};return Object.keys(i).length===0?e.jsx(f,{variant:"body2",sx:{color:"text.lighter"},children:"—"}):e.jsx(v,{children:Object.entries(i).map(([z,R],y)=>{if(!R)return null;const j=R;return e.jsxs(f,{variant:"body2",sx:{lineHeight:1.2},children:[y>0&&", ",Q(j.amount,j.currency?.decimal||18)," ",j.currency?.symbol||""]},z)})})}}},{label:t("admin.coupon.discountInfo"),name:"discount_info",options:{customBodyRenderLite:(u,r)=>{const i=d.subscriptions?.[r]?.discount_info;if(!i)return e.jsx(f,{variant:"body2",children:"—"});const z=i.coupon_info;return e.jsxs(v,{children:[e.jsxs(f,{variant:"body2",children:[t("admin.coupon.discountPeriod"),": ",A(i.discount_start*1e3),i.discount_end&&` - ${A(i.discount_end*1e3)}`]}),e.jsxs(f,{variant:"caption",sx:{color:"text.secondary"},children:[t("admin.coupon.duration"),":"," ",t(`admin.coupon.couponTermsDuration.${z.duration}`,{months:z.duration_in_months})]})]})}}},{label:t("common.created"),name:"created_at",options:{customBodyRenderLite:(u,r)=>{const l=d.subscriptions?.[r];return A(l?.created_at)}}}),g})();return e.jsxs(v,{children:[e.jsxs(ie,{value:a,onChange:_,sx:{flex:"1 0 auto",maxWidth:"100%",fontSize:14,borderBottom:1,borderColor:"divider",".Mui-selected":{fontSize:"14px !important",color:"primary.main"}},children:[e.jsx(K,{label:t("admin.coupon.customers")}),e.jsx(K,{label:t("admin.coupon.subscriptions")})]}),a===0&&e.jsx(v,{sx:{mt:2},children:d.customers?.length>0?e.jsx(J,{data:d.customers,columns:U,loading:n,toolbar:!1,options:{selectableRows:"none",serverSide:!0,count:d.count||0,page:m.page,rowsPerPage:m.pageSize,rowsPerPageOptions:[5,10,25,50]},onChange:x}):!n&&e.jsxs(v,{sx:{textAlign:"center",py:4},children:[e.jsx(f,{variant:"h6",sx:{color:"text.secondary"},children:t("admin.coupon.noCustomersFound")}),e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:t("admin.coupon.noCustomersRedeem")})]})}),a===1&&e.jsx(v,{children:d.subscriptions?.length>0?e.jsx(J,{data:d.subscriptions,columns:E,loading:n,options:{selectableRows:"none",serverSide:!0,count:d.count||0,page:w.page,rowsPerPage:w.pageSize,rowsPerPageOptions:[5,10,25,50]},onChange:M}):!n&&e.jsxs(v,{sx:{textAlign:"center",py:4},children:[e.jsx(f,{variant:"h6",sx:{color:"text.secondary"},children:t("admin.coupon.noSubscriptionsFound")}),e.jsx(f,{variant:"body2",sx:{color:"text.secondary"},children:t("admin.coupon.noSubscriptionsRedeem")})]})})]})}const ge=O(q)(({theme:o})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:o.spacing(1.5,2),backgroundColor:o.palette.grey[50],borderRadius:o.shape.borderRadius,marginBottom:o.spacing(1),"&:last-child":{marginBottom:0}})),he=O(f)(({theme:o})=>({fontWeight:500,color:o.palette.text.primary,textTransform:"uppercase",fontSize:"0.875rem"})),ye=O(f)(({theme:o})=>({color:o.palette.text.secondary,fontSize:"0.875rem",fontFamily:"monospace"})),ve=O(q)(({theme:o})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:o.spacing(1,2),marginBottom:o.spacing(1),borderBottom:`1px solid ${o.palette.divider}`})),te=O(f)(({theme:o})=>({fontWeight:600,color:o.palette.text.primary,fontSize:"0.75rem",letterSpacing:"0.5px"}));function Oe({currencyOptions:o,type:h="coupon"}){const{t:S}=H(),{settings:t}=se();if(!o||Object.keys(o).length===0)return null;const s=Object.entries(o);return e.jsxs(v,{children:[e.jsxs(ve,{children:[e.jsx(te,{children:S("admin.coupon.currency")}),e.jsx(te,{children:S(h==="coupon"?"admin.coupon.discountAmount":"admin.coupon.minimumAmount")})]}),e.jsx(q,{children:s.map(([a,p])=>{const m=N(t.paymentMethods,a)||{symbol:a.toUpperCase(),name:a.toUpperCase(),decimal:18};let c;return typeof p=="string"?c=$(p,m.decimal):typeof p=="number"?c=p.toLocaleString():typeof p=="object"&&p!==null?"minimum_amount"in p?c=$(p.minimum_amount,m.decimal):"amount_off"in p?c=$(p.amount_off,m.decimal):c="0":c="0",e.jsxs(ge,{children:[e.jsx(he,{children:m.symbol}),e.jsx(ye,{children:c})]},a)})})]})}export{ke as A,Oe as C,$e as P,Ae as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as n,q as l,ch as D,aT as G,ad as T,bN as H,a3 as $,bH as I}from"./vendor-mui-BXZut9Pz.js";import{V as L}from"./vendor-blocklet-
|
|
1
|
+
import{r as x,j as n,q as l,ch as D,aT as G,ad as T,bN as H,a3 as $,bH as I}from"./vendor-mui-BXZut9Pz.js";import{V as L}from"./vendor-blocklet-B67R14so.js";import{a as P}from"./index-B4yaPb7B.js";import{C as V}from"./currency-GstdXsJf.js";function _({mode:i,hasSelected:d,onSelect:b,value:r,width:z="100%",disabled:h=!1,selectSX:k={},currencyFilter:v=()=>!0,hideMethod:t=!1,includeAllOption:j=!1,allOption:o={value:"all",label:"All"},selectedSx:A={}}){const{t:E}=L(),{settings:g}=P(),[C,u]=x.useState(i),c=x.useMemo(()=>(g.paymentMethods||[]).map(e=>({method:e,currencies:(e.payment_currencies||[]).map(s=>({...s,method:e}))})),[g.paymentMethods]),f=x.useMemo(()=>c.flatMap(e=>e.currencies),[c]);x.useEffect(()=>{if(r&&i==="selected"&&f.length>0){const e=f.find(s=>s.id===r);if(e&&!d(e)){const s=setTimeout(()=>{b(r)},0);return()=>clearTimeout(s)}}},[r,i,f,d]);const W=e=>{h||(u(i),b(e.target.value))},p=f.find(e=>e.id===r),a=c.find(e=>e.currencies.some(s=>s.id===r))?.method,S=x.useMemo(()=>c.map(e=>({method:e.method,currencies:e.currencies.filter(s=>v(s)&&!d(s))})).filter(e=>e.currencies.length>0),[c,d]),y=S.length>0&&!h;if(C==="selected"){const e=j&&r===o.value;let s="";return e?s=o.label:p?.symbol?s=t?p.symbol:`${p.symbol} (${a?.name||""})`:!t&&a?.name&&(s=`(${a.name})`),n.jsxs(l,{onClick:()=>{y&&u("selecting")},sx:{cursor:y?"pointer":"default",display:"inline-flex",minWidth:"120px",justifyContent:"flex-end",textAlign:"right",width:"100%",...A},children:[s,y&&n.jsx(D,{sx:{color:"text.secondary",fontSize:21}})]})}return y?C==="selecting"?n.jsxs(G,{size:"small",value:r,renderValue:()=>{if(j&&r===o.value)return n.jsx(l,{variant:"body1",sx:{display:"inline-flex",fontSize:"12px",color:"text.secondary"},children:o.label});const e=p?.symbol||"",s=!t&&a?.name?` (${a.name})`:"";return n.jsx(l,{variant:"body1",sx:{display:"inline-flex",fontSize:"12px",color:"text.secondary"},children:`${e}${s}`.trim()})},onChange:W,open:!0,sx:{width:z,...k},disabled:h,onClose:()=>u(i),children:[j?n.jsx(T,{value:o.value,children:n.jsx(l,{sx:{fontWeight:"bold"},children:o.label})}):null,S.flatMap(e=>{const s=t?null:n.jsx(H,{sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:"2.1875rem"},children:e.method.name},e.method.id),w=e.currencies.map(m=>n.jsx(T,{sx:{pl:3},value:m.id,children:n.jsxs($,{direction:"row",sx:{width:"100%",justifyContent:"space-between",gap:2},children:[t?null:n.jsx(V,{logo:m.logo,name:m.name}),n.jsx(l,{sx:{fontWeight:t?"normal":"bold"},children:m.symbol})]})},m.id));return s?[s,...w]:w})]}):n.jsx("span",{children:n.jsxs($,{direction:"row",onClick:()=>u("selecting"),sx:{alignItems:"center",cursor:"pointer",display:"inline-flex"},children:[n.jsx(I,{color:"primary"}),n.jsx(l,{color:"primary",children:E("admin.price.currency.add")})]})}):null}export{_ as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./vendor-mui-BXZut9Pz.js";import"./vendor-blocklet-
|
|
1
|
+
import"./vendor-mui-BXZut9Pz.js";import"./vendor-blocklet-B67R14so.js";import"./index-B4yaPb7B.js";const d=(i,f,{t:m,separator:c=" "})=>{const h=(r,o)=>`${r||0} ${m(`common.${o}${r>1?"s":""}`).toLowerCase()}`,s=(r,o)=>{switch(o){case"hour":{if(r<24)return[["hour",r]];if(r<48)return[["day",Math.floor(r/24)],["hour",r%24]];const t=Math.floor(r/24);return s(t,"day")}case"day":{if(r<7)return[["day",r]];if(r<14)return[["week",Math.floor(r/7)],["day",r%7]];if(r<30)return r%7===0?[["week",r/7]]:[["day",r]];const t=Math.floor(r/365),e=r%365,n=Math.floor(e/30);return t>0?n>0?[["year",t],["month",n]]:[["year",t]]:n>0?[["month",n],["week",Math.floor(e%30/7)]]:[["week",Math.floor(r/7)]]}case"week":{if(r<4)return[["week",r]];if(r<8)return[["month",Math.floor(r/4)],["week",r%4]];const t=Math.floor(r/4);return s(t,"month")}case"month":{const t=Math.floor(r/12),e=r%12;return t>0?e>0?[["year",t],["month",e]]:[["year",t]]:[["month",r]]}case"year":return[["year",r]];default:return[[o,r]]}},u=s(i,f).filter(([,r])=>r>0);return u.length===0?h(0,f):u.map(([r,o])=>h(o,r)).join(c)};export{d as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,a3 as d,q as r,O as l,be as x}from"./vendor-mui-BXZut9Pz.js";import"./vendor-blocklet-
|
|
1
|
+
import{j as s,a3 as d,q as r,O as l,be as x}from"./vendor-mui-BXZut9Pz.js";import"./vendor-blocklet-B67R14so.js";import{d as p,aM as o,J as n}from"./index-B4yaPb7B.js";function f({subscription:t,variant:e="body1",hideSubscription:a=!1,maxLength:i=80}){const{isMobile:c}=p();return t.description?s.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[s.jsx(r,{variant:e,className:"subscription-description",children:s.jsx(o,{text:t.description,maxLength:i,useWidth:!0})}),!a&&!c&&s.jsx(l,{title:n(t.items),children:s.jsx(x,{sx:{color:"text.secondary"},fontSize:"small"})})]}):s.jsx(r,{variant:e,children:s.jsx(o,{text:n(t.items),maxLength:i,useWidth:!0})})}export{f as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,w as z,A as N,B as o,a3 as m,bv as P,q as x,Y as v,x as b,O as q,cA as H,bf as J}from"./vendor-mui-BXZut9Pz.js";import{V as U,Y as V,P as Y,Z as f}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,w as z,A as N,B as o,a3 as m,bv as P,q as x,Y as v,x as b,O as q,cA as H,bf as J}from"./vendor-mui-BXZut9Pz.js";import{V as U,Y as V,P as Y,Z as f}from"./vendor-blocklet-B67R14so.js";import{d as G,h as Z,ac as D,j as M,F as K,e as w,b8 as S,k as A}from"./index-B4yaPb7B.js";import{C as Q}from"./copyable-CprMHdhV.js";import{I as g}from"./info-metric-ukWq8INi.js";import{I as d}from"./info-row-CaPaNF4L.js";import{I as X}from"./info-row-group-Cxo-4Gk5.js";import{I as ee}from"./list-ZaBapEXW.js";import{M as te}from"./editor-vZvxDUTl.js";import{M as ae}from"./list-B2b-s8wM.js";import{S as R}from"./header-ivXuPt06.js";import{g as se,a as ie,T as ne}from"./tax-utils-B8J0Kfnz.js";import{T as oe}from"./index-C3AP4jq0.js";import{D as re}from"./drawer-form-CQjNFFWk.js";import{g as le}from"./util-B8B3fsMa.js";import{a as de}from"./vendor-react-BPknnnEA.js";import"./table-BN3WBnr3.js";import"./cache-state-lld4zuDg.js";import"./link-DsltSF2Q.js";import"./filter-toolbar-VvmMATj0.js";import"./lodash-B4Ozcv0x.js";import"./product-select-_72p-5lF.js";import"./info-card-C9dRgztS.js";import"./action-C2c0yWuW.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./form-CnrBCyTJ.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";import"./collapse-CSrlJ0eG.js";const ce=r=>w.get(`/api/tax-rates/${r}`).then(t=>t.data),xe=(r={})=>Object.entries(r).map(([t,n])=>({key:t,value:typeof n=="object"?JSON.stringify(n,null,2):String(n)})),me=r=>r.reduce((t,n)=>{if(!n.key||!n.value)return t;try{t[n.key]=JSON.parse(n.value)}catch{t[n.key]=n.value}return t},{});function He({id:r}){const{t,locale:n}=U(),{isMobile:O}=G(),W=de(),[c,l]=V({editing:{metadata:!1,taxRate:!1},loading:{metadata:!1,taxRate:!1}}),j=Z({defaultValues:{display_name:"",description:"",country:"",state:"",postal_code:"",tax_code:"",percentage:0,metadata:[{key:"",value:""}]}}),{data:a,loading:$,error:C,runAsync:h}=Y(()=>ce(r));if($&&!a)return e.jsx(z,{});if(C)return e.jsx(N,{severity:"error",children:C.message});if(!a)return null;const F=s=>{s==="delete"?W("/admin/tax/rates"):h()},I=()=>{l(s=>({editing:{...s.editing,metadata:!0}}))},B=()=>{j.reset({display_name:a.display_name,description:a.description||"",country:(a.country||"").toLowerCase(),state:a.state||"",postal_code:a.postal_code||"",tax_code:a.tax_code||"",percentage:a.percentage,metadata:xe(a.metadata||{})}),l(s=>({editing:{...s.editing,taxRate:!0}}))},E=async s=>{try{l(i=>({loading:{...i.loading,metadata:!0}})),await w.put(`/api/tax-rates/${r}`,s),f.success(t("common.saved")),S("tax-rate.updated"),h()}catch(i){console.error(i),f.error(A(i))}finally{l(i=>({loading:{...i.loading,metadata:!1}}))}},L=async s=>{try{l(y=>({loading:{...y.loading,taxRate:!0}}));const{metadata:i,...T}=s;await w.put(`/api/tax-rates/${r}`,{...T,percentage:Number(T.percentage),metadata:me(i||[])}),f.success(t("admin.taxRate.updated")),S("tax-rate.updated"),l(y=>({editing:{...y.editing,taxRate:!1}})),h()}catch(i){console.error(i),f.error(A(i))}finally{l(i=>({loading:{...i.loading,taxRate:!1}}))}},p=a.country?se(a.country):null,_=[a.state,a.postal_code].filter(Boolean),k=p?`${p.name}${_.length>0?` · ${_.join(" · ")}`:""}`:"—",u=a.tax_code?ie(a.tax_code,n):null;return e.jsxs(pe,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(o,{children:[!a.active&&e.jsx(N,{severity:"warning",sx:{mb:2},children:t("admin.taxRate.inactiveWarning")}),e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>le("/admin/tax/rates"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(P,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.taxRates")})]}),e.jsx(ne,{data:a,onChange:F})]}),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(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(x,{variant:"h2",sx:{color:"text.primary"},children:a.display_name}),a.description&&e.jsx(x,{variant:"subtitle1",sx:{color:"text.lighter"},children:a.description})]})}),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(g,{label:t("common.id"),value:e.jsx(Q,{text:r,style:{marginLeft:4}}),divider:!0}),e.jsx(g,{label:t("admin.taxRate.percentage"),value:`${a.percentage}%`,divider:!0}),e.jsx(g,{label:t("admin.taxRate.location"),value:p?e.jsxs(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(D,{iso2:a.country.toLowerCase(),style:{width:24}}),e.jsx(x,{variant:"body2",children:k})]}):k,divider:!0}),e.jsx(g,{label:t("common.createdAt"),value:M(a.created_at),divider:!0})]})]}),e.jsx(v,{})]}),e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".tax-column-1":{minWidth:{xs:"100%",lg:"600px"}},".tax-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(o,{className:"tax-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(o,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(R,{title:t("admin.details"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.taxRate,onClick:B,children:t("common.edit")})}),e.jsxs(X,{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(d,{label:t("admin.taxRate.displayName"),value:a.display_name}),e.jsx(d,{label:t("admin.taxRate.country"),value:p?e.jsxs(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(D,{iso2:a.country.toLowerCase(),style:{width:24}}),e.jsx(x,{variant:"body2",children:p.name})]}):"—"}),e.jsx(d,{label:t("admin.taxRate.state"),value:a.state||"—"}),e.jsx(d,{label:t("admin.taxRate.postalCode"),value:a.postal_code||"—"}),e.jsx(d,{label:t("admin.taxRate.percentage"),value:`${a.percentage}%`}),e.jsx(d,{label:t("admin.taxRate.taxCode"),value:u?e.jsx(q,{title:u.description,arrow:!0,placement:"top",children:e.jsxs(o,{children:[e.jsx(x,{variant:"body2",sx:{fontWeight:500},children:u.name}),e.jsx(x,{variant:"caption",sx:{color:"text.secondary"},children:u.id})]})}):a.tax_code||"—"}),e.jsx(d,{label:t("common.status"),value:a.active?t("common.active"):t("common.inactive")}),e.jsx(d,{label:t("common.updatedAt"),value:M(a.updated_at)})]})]}),e.jsx(v,{}),e.jsxs(o,{className:"section",children:[e.jsx(R,{title:t("admin.taxRate.associatedInvoices")}),e.jsx(o,{className:"section-body",children:e.jsx(ee,{features:{customer:!0,filter:!1,toolbar:!1},tax_rate_id:r,mode:"admin",status:""})})]})]}),O&&e.jsx(v,{}),e.jsx(o,{className:"tax-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(o,{className:"section",children:[e.jsx(R,{title:t("common.metadata.label"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.metadata,onClick:I,children:t("common.edit")})}),e.jsxs(o,{className:"section-body",children:[e.jsx(ae,{data:a.metadata||{},handleEditMetadata:I}),c.editing.metadata&&e.jsx(te,{data:a,loading:c.loading.metadata,onSave:E,onCancel:()=>l(s=>({editing:{...s.editing,metadata:!1}}))})]})]})})]}),c.editing.taxRate&&e.jsx(re,{icon:e.jsx(H,{}),text:t("admin.taxRate.edit"),open:c.editing.taxRate,onClose:()=>l(s=>({editing:{...s.editing,taxRate:!1}})),width:640,addons:e.jsx(b,{variant:"contained",size:"small",disabled:c.loading.taxRate,onClick:j.handleSubmit(L),children:t("common.save")}),children:e.jsx(K,{...j,children:e.jsx(oe,{})})})]})}const pe=J(m)``;export{He as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{r as y,j as e,A as f,w as _,B as i,a3 as s,bv as C,q as n,x as h,N as I,Y as k,a7 as S,bf as D}from"./vendor-mui-BXZut9Pz.js";import{V as A,P as E}from"./vendor-blocklet-B67R14so.js";import{u as T,a3 as N,i as G,j as m,N as z,p as B,e as $}from"./index-B4yaPb7B.js";import{S as R}from"./source-data-viewer-D1GShrs5.js";import{I as d}from"./info-metric-ukWq8INi.js";import{S as j}from"./header-ivXuPt06.js";import{I as o}from"./info-row-CaPaNF4L.js";import{I as M}from"./info-row-group-Cxo-4Gk5.js";import{u as W}from"./browser-DF2vfpBa.js";import{i as P}from"./did-Bqcz-NjH.js";import{e as q,a as H}from"./vendor-react-BPknnnEA.js";import"./util-B8B3fsMa.js";import"./lodash-B4Ozcv0x.js";const O=c=>$.get(`/api/credit-transactions/${c}`).then(a=>a.data);function ne(){const{id:c}=q(),a=H(),{t:r}=A(),{session:x}=T(),g=W(),{loading:v,error:u,data:t}=E(()=>O(c)),b=y.useCallback(()=>{a("/customer",{replace:!0})},[a]);if(t?.customer?.did&&x?.user?.did&&!P(t.customer.did,x.user.did))return e.jsx(f,{severity:"error",children:r("common.accessDenied")});if(u)return e.jsx(f,{severity:"error",children:u.message});if(v||!t)return e.jsx(_,{});const w=l=>{if(!l)return null;const p={pending:{label:r("common.pending"),color:"warning"},completed:{label:r("common.completed"),color:"success"},failed:{label:r("common.failed"),color:"error"}}[l]||{label:l,color:"default"};return e.jsx(S,{label:p.label,size:"small",color:p.color})};return e.jsxs(V,{children:[e.jsxs(i,{children:[e.jsxs(s,{className:"page-header",direction:"row",justifyContent:"space-between",alignItems:"center",sx:{position:"relative"},children:[g?e.jsx(i,{}):e.jsxs(s,{direction:"row",onClick:b,alignItems:"center",sx:{fontWeight:"normal",cursor:"pointer"},children:[e.jsx(C,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(n,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:r("admin.creditTransactions.title")})]}),e.jsxs(s,{direction:"row",spacing:1,children:[t.creditGrant&&e.jsx(h,{variant:"outlined",size:"small",onClick:()=>a(`/customer/credit-grant/${t.credit_grant_id}`),children:r("common.viewGrant")}),t.subscription&&e.jsx(h,{variant:"outlined",size:"small",onClick:()=>a(`/customer/subscription/${t.subscription_id}`),children:r("common.viewSubscription")})]})]}),e.jsxs(i,{mt:4,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(s,{direction:"row",justifyContent:"space-between",alignItems:"center",children:e.jsxs(s,{direction:"column",alignItems:"flex-start",justifyContent:"space-around",children:[e.jsx(n,{variant:"h2",color:"text.primary",children:t.description||r("common.creditTransaction")}),e.jsx(n,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:t.id})]})}),e.jsxs(s,{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(d,{label:r("common.creditAmount"),value:e.jsx(s,{direction:"row",alignItems:"center",spacing:.5,children:e.jsxs(n,{variant:"body2",sx:{color:"error.main"},children:["-",N(G(t.credit_amount,t.creditGrant?.paymentCurrency?.decimal||0),t.creditGrant?.paymentCurrency?.symbol||"")]})}),divider:!0}),t.transfer_status&&e.jsx(d,{label:r("common.transferStatus"),value:w(t.transfer_status),divider:!0}),e.jsx(d,{label:r("common.createdAt"),value:m(t.created_at)})]})]})]}),e.jsxs(i,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(j,{title:r("admin.details")}),e.jsxs(M,{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(o,{label:r("common.customer"),value:e.jsxs(s,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(I,{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(n,{children:t.customer?.name})]})}),e.jsx(o,{label:r("common.creditGrant"),value:e.jsx(n,{component:"span",onClick:()=>a(`/customer/credit-grant/${t.credit_grant_id}`),sx:{color:"text.link",cursor:"pointer"},children:t.creditGrant?.name||t.credit_grant_id})}),t.subscription&&e.jsx(o,{label:r("admin.subscription.name"),value:e.jsx(n,{component:"span",onClick:()=>a(`/customer/subscription/${t.subscription_id}`),sx:{color:"text.link",cursor:"pointer"},children:t.subscription.description||t.subscription_id})}),t.transfer_hash&&t.paymentMethod&&e.jsx(o,{label:r("common.transferTxHash"),value:e.jsx(B,{details:{arcblock:{tx_hash:t.transfer_hash,payer:""}},method:t.paymentMethod,mode:"customer"})}),e.jsx(o,{label:r("admin.meterEvent.reportedAt"),value:m(t.meterEvent?.timestamp?t.meterEvent.timestamp*1e3:t.meterEvent?.created_at||t.created_at)}),e.jsx(o,{label:r("admin.meterEvent.processedAt"),value:m(t.meterEvent?.processed_at?t.meterEvent.processed_at*1e3:t.created_at)})]})]}),t.meterEvent?.source_data&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsxs(i,{className:"section",children:[e.jsx(j,{title:r("common.sourceData")}),e.jsx(i,{className:"section-body",children:e.jsx(R,{data:t.meterEvent.source_data})})]})]})]})}const V=D(s)`
|
|
2
|
+
margin-bottom: 24px;
|
|
3
|
+
gap: 24px;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
@media (max-width: ${({theme:c})=>c.breakpoints.values.md}px) {
|
|
6
|
+
.section-header {
|
|
7
|
+
font-size: 18px;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`;export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,b$ as U,a3 as d,B as s,q as c,bf as C,bg as q,a7 as v,A as z,w as H,z as Y,bv as G,Y as f,x as O}from"./vendor-mui-BXZut9Pz.js";import{V as E,P as W,Y as Z,Z as A}from"./vendor-blocklet-DcLR2Cyf.js";import{e as w,d as J,a as K,n as Q,j as N,b8 as X,k as ee}from"./index-BarN7DfU.js";import{C as oe}from"./copyable-QrCyyiou.js";import{E as ie}from"./list-DaK9287Y.js";import{I as b}from"./info-metric-Dl4ZDm0Z.js";import{I as p}from"./info-row-jI0h_hv4.js";import{I as te}from"./info-row-group-CFuMWJf1.js";import{M as ne}from"./editor-AmthipP2.js";import{M as se}from"./list-CkHExntK.js";import{S as g}from"./header-ivXuPt06.js";import{g as re}from"./util-DxXTXkeY.js";import{P as ae,C as ce,A as de,a as le}from"./currency-restrictions-BcEm8W45.js";import{C as me}from"./link-CmPoIweR.js";import{a as pe}from"./vendor-react-BPknnnEA.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"./description-SnR5WxWT.js";import"./status-CUVYrUIG.js";const xe=()=>w.get("/api/customers?limit=1000").then(t=>t.data);function ue({data:t}){const{t:o}=E(),{data:M}=W(xe,{ready:t.verification_type==="user_restricted"&&(t.customer_dids?.length??0)>0}),S=M?.list||[],k=()=>t.nft_config?e.jsxs(d,{spacing:2,children:[t.nft_config.nft_addresses&&t.nft_config.nft_addresses.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.nftAddresses")}),e.jsx(_,{children:t.nft_config.nft_addresses.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"default",sx:{backgroundColor:"grey.50",borderColor:"grey.300",fontFamily:"monospace",fontSize:"0.75rem",maxWidth:200}},n))})]}),t.nft_config.nft_tags&&t.nft_config.nft_tags.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.nftTags")}),e.jsx(_,{children:t.nft_config.nft_tags.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"primary",sx:{backgroundColor:"primary.50",fontWeight:500}},n))})]}),t.nft_config.min_balance&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.minBalance")}),e.jsx(c,{variant:"body2",sx:{fontWeight:"medium"},children:t.nft_config.min_balance})]})]}):e.jsx(c,{variant:"body2",sx:{color:"text.secondary"},children:o("admin.promotionCode.noNftConfig")}),x=()=>t.vc_config?e.jsxs(d,{spacing:2,children:[t.vc_config.vc_roles&&t.vc_config.vc_roles.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.requiredRoles")}),e.jsx(_,{children:t.vc_config.vc_roles.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"secondary",sx:{backgroundColor:"secondary.50",fontWeight:500,textTransform:"capitalize"}},n))})]}),t.vc_config.vc_trusted_issuers&&t.vc_config.vc_trusted_issuers.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.trustedIssuers")}),e.jsx(_,{children:t.vc_config.vc_trusted_issuers.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"info",sx:{backgroundColor:"info.50",fontFamily:"monospace",fontSize:"0.75rem",maxWidth:200}},n))})]})]}):e.jsx(c,{variant:"body2",sx:{color:"text.secondary"},children:o("admin.promotionCode.noVcConfig")}),l=()=>t.customer_dids?.length?e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.allowedUsers")}),e.jsx(ge,{children:t.customer_dids.map(n=>{const i=S.find(u=>u.did===n||u.id===n);return i?e.jsx(me,{customer:i,size:"small",cardProps:{sx:{border:"none",p:0,minWidth:0}}},n):e.jsx(v,{label:n,size:"small",variant:"outlined",color:"default",sx:{maxWidth:200,backgroundColor:"grey.50",borderColor:"grey.300"}},n)})})]}):e.jsx(c,{variant:"body2",sx:{color:"text.secondary"},children:o("admin.promotionCode.noUsersSpecified")}),I=()=>{switch(t.verification_type){case"nft":return k();case"vc":return x();case"user_restricted":return l();default:return e.jsx(c,{variant:"body2",sx:{color:"text.secondary",fontStyle:"italic"},children:o("admin.promotionCode.codeVerificationOnly")})}};return e.jsx(fe,{children:e.jsx(U,{children:e.jsxs(d,{spacing:2,children:[e.jsxs(s,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:{xs:1,sm:2},alignItems:{xs:"flex-start",sm:"center"}},children:[e.jsx(c,{variant:"caption",sx:{color:"text.secondary"},children:o("admin.promotionCode.verificationType")}),e.jsx(c,{variant:"subtitle2",sx:{color:"text.primary",fontWeight:"medium"},children:o(`admin.promotionCode.verificationTypeMap.${t.verification_type}`)})]}),I()]})})})}const fe=C(q)(({theme:t})=>({border:`1px solid ${t.palette.divider}`,boxShadow:"none",backgroundColor:t.palette.background.paper})),j=C(s)({display:"flex",flexDirection:"column",gap:8}),h=C(c)(({theme:t})=>({fontSize:"0.875rem",fontWeight:500,color:t.palette.text.secondary})),_=C(s)({display:"flex",flexDirection:"row",flexWrap:"wrap",gap:8}),ge=C(s)({display:"flex",flexDirection:"row",flexWrap:"wrap",gap:8,alignItems:"center"}),je=t=>w.get(`/api/promotion-codes/${t}`).then(o=>o.data),he=t=>w.get(`/api/coupons/${t}`).then(o=>o.data);function eo(t){const{t:o}=E(),{isMobile:M}=J(),S=pe(),{settings:k}=K(),[x,l]=Z({editing:{metadata:!1},loading:{metadata:!1},editModalOpen:!1}),{loading:I,error:n,data:i,runAsync:u}=W(()=>je(t.id)),{data:m}=W(()=>i?.coupon_id?he(i.coupon_id):Promise.resolve(null),{refreshDeps:[i?.coupon_id]});if(n)return e.jsx(z,{severity:"error",children:n.message});if(I||!i)return e.jsx(H,{});const T=(()=>{const r=k.paymentMethods?.flatMap(y=>y.payment_currencies)||[];if(!m||m.percent_off)return r;const a=new Set;return m.currency_id&&a.add(m.currency_id),m.currency_options&&typeof m.currency_options=="object"&&Object.keys(m.currency_options).forEach(y=>{a.add(y)}),r.filter(y=>a.has(y.id))})(),P=async r=>{try{l(a=>({loading:{...a.loading,metadata:!0}})),await w.put(`/api/promotion-codes/${t.id}`,{metadata:r.metadata}),A.success(o("common.saved")),X("promotion-code.updated"),u()}catch(a){console.error(a),A.error(ee(a))}finally{l(a=>({loading:{...a.loading,metadata:!1}}))}},D=()=>{l(r=>({editing:{...r.editing,metadata:!0}}))},$=(r,a)=>{r==="edit"&&a?l({editModalOpen:!0}):u()},B=()=>{l({editModalOpen:!1})},L=()=>{l({editModalOpen:!1}),u()},V=()=>{const r=i.expires_at&&Math.floor(Date.now()/1e3)>i.expires_at,a=i.max_redemptions&&i.times_redeemed>=i.max_redemptions;return r?{label:o("admin.promotionCode.expired"),color:"default"}:a?{label:o("admin.promotionCode.maxedOut"),color:"default"}:i.active?{label:o("admin.promotionCode.active"),color:"success"}:{label:o("admin.promotionCode.inactive"),color:"default"}},F=()=>{const r=i.max_redemptions?i.max_redemptions.toString():o("admin.promotionCode.unlimited");return`${i.times_redeemed||0}/${r}`},R=V();return e.jsxs(Ce,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(s,{children:[!i.active&&e.jsxs(z,{severity:"warning",children:[e.jsx(Y,{children:o("admin.promotionCode.inactiveTitle")}),o("admin.promotionCode.inactiveTip")]}),e.jsxs(d,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(d,{direction:"row",onClick:()=>re("/admin/products/coupons"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(G,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(c,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:o("admin.coupons")})]}),e.jsx(d,{direction:"row",spacing:2,children:e.jsx(ae,{data:i,onChange:$,variant:"normal"})})]}),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.jsx(d,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:e.jsx(c,{variant:"h2",sx:{color:"text.primary",fontFamily:"monospace",letterSpacing:1},children:i.code})}),e.jsxs(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(b,{label:o("admin.promotionCode.id"),value:e.jsx(oe,{text:t.id,style:{marginLeft:4}}),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.redemptions"),value:F(),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.status"),value:e.jsx(Q,{label:R.label,color:R.color}),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.verificationType"),value:o(`admin.promotionCode.verificationTypeMap.${i.verification_type}`),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.created"),value:N(i.created_at),divider:!0})]})]}),e.jsx(f,{})]}),e.jsxs(d,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".promotion-code-column-1":{minWidth:{xs:"100%",lg:"600px"}},".promotion-code-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(s,{className:"promotion-code-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("common.details")}),e.jsxs(te,{children:[e.jsx(p,{label:o("common.active"),value:i.active?o("admin.promotionCode.yes"):o("admin.promotionCode.no")}),i.description&&e.jsx(p,{label:o("admin.coupon.desc"),value:i.description}),e.jsx(p,{label:o("admin.promotionCode.couponId"),value:e.jsx(O,{variant:"text",color:"inherit",size:"small",sx:{color:"secondary.main"},onClick:()=>S(`/admin/products/coupons/${i.coupon_id}`),children:i.coupon_id})}),e.jsx(p,{label:o("admin.promotionCode.maxRedemptions"),value:i.max_redemptions||o("admin.promotionCode.unlimited")}),e.jsx(p,{label:o("admin.promotionCode.timesRedeemed"),value:i.times_redeemed||0}),e.jsx(p,{label:o("admin.promotionCode.expires"),value:i.expires_at?N(i.expires_at*1e3):o("admin.promotionCode.never")}),e.jsx(p,{label:o("admin.promotionCode.updated"),value:N(i.updated_at)})]})]}),e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("admin.promotionCode.verificationConfig")}),e.jsx(s,{className:"section-body",children:e.jsx(ue,{data:i})})]}),i.restrictions?.currency_options&&Object.keys(i.restrictions.currency_options).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("admin.coupon.currencies")}),e.jsx(s,{className:"section-body",children:e.jsx(ce,{currencyOptions:i.restrictions.currency_options,type:"promotion_code"})})]})]}),e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("admin.coupon.activeRedemptions")}),e.jsx(s,{className:"section-body",children:e.jsx(de,{promotionCodeId:i.id})})]}),e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("common.events")}),e.jsx(s,{className:"section-body",children:e.jsx(ie,{features:{toolbar:!1},object_id:i.id})})]})]}),M&&e.jsx(f,{}),e.jsx(s,{className:"promotion-code-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("common.metadata.label"),children:e.jsx(O,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:x.editing.metadata,onClick:D,children:o("common.edit")})}),e.jsxs(s,{className:"section-body",children:[e.jsx(se,{data:i.metadata,handleEditMetadata:D}),x.editing.metadata&&e.jsx(ne,{data:i,loading:x.loading.metadata,onSave:P,onCancel:()=>l(r=>({editing:{...r.editing,metadata:!1}}))})]})]})})]}),e.jsx(le,{open:x.editModalOpen,onClose:B,onSubmit:L,couponId:i.coupon_id,promotionCode:i,isEditing:!0,availableCurrencies:T})]})}const Ce=C(d)``;export{eo as default};
|
|
1
|
+
import{j as e,b$ as U,a3 as d,B as s,q as c,bf as C,bg as q,a7 as v,A as z,w as H,z as Y,bv as G,Y as f,x as O}from"./vendor-mui-BXZut9Pz.js";import{V as E,P as W,Y as Z,Z as A}from"./vendor-blocklet-B67R14so.js";import{e as w,d as J,a as K,n as Q,j as N,b8 as X,k as ee}from"./index-B4yaPb7B.js";import{C as oe}from"./copyable-CprMHdhV.js";import{E as ie}from"./list-CvM46TsP.js";import{I as b}from"./info-metric-ukWq8INi.js";import{I as p}from"./info-row-CaPaNF4L.js";import{I as te}from"./info-row-group-Cxo-4Gk5.js";import{M as ne}from"./editor-vZvxDUTl.js";import{M as se}from"./list-B2b-s8wM.js";import{S as g}from"./header-ivXuPt06.js";import{g as re}from"./util-B8B3fsMa.js";import{P as ae,C as ce,A as de,a as le}from"./currency-restrictions-Dsupz2ce.js";import{C as me}from"./link-DsltSF2Q.js";import{a as pe}from"./vendor-react-BPknnnEA.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./index-oy7LrXGT.js";import"./collapse-CSrlJ0eG.js";import"./drawer-form-CQjNFFWk.js";import"./currency-select-C8j7QQMP.js";import"./currency-GstdXsJf.js";import"./product-select-_72p-5lF.js";import"./form-AFzUvoFE.js";import"./info-card-C9dRgztS.js";import"./uploader-BLdAbLR6.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";import"./actions-BEUwbsq1.js";import"./link-DMWJcQvZ.js";import"./description-BHxdy5I3.js";import"./status-3Swm2gK5.js";const xe=()=>w.get("/api/customers?limit=1000").then(t=>t.data);function ue({data:t}){const{t:o}=E(),{data:M}=W(xe,{ready:t.verification_type==="user_restricted"&&(t.customer_dids?.length??0)>0}),S=M?.list||[],k=()=>t.nft_config?e.jsxs(d,{spacing:2,children:[t.nft_config.nft_addresses&&t.nft_config.nft_addresses.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.nftAddresses")}),e.jsx(_,{children:t.nft_config.nft_addresses.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"default",sx:{backgroundColor:"grey.50",borderColor:"grey.300",fontFamily:"monospace",fontSize:"0.75rem",maxWidth:200}},n))})]}),t.nft_config.nft_tags&&t.nft_config.nft_tags.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.nftTags")}),e.jsx(_,{children:t.nft_config.nft_tags.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"primary",sx:{backgroundColor:"primary.50",fontWeight:500}},n))})]}),t.nft_config.min_balance&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.minBalance")}),e.jsx(c,{variant:"body2",sx:{fontWeight:"medium"},children:t.nft_config.min_balance})]})]}):e.jsx(c,{variant:"body2",sx:{color:"text.secondary"},children:o("admin.promotionCode.noNftConfig")}),x=()=>t.vc_config?e.jsxs(d,{spacing:2,children:[t.vc_config.vc_roles&&t.vc_config.vc_roles.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.requiredRoles")}),e.jsx(_,{children:t.vc_config.vc_roles.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"secondary",sx:{backgroundColor:"secondary.50",fontWeight:500,textTransform:"capitalize"}},n))})]}),t.vc_config.vc_trusted_issuers&&t.vc_config.vc_trusted_issuers.length>0&&e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.trustedIssuers")}),e.jsx(_,{children:t.vc_config.vc_trusted_issuers.map(n=>e.jsx(v,{label:n,size:"small",variant:"outlined",color:"info",sx:{backgroundColor:"info.50",fontFamily:"monospace",fontSize:"0.75rem",maxWidth:200}},n))})]})]}):e.jsx(c,{variant:"body2",sx:{color:"text.secondary"},children:o("admin.promotionCode.noVcConfig")}),l=()=>t.customer_dids?.length?e.jsxs(j,{children:[e.jsx(h,{children:o("admin.promotionCode.allowedUsers")}),e.jsx(ge,{children:t.customer_dids.map(n=>{const i=S.find(u=>u.did===n||u.id===n);return i?e.jsx(me,{customer:i,size:"small",cardProps:{sx:{border:"none",p:0,minWidth:0}}},n):e.jsx(v,{label:n,size:"small",variant:"outlined",color:"default",sx:{maxWidth:200,backgroundColor:"grey.50",borderColor:"grey.300"}},n)})})]}):e.jsx(c,{variant:"body2",sx:{color:"text.secondary"},children:o("admin.promotionCode.noUsersSpecified")}),I=()=>{switch(t.verification_type){case"nft":return k();case"vc":return x();case"user_restricted":return l();default:return e.jsx(c,{variant:"body2",sx:{color:"text.secondary",fontStyle:"italic"},children:o("admin.promotionCode.codeVerificationOnly")})}};return e.jsx(fe,{children:e.jsx(U,{children:e.jsxs(d,{spacing:2,children:[e.jsxs(s,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:{xs:1,sm:2},alignItems:{xs:"flex-start",sm:"center"}},children:[e.jsx(c,{variant:"caption",sx:{color:"text.secondary"},children:o("admin.promotionCode.verificationType")}),e.jsx(c,{variant:"subtitle2",sx:{color:"text.primary",fontWeight:"medium"},children:o(`admin.promotionCode.verificationTypeMap.${t.verification_type}`)})]}),I()]})})})}const fe=C(q)(({theme:t})=>({border:`1px solid ${t.palette.divider}`,boxShadow:"none",backgroundColor:t.palette.background.paper})),j=C(s)({display:"flex",flexDirection:"column",gap:8}),h=C(c)(({theme:t})=>({fontSize:"0.875rem",fontWeight:500,color:t.palette.text.secondary})),_=C(s)({display:"flex",flexDirection:"row",flexWrap:"wrap",gap:8}),ge=C(s)({display:"flex",flexDirection:"row",flexWrap:"wrap",gap:8,alignItems:"center"}),je=t=>w.get(`/api/promotion-codes/${t}`).then(o=>o.data),he=t=>w.get(`/api/coupons/${t}`).then(o=>o.data);function eo(t){const{t:o}=E(),{isMobile:M}=J(),S=pe(),{settings:k}=K(),[x,l]=Z({editing:{metadata:!1},loading:{metadata:!1},editModalOpen:!1}),{loading:I,error:n,data:i,runAsync:u}=W(()=>je(t.id)),{data:m}=W(()=>i?.coupon_id?he(i.coupon_id):Promise.resolve(null),{refreshDeps:[i?.coupon_id]});if(n)return e.jsx(z,{severity:"error",children:n.message});if(I||!i)return e.jsx(H,{});const T=(()=>{const r=k.paymentMethods?.flatMap(y=>y.payment_currencies)||[];if(!m||m.percent_off)return r;const a=new Set;return m.currency_id&&a.add(m.currency_id),m.currency_options&&typeof m.currency_options=="object"&&Object.keys(m.currency_options).forEach(y=>{a.add(y)}),r.filter(y=>a.has(y.id))})(),P=async r=>{try{l(a=>({loading:{...a.loading,metadata:!0}})),await w.put(`/api/promotion-codes/${t.id}`,{metadata:r.metadata}),A.success(o("common.saved")),X("promotion-code.updated"),u()}catch(a){console.error(a),A.error(ee(a))}finally{l(a=>({loading:{...a.loading,metadata:!1}}))}},D=()=>{l(r=>({editing:{...r.editing,metadata:!0}}))},$=(r,a)=>{r==="edit"&&a?l({editModalOpen:!0}):u()},B=()=>{l({editModalOpen:!1})},L=()=>{l({editModalOpen:!1}),u()},V=()=>{const r=i.expires_at&&Math.floor(Date.now()/1e3)>i.expires_at,a=i.max_redemptions&&i.times_redeemed>=i.max_redemptions;return r?{label:o("admin.promotionCode.expired"),color:"default"}:a?{label:o("admin.promotionCode.maxedOut"),color:"default"}:i.active?{label:o("admin.promotionCode.active"),color:"success"}:{label:o("admin.promotionCode.inactive"),color:"default"}},F=()=>{const r=i.max_redemptions?i.max_redemptions.toString():o("admin.promotionCode.unlimited");return`${i.times_redeemed||0}/${r}`},R=V();return e.jsxs(Ce,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(s,{children:[!i.active&&e.jsxs(z,{severity:"warning",children:[e.jsx(Y,{children:o("admin.promotionCode.inactiveTitle")}),o("admin.promotionCode.inactiveTip")]}),e.jsxs(d,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(d,{direction:"row",onClick:()=>re("/admin/products/coupons"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(G,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(c,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:o("admin.coupons")})]}),e.jsx(d,{direction:"row",spacing:2,children:e.jsx(ae,{data:i,onChange:$,variant:"normal"})})]}),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.jsx(d,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:e.jsx(c,{variant:"h2",sx:{color:"text.primary",fontFamily:"monospace",letterSpacing:1},children:i.code})}),e.jsxs(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(b,{label:o("admin.promotionCode.id"),value:e.jsx(oe,{text:t.id,style:{marginLeft:4}}),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.redemptions"),value:F(),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.status"),value:e.jsx(Q,{label:R.label,color:R.color}),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.verificationType"),value:o(`admin.promotionCode.verificationTypeMap.${i.verification_type}`),divider:!0}),e.jsx(b,{label:o("admin.promotionCode.created"),value:N(i.created_at),divider:!0})]})]}),e.jsx(f,{})]}),e.jsxs(d,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".promotion-code-column-1":{minWidth:{xs:"100%",lg:"600px"}},".promotion-code-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(s,{className:"promotion-code-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("common.details")}),e.jsxs(te,{children:[e.jsx(p,{label:o("common.active"),value:i.active?o("admin.promotionCode.yes"):o("admin.promotionCode.no")}),i.description&&e.jsx(p,{label:o("admin.coupon.desc"),value:i.description}),e.jsx(p,{label:o("admin.promotionCode.couponId"),value:e.jsx(O,{variant:"text",color:"inherit",size:"small",sx:{color:"secondary.main"},onClick:()=>S(`/admin/products/coupons/${i.coupon_id}`),children:i.coupon_id})}),e.jsx(p,{label:o("admin.promotionCode.maxRedemptions"),value:i.max_redemptions||o("admin.promotionCode.unlimited")}),e.jsx(p,{label:o("admin.promotionCode.timesRedeemed"),value:i.times_redeemed||0}),e.jsx(p,{label:o("admin.promotionCode.expires"),value:i.expires_at?N(i.expires_at*1e3):o("admin.promotionCode.never")}),e.jsx(p,{label:o("admin.promotionCode.updated"),value:N(i.updated_at)})]})]}),e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("admin.promotionCode.verificationConfig")}),e.jsx(s,{className:"section-body",children:e.jsx(ue,{data:i})})]}),i.restrictions?.currency_options&&Object.keys(i.restrictions.currency_options).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("admin.coupon.currencies")}),e.jsx(s,{className:"section-body",children:e.jsx(ce,{currencyOptions:i.restrictions.currency_options,type:"promotion_code"})})]})]}),e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("admin.coupon.activeRedemptions")}),e.jsx(s,{className:"section-body",children:e.jsx(de,{promotionCodeId:i.id})})]}),e.jsx(f,{}),e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("common.events")}),e.jsx(s,{className:"section-body",children:e.jsx(ie,{features:{toolbar:!1},object_id:i.id})})]})]}),M&&e.jsx(f,{}),e.jsx(s,{className:"promotion-code-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(s,{className:"section",children:[e.jsx(g,{title:o("common.metadata.label"),children:e.jsx(O,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:x.editing.metadata,onClick:D,children:o("common.edit")})}),e.jsxs(s,{className:"section-body",children:[e.jsx(se,{data:i.metadata,handleEditMetadata:D}),x.editing.metadata&&e.jsx(ne,{data:i,loading:x.loading.metadata,onSave:P,onCancel:()=>l(r=>({editing:{...r.editing,metadata:!1}}))})]})]})})]}),e.jsx(le,{open:x.editModalOpen,onClose:B,onSubmit:L,couponId:i.coupon_id,promotionCode:i,isEditing:!0,availableCurrencies:T})]})}const Ce=C(d)``;export{eo as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as x,w as p,B as a,a3 as r,bv as u,q as n,O as h,bf as j}from"./vendor-mui-BXZut9Pz.js";import{V as b,P as f}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,A as x,w as p,B as a,a3 as r,bv as u,q as n,O as h,bf as j}from"./vendor-mui-BXZut9Pz.js";import{V as b,P as f}from"./vendor-blocklet-B67R14so.js";import{n as g,j as c,e as v}from"./index-B4yaPb7B.js";import{C as w}from"./copyable-CprMHdhV.js";import{I as o}from"./info-metric-ukWq8INi.js";import{S as y}from"./header-ivXuPt06.js";import{W as k}from"./attempts-BfbYfiJa.js";import{g as C,w as S}from"./util-B8B3fsMa.js";import"./vendor-react-BPknnnEA.js";import"./vendor-arcblock-D1drrE7q.js";import"./lodash-B4Ozcv0x.js";import"./info-card-C9dRgztS.js";const W=i=>v.get(`/api/webhook-endpoints/${i}`).then(s=>s.data);function F(i){const{t:s}=b(),{loading:m,error:l,data:t}=f(()=>W(i.id));return l?e.jsx(x,{severity:"error",children:l.message}):m||!t?e.jsx(p,{}):e.jsxs(_,{direction:"column",spacing:4,sx:{mb:4},children:[e.jsxs(a,{children:[e.jsxs(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(r,{direction:"row",onClick:()=>C("/admin/developers/webhooks"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(u,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(n,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("admin.webhooks")})]}),e.jsx(w,{text:i.id,style:{marginLeft:4}})]}),e.jsxs(a,{sx:{mt:2},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(r,{direction:"column",sx:{alignItems:"flex-start"},children:[e.jsx(n,{variant:"h5",children:t.url}),e.jsx(n,{variant:"body1",sx:{color:"text.secondary"},children:t.description})]})}),e.jsxs(r,{className:"section-body",direction:"row",spacing:3,sx:{justifyContent:"flex-start",flexWrap:"wrap",pt:2,mt:2,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(o,{label:s("common.status"),value:e.jsx(g,{label:t.status,color:S(t.status)}),divider:!0}),e.jsx(o,{label:s("admin.webhookEndpoint.listen"),value:e.jsx(h,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:t.enabled_events.map(d=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:d},d))}),children:e.jsxs(n,{sx:{backgroundColor:"grey.100",paddingX:.5,borderRadius:.5},children:[t.enabled_events.length," events"]})}),divider:!0}),e.jsx(o,{label:s("admin.webhookEndpoint.version"),value:t.api_version,divider:!0}),e.jsx(o,{label:s("common.createdAt"),value:c(t.created_at),divider:!0}),e.jsx(o,{label:s("common.updatedAt"),value:c(t.updated_at)})]})]})]}),e.jsxs(a,{className:"section",children:[e.jsx(y,{title:s("admin.webhookEndpoint.attempts"),mb:0}),e.jsx(a,{className:"section-body",children:e.jsx(k,{webhook_endpoint_id:t.id})})]})]})}const _=j(r)``;export{F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as L,w as R,B as s,a3 as n,bv as $,q as E,N as B,Y as r,O as W,be as z,x as O,bf as H}from"./vendor-mui-BXZut9Pz.js";import{V as q,Y as G,P as U,cw as V,a7 as Y,Z as I}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,A as L,w as R,B as s,a3 as n,bv as $,q as E,N as B,Y as r,O as W,be as z,x as O,bf as H}from"./vendor-mui-BXZut9Pz.js";import{V as q,Y as G,P as U,cw as V,a7 as Y,Z as I}from"./vendor-blocklet-B67R14so.js";import{d as F,i as w,a5 as J,n as _,o as C,j as N,p as Z,e as k,k as K}from"./index-B4yaPb7B.js";import{T as Q}from"./gas-kw2KMH1u.js";import{L as M}from"./vendor-react-BPknnnEA.js";import{l as X}from"./lodash-B4Ozcv0x.js";import{C as ee}from"./copyable-CprMHdhV.js";import{C as te}from"./link-DsltSF2Q.js";import{E as ae}from"./list-CvM46TsP.js";import{I as S}from"./info-metric-ukWq8INi.js";import{I as i}from"./info-row-CaPaNF4L.js";import{M as se}from"./editor-vZvxDUTl.js";import{M as ie}from"./list-B2b-s8wM.js";import{P as ne}from"./actions-JHsqbHpB.js";import{P as oe}from"./list-Cd1O-aDi.js";import{S as l}from"./header-ivXuPt06.js";import{g as re}from"./util-B8B3fsMa.js";import{R as le}from"./list-BzgF4i3i.js";import{I as me}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./form-CnrBCyTJ.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./cache-state-lld4zuDg.js";import"./filter-toolbar-VvmMATj0.js";import"./product-select-_72p-5lF.js";import"./info-card-C9dRgztS.js";import"./actions-DeCPtfTK.js";const ce=x=>k.get(`/api/payment-intents/${x}`).then(a=>a.data),m="column",c="flex-start";function Oe(x){const{t:a}=q(),{isMobile:f}=F(),[j,p]=G({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:D,error:y,data:t,runAsync:h}=U(()=>ce(x.id));if(y)return e.jsx(L,{severity:"error",children:y.message});if(D||!t)return e.jsx(R,{});const A=(d=>async P=>{try{p(o=>({loading:{...o.loading,[d]:!0}})),await k.put(`/api/payment-intents/${x.id}`,P).then(o=>o.data),I.success(a("common.saved")),h()}catch(o){console.error(o),I.error(K(o))}finally{p(o=>({loading:{...o.loading,[d]:!1}}))}})("metadata"),u=t.paymentCurrency,g=[w(t?.amount_received,u.decimal),u.symbol].join(" "),b=[w(t?.amount,u.decimal),u.symbol].join(" "),v=()=>{p(d=>({editing:{...d.editing,metadata:!0}}))},T=t.subscription?.status==="canceled";return e.jsxs(de,{direction:"column",spacing:2.5,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/payments/intents"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx($,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(E,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.payments")})]}),e.jsx(ne,{data:t,variant:"normal",onChange:h})]}),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.jsx(n,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(n,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(B,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(n,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(J,{amount:t?.amount_received==="0"?b:g,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(ee,{text:x.id})]})]})}),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(S,{label:a("common.status"),value:e.jsx(_,{label:t.status,color:C(t.status)}),divider:!0}),e.jsx(S,{label:a("common.customer"),value:t.metadata?.payerDid&&V(t.metadata?.payerDid)?e.jsx(Y,{did:t.metadata?.payerDid,...f?{responsive:!1,compact:!0}:{}}):e.jsx(te,{customer:t.customer}),divider:!0})]})]}),e.jsx(r,{})]}),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(l,{title:a("admin.details")}),e.jsxs(me,{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(i,{label:a("common.status"),value:e.jsxs(n,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(_,{label:t.status,color:C(t.status)}),t.last_payment_error&&e.jsx(W,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify({...t.last_payment_error,type:X.startCase(t.last_payment_error?.type)},null,2)}),children:e.jsx(z,{fontSize:"small",color:"error"})})]})}),e.jsx(i,{label:a("common.amount"),value:b}),e.jsx(i,{label:a("admin.paymentIntent.received"),value:g}),e.jsx(i,{label:a("common.createdAt"),value:N(t.created_at)}),e.jsx(i,{label:a("common.description"),value:t.description}),e.jsx(i,{label:a("common.updatedAt"),value:N(t.updated_at)}),e.jsx(i,{label:a("common.statementDescriptor"),value:t.statement_descriptor})]})]}),e.jsx(r,{}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.payouts")}),e.jsx(s,{className:"section-body",children:e.jsx(oe,{features:{toolbar:!1},payment_intent_id:t?.id,isCanceledSubscription:T})})]}),e.jsx(r,{}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.refunds")}),e.jsx(s,{className:"section-body",children:e.jsx(le,{features:{customer:!1,toolbar:!1},payment_intent_id:t?.id})})]}),e.jsx(r,{}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.events.title")}),e.jsx(s,{className:"section-body",children:e.jsx(ae,{features:{toolbar:!1},object_id:t.id})})]})]}),f&&e.jsx(r,{}),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(l,{title:a("admin.paymentMethod._name")}),e.jsxs(n,{children:[e.jsx(i,{label:a("common.id"),value:t.paymentMethod?.id,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentMethod.type"),value:t.paymentMethod?.type,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod?.name})`,direction:m,alignItems:c}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(i,{label:a("common.txGas"),value:e.jsx(Q,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c}),e.jsx(i,{label:a(`common.${t.payment_details?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(Z,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c})]})]}),e.jsx(r,{}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("admin.connections")}),e.jsxs(n,{children:[t.subscription&&e.jsx(i,{label:a("admin.subscription.name"),value:e.jsx(M,{to:`/admin/billing/${t.subscription.id}`,children:t.subscription.id}),direction:m,alignItems:c}),t.invoice_id&&e.jsx(i,{label:a("admin.invoice.name"),value:e.jsx(M,{to:`/admin/billing/${t.invoice_id}`,children:t.invoice_id}),direction:m,alignItems:c})]})]}),e.jsx(r,{}),e.jsxs(s,{className:"section",children:[e.jsx(l,{title:a("common.metadata.label"),children:e.jsx(O,{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:A,onCancel:()=>p(d=>({editing:{...d.editing,metadata:!1}}))})]})]})]})]})]})}const de=H(n)``;export{Oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as M,w as W,$ as p,a3 as n,bv as _,q as f,B as i,Y as d,x as $,bf as A}from"./vendor-mui-BXZut9Pz.js";import{V as L,Y as B,P as E,F as w,Z as y}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,A as M,w as W,$ as p,a3 as n,bv as _,q as f,B as i,Y as d,x as $,bf as A}from"./vendor-mui-BXZut9Pz.js";import{V as L,Y as B,P as E,F as w,Z as y}from"./vendor-blocklet-B67R14so.js";import{a as R,T as U,j as v,e as I,k as z}from"./index-B4yaPb7B.js";import{a as O,L as q}from"./vendor-react-BPknnnEA.js";import{C as k}from"./copyable-CprMHdhV.js";import{E as F}from"./list-CvM46TsP.js";import{I as G}from"./info-card-C9dRgztS.js";import{I as C}from"./info-row-CaPaNF4L.js";import{M as H}from"./editor-vZvxDUTl.js";import{M as Y}from"./list-B2b-s8wM.js";import{P as V}from"./actions--FNKSNIs.js";import{P as Z}from"./preview-F3lma170.js";import{S as l}from"./header-ivXuPt06.js";import{g as J,n as K}from"./util-B8B3fsMa.js";import{I as Q}from"./info-metric-ukWq8INi.js";import{I as X}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./assign-DKRfmN7W.js";import"./chrome-BPS46pXA.js";const ee=o=>I.get(`/api/pricing-tables/${o}`).then(t=>t.data);function Ne(o){const{t,locale:u}=L(),N=O(),{settings:P}=R(),[m,c]=B({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:T,error:g,data:a,runAsync:j}=E(()=>ee(o.id));if(g)return e.jsx(M,{severity:"error",children:g.message});if(T||!a)return e.jsx(W,{});const D=(r=>async x=>{try{c(s=>({loading:{...s.loading,[r]:!0}})),await I.put(`/api/pricing-tables/${o.id}`,x).then(s=>s.data),y.success(t("common.saved")),j()}catch(s){console.error(s),y.error(z(s))}finally{c(s=>({loading:{...s.loading,[r]:!1}}))}})("metadata"),S=r=>{r==="remove"?N("/admin/products/pricing-tables"):j()},h=()=>{c(r=>({editing:{...r.editing,metadata:!0}}))};return e.jsxs(p,{container:!0,spacing:4,sx:{mb:4},children:[e.jsxs(p,{size:12,children:[e.jsxs(n,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n,{direction:"row",onClick:()=>J("/admin/products/pricing-tables"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(_,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(f,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.pricingTables")})]}),e.jsx(V,{data:a,onChange:S,variant:"normal"})]}),e.jsxs(i,{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(n,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",gap:5},children:e.jsxs(n,{direction:"column",sx:{alignItems:"flex-start"},children:[e.jsx(f,{variant:"h1",children:a.name}),e.jsx(k,{text:w(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pricing-table/${a.id}`),children:e.jsx(f,{variant:"h6",sx:{color:"text.secondary",mr:1,maxWidth:{xs:300,md:"100%"},textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:w(window.blocklet.prefix,`/checkout/pricing-table/${a.id}`)})})]})}),e.jsx(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(Q,{label:t("common.id"),value:e.jsx(k,{text:o.id,style:{marginLeft:4}}),divider:!0})})]}),e.jsx(d,{})]}),e.jsx(p,{size:12,children:e.jsxs(n,{sx:{flexDirection:{xs:"column",lg:"row"},gap: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(i,{className:"payment-link-column-1",sx:{flex:1},children:e.jsxs(te,{direction:"column",spacing:3,children:[e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.products")}),e.jsx(i,{className:"section-body",children:e.jsx(U,{className:"link-products-table",toolbar:!1,footer:!1,locale:u,data:a.items,columns:[{label:t("common.title"),name:"product_id",options:{sort:!1,customBodyRenderLite:(r,x)=>{const s=a.items[x],b=a?.currency||P.baseCurrency;return e.jsx(q,{to:`/admin/products/${s.product_id}?currency_id=${b?.id}&price_id=${s.price.id}`,children:e.jsx(G,{name:s.product.name,description:K({...s.product,prices:[s.price]},b,u),logo:s.product.images[0]})})}}}],options:{count:a.items.length,page:0,rowsPerPage:20},emptyNodeText:t("empty.products")})})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.details")}),e.jsxs(X,{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:t("common.createdAt"),value:v(a.created_at)}),e.jsx(C,{label:t("common.updatedAt"),value:v(a.updated_at)})]})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("common.preview")}),e.jsx(i,{className:"section-body",sx:{maxWidth:1050},children:e.jsx(Z,{id:a.id})})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.events.title")}),e.jsx(i,{className:"section-body",children:e.jsx(F,{features:{toolbar:!1},object_id:a.id})})]})]})}),e.jsx(i,{className:"payment-link-column-2",children:e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("common.metadata.label"),children:e.jsx($,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:m.editing.metadata,onClick:h,children:t("common.edit")})}),e.jsxs(i,{className:"section-body",children:[e.jsx(Y,{data:a.metadata,handleEditMetadata:h}),m.editing.metadata&&e.jsx(H,{data:a,loading:m.loading.metadata,onSave:D,onCancel:()=>c(r=>({editing:{...r.editing,metadata:!1}}))})]})]})})]})})]})}const te=A(n)``;export{Ne as default};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{j as e,r as D,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-B67R14so.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 me,v as de,l as pe,w as ue}from"./index-B4yaPb7B.js";import{T as xe}from"./gas-kw2KMH1u.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-DsltSF2Q.js";import{I as h}from"./info-row-CaPaNF4L.js";import{D as je,R as ve,I as _e}from"./related-credit-grants-DnKdAit6.js";import{g as we}from"./util-B8B3fsMa.js";import{i as Ce}from"./did-Bqcz-NjH.js";import{I}from"./info-metric-ukWq8INi.js";import{I as ke}from"./info-row-group-Cxo-4Gk5.js";import{u as Ie}from"./browser-DF2vfpBa.js";import"./browser-Bb9g-cvG.js";import"./usage-records-BAwNs1y8.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./generateCategoricalChart-BCpuUeC_.js";const Se=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,Re=D.memo(({invoice_id:s})=>{const o="invoice-table",{t:a,locale:r}=$(),[d,y]=D.useState({pageSize:R,page:1}),{loading:f,data:p={list:[],count:0}}=F(()=>U({...d,invoice_id:s}),{refreshDeps:[d]}),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")}}}],m=({page:n,rowsPerPage:i})=>{d.pageSize!==i?y(t=>({...t,pageSize:i,page:1})):d.page!==n+1&&y(t=>({...t,page:n+1}))};return e.jsx(De,{children:e.jsx(ae,{hasRowLink:!0,durable:`__${o}__`,durableKeys:["page","rowsPerPage","searchText"],data:p.list,columns:u,options:{count:p.count,page:d.page-1,rowsPerPage:d.pageSize},loading:f,onChange:m,toolbar:!1,sx:{mt:2},showMobile:!1,locale:r,mobileTDFlexDirection:"row",emptyNodeText:a("payment.customer.refund.emptyList")})})}),De=H(c)`
|
|
2
|
+
@media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
|
|
3
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root {
|
|
4
|
+
> div {
|
|
5
|
+
width: fit-content;
|
|
6
|
+
flex: inherit;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
.invoice-summary {
|
|
11
|
+
padding-right: 20px;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`,Te=D.memo(({invoice_id:s})=>{const{t:o}=$(),{data:a,loadMore:r,loadingMore:d,loading:y}=ee(u=>{const m=u?Math.ceil(u.list.length/R)+1:1;return U({page:m,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=Se(a.list);return e.jsxs(x,{direction:"column",sx:{gap:1,mt:1},children:[Object.entries(p).map(([u,m])=>e.jsxs(c,{children:[e.jsx(l,{sx:{fontWeight:"bold",color:"text.secondary",mt:2,mb:1},children:u}),m.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:d,children:d?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 Me({type:s="list",...o}){return s==="table"?e.jsx(Re,{...o}):e.jsx(Te,{...o})}const Le=s=>K.get(`/api/invoices/${s}`).then(o=>o.data);function et(){const{t:s,locale:o}=$(),[a]=he(),{isMobile:r}=oe(),{connect:d}=ie(),y=ye(),f=Q(),p=Ie(),[u,m]=te({downloading:!1,paying:!1}),{loading:n,error:i,data:t,runAsync:v}=F(()=>Le(y.id)),g=a.get("action"),{session:C}=re(),T=t?.checkoutSession?.submit_type==="donate",z=()=>{m({paying:!0}),d.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()=>{d.close(),m({paying:!1}),await v()},onClose:()=>{d.close(),m({paying:!1})},onError:_=>{m({paying:!1}),N.error(W(_))}})},Y=()=>{m({paying:!0}),d.close()};if(D.useEffect(()=>{i?.response?.status===403?Y():["pay","renew"].includes(g)&&["open","uncollectible"].includes(t?.status)&&z()},[i]),t?.customer?.did&&C?.user?.did&&!Ce(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)&&!T&&!j.isEmpty(t.lines);return e.jsxs(Be,{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(),m({paying:!1}),await v()},onError:()=>{m({paying:!1})},onClose:()=>{m({paying:!1})},children:(_,J)=>e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying||J,onClick:()=>{m({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(ke,{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:me(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:`${de(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})})]})]}),T&&!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&&!T&&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(Me,{invoice_id:t.id,type:"table"})})]})]})]})}const Be=H(x)`
|
|
15
|
+
.invoice-summary-wrapper {
|
|
16
|
+
display: 'grid';
|
|
17
|
+
grid-template-columns: '50% 50%';
|
|
18
|
+
}
|
|
19
|
+
@media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
|
|
20
|
+
.section-header {
|
|
21
|
+
font-size: 18px;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;export{et 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,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
|
+
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-B67R14so.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-B4yaPb7B.js";import{C as ne}from"./copyable-CprMHdhV.js";import{E as be}from"./list-CvM46TsP.js";import{I as A}from"./info-metric-ukWq8INi.js";import{I as w}from"./info-row-CaPaNF4L.js";import{I as Ce}from"./info-row-group-Cxo-4Gk5.js";import{M as ve}from"./editor-vZvxDUTl.js";import{M as _e}from"./list-B2b-s8wM.js";import{S as M}from"./header-ivXuPt06.js";import{g as we}from"./util-B8B3fsMa.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-Dsupz2ce.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./index-oy7LrXGT.js";import"./collapse-CSrlJ0eG.js";import"./drawer-form-CQjNFFWk.js";import"./currency-select-C8j7QQMP.js";import"./currency-GstdXsJf.js";import"./product-select-_72p-5lF.js";import"./form-AFzUvoFE.js";import"./info-card-C9dRgztS.js";import"./uploader-BLdAbLR6.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";import"./actions-BEUwbsq1.js";import"./link-DMWJcQvZ.js";import"./link-DsltSF2Q.js";import"./description-BHxdy5I3.js";import"./status-3Swm2gK5.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{j as e,A as E,w as O,B as r,a3 as o,bv as R,q as w,N as W,Y as x,O as H,be as U,x as q,bf as G}from"./vendor-mui-BXZut9Pz.js";import{V,Y,P as F,cw as J,a7 as C,Z as k}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,A as E,w as O,B as r,a3 as o,bv as R,q as w,N as W,Y as x,O as H,be as U,x as q,bf as G}from"./vendor-mui-BXZut9Pz.js";import{V,Y,P as F,cw as J,a7 as C,Z as k}from"./vendor-blocklet-B67R14so.js";import{d as Z,i as K,a5 as Q,n as _,a6 as M,a7 as X,N as ee,j as S,p as te,e as A,k as ae}from"./index-B4yaPb7B.js";import{T as se}from"./gas-kw2KMH1u.js";import{L as ne}from"./vendor-react-BPknnnEA.js";import{C as ie}from"./copyable-CprMHdhV.js";import{C as oe}from"./link-DsltSF2Q.js";import{E as re}from"./list-CvM46TsP.js";import{I as N}from"./info-metric-ukWq8INi.js";import{I as i}from"./info-row-CaPaNF4L.js";import{M as le}from"./editor-vZvxDUTl.js";import{M as me}from"./list-B2b-s8wM.js";import{S as p}from"./header-ivXuPt06.js";import{g as ce,l as de}from"./util-B8B3fsMa.js";import{I as D}from"./info-card-C9dRgztS.js";import{I as xe}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";const pe=d=>A.get(`/api/payouts/${d}`).then(a=>a.data),m="column",c="flex-start";function Le(d){const{t:a,locale:T}=V(),{isMobile:j}=Z(),[f,u]=Y({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:$,error:y,data:t,runAsync:z}=F(()=>pe(d.id));if(y)return e.jsx(E,{severity:"error",children:y.message});if($||!t)return e.jsx(O,{});const L=(n=>async B=>{try{u(l=>({loading:{...l.loading,[n]:!0}})),await A.put(`/api/payouts/${d.id}`,B).then(l=>l.data),k.success(a("common.saved")),z()}catch(l){console.error(l),k.error(ae(l))}finally{u(l=>({loading:{...l.loading,[n]:!1}}))}})("metadata"),g=t.paymentCurrency,h=[K(t?.amount,g.decimal),g.symbol].join(" "),b=()=>{u(n=>({editing:{...n.editing,metadata:!0}}))},{paymentIntent:s}=t||{},P=()=>{if(t.customer)return e.jsx(oe,{customer:t.customer});const n=de(t.destination);return n?e.jsx(D,{name:n.name,description:e.jsx(C,{did:t.destination}),logo:n.avatar,size:40}):t.destination},I=s?.customer?.metadata?.anonymous,v=s?.customer?.did||s?.metadata?.payerDid||"";return e.jsxs(ue,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(r,{children:[e.jsx(o,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(o,{direction:"row",onClick:()=>ce("/admin/payments/payouts"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(R,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(w,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.payouts")})]})}),e.jsxs(r,{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(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(o,{direction:"row",sx:{alignItems:"center"},children:e.jsxs(o,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(W,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(o,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(Q,{amount:h,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(ie,{text:d.id})]})]})})}),e.jsxs(o,{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(N,{label:a("common.status"),value:e.jsx(_,{label:t.status,color:M(t.status)}),divider:!0}),s?.id&&e.jsx(N,{label:a("customer.payout.payer"),value:e.jsx(D,{variant:"circular",logo:ee(s?.customer?.did,s?.customer?.updated_at?new Date(s?.customer?.updated_at).toISOString():"",48),logoName:s?.customer?.metadata?.anonymous?"":s?.customer?.name,name:e.jsxs(w,{variant:"subtitle2",sx:{...I?{}:{cursor:"pointer","&:hover":{color:"text.link"}}},onClick:()=>{if(I)return;const n=X(s?.customer?.did,T);window.open(n,"_blank")},children:[s?.customer?.name,s?.customer?.email?` (${s?.customer?.email})`:""]}),description:J(v)&&e.jsx(C,{did:v,...j?{responsive:!1,compact:!0}:{}}),size:40}),divider:!0})]})]}),e.jsx(x,{})]}),e.jsxs(o,{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(r,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(p,{title:a("admin.details")}),e.jsxs(xe,{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(i,{label:a("common.status"),value:e.jsxs(o,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(_,{label:t.status,color:M(t.status)}),t.last_attempt_error&&e.jsx(H,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify(t.last_attempt_error,null,2)}),children:e.jsx(U,{fontSize:"small",color:"error"})})]})}),e.jsx(i,{label:a("common.amount"),value:h}),e.jsx(i,{label:a("common.customer"),value:P()}),e.jsx(i,{label:a("common.createdAt"),value:S(t.created_at)}),e.jsx(i,{label:a("common.description"),value:t.description}),e.jsx(i,{label:a("common.updatedAt"),value:S(t.updated_at)})]})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.events.title")}),e.jsx(r,{className:"section-body",children:e.jsx(re,{features:{toolbar:!1},object_id:t.id})})]})]}),j&&e.jsx(x,{}),e.jsxs(r,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.paymentMethod._name")}),e.jsxs(o,{children:[e.jsx(i,{label:a("common.id"),value:t.paymentMethod?.id,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentMethod.type"),value:t.paymentMethod?.type,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod?.name})`,direction:m,alignItems:c}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(i,{label:a("common.txGas"),value:e.jsx(se,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c}),e.jsx(i,{label:a(`common.${t.payment_details?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(te,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c})]})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.connections")}),e.jsx(o,{children:t.payment_intent_id?e.jsx(i,{label:a("admin.paymentIntent.name"),value:e.jsx(ne,{to:`/admin/payments/${t.paymentIntent.id}`,children:t.paymentIntent.id}),direction:m,alignItems:c}):a("common.none")})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("common.metadata.label"),children:e.jsx(q,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:f.editing.metadata,onClick:b,children:a("common.edit")})}),e.jsxs(r,{className:"section-body",children:[e.jsx(me,{data:t.metadata,handleEditMetadata:b}),f.editing.metadata&&e.jsx(le,{data:t,loading:f.loading.metadata,onSave:L,onCancel:()=>u(n=>({editing:{...n.editing,metadata:!1}}))})]})]})]})]})]})}const ue=G(o)``;export{Le as default};
|