Build 533169stable
Module 263758
2,908 characters · in ba7b9b34b6ee39a7.jsDependencies
Source Raw
function(e,t,n){n.d(t,{A:()=>A});var a=n(627968),i=n(64700),s=n(503698),l=n.n(s),r=n(311907),o=n(562465),d=n(397927),c=n(803306),u=n(323082),m=n(272207),h=n(287809),x=n(166403),p=n(556499),g=n(652215),f=n(788868),v=n(214868),_=n(505206);let b=async()=>(await o.Bo.get({url:g.Rsh.BILLING_SUBSCRIPTIONS,query:{include_inactive:!0,limit:5},rejectWithError:!1})).body.map(e=>m.A.createFromServer(e)),j=[{id:"nitro-monthly",label:"Nitro Monthly",value:f.gD.PREMIUM_MONTH_TIER_2},{id:"nitro-yearly",label:"Nitro Yearly",value:f.gD.PREMIUM_YEAR_TIER_2},{id:"nitro-classic-monthly",label:"Nitro Classic Monthly",value:f.gD.PREMIUM_MONTH_TIER_1},{id:"nitro-classic-yearly",label:"Nitro Classic Yearly",value:f.gD.PREMIUM_YEAR_TIER_1},{id:"basic-monthly",label:"Basic Monthly",value:f.gD.PREMIUM_MONTH_TIER_0},{id:"basic-yearly",label:"Basic Yearly",value:f.gD.PREMIUM_YEAR_TIER_0},{id:"reverse-trial-1week",label:"Reverse Trial 1-week",value:f.gd},{id:"reverse-trial-2week",label:"Reverse Trial 2-week",value:f.Uk},{id:"nitro-squad-monthly",label:"Nitro Squad Monthly",value:f.gD.PREMIUM_GROUP_MONTH}];function A(){let e=(0,r.bG)([x.A],()=>x.A.getPremiumTypeSubscription()),t=(0,r.bG)([h.default],()=>h.default.getCurrentUser()),[n,s]=i.useState("511651880837840896"),[m,f]=i.useState([]),[A,C]=i.useState(!1),y=i.useCallback(async()=>{try{C(!0),await (0,u.hP)(),await (0,c.eO)(t.id),f(await b())}finally{C(!1)}},[t]);i.useEffect(()=>{y()},[y]);let S=i.useMemo(()=>m.filter(e=>e.status!==g.Dmq.ACTIVE).sort((e,t)=>e.id>t.id?-1:1),[m]),E=async()=>{await o.Bo.post({url:"/debug/subscription",body:{plan_id:n},rejectWithError:!1}),await y()},T=async()=>{await o.Bo.del({url:"/debug/subscription",rejectWithError:!1}),await y()};return(0,a.jsx)(d.IpV,{className:_.nd,children:(0,a.jsxs)("div",{className:v.l$,children:[(0,a.jsxs)("div",{className:v.dL,children:[(0,a.jsx)(d.Heading,{variant:"heading-lg/semibold",className:_.wx,children:null!=e?"Active Subscription":"Subscription Type"}),(0,a.jsx)(d.K0,{"aria-label":"Refresh",icon:d.fNY,size:"sm",variant:"icon-only",disabled:A,onClick:y})]}),(0,a.jsx)("section",{className:l()([v.uW,v.Uo]),children:null==e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.l6P,{label:"Premium Plan",hideLabel:!0,value:n,options:j,onSelectionChange:s,selectionMode:"single",fullWidth:!0}),(0,a.jsx)(d.Button,{variant:"primary",size:"sm",text:"Create Subscription",onClick:E})]})}),null!=e&&(0,a.jsx)(p.A,{subscription:e,onUpdated:y}),(0,a.jsx)(d.Heading,{variant:"heading-lg/semibold",className:_.wx,children:"Bulk Actions"}),(0,a.jsx)("section",{className:l()([v.uW,v.Uo]),children:(0,a.jsx)(d.Button,{variant:"primary",size:"sm",text:"End All Subscriptions",onClick:T})}),S.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Heading,{variant:"heading-lg/semibold",className:_.wx,children:"Previous Subscriptions"}),S.map(e=>(0,a.jsx)(p.A,{subscription:e,onUpdated:y},e.id))]})]})})}}