FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
Edit File: p-d5a837be.entry.js
import{r as t,h as e,a as s}from"./p-e97fde0a.js";import{o as i}from"./p-b719a497.js";import{a}from"./p-dd3464cd.js";import{a as r}from"./p-401e165e.js";import"./p-d3366af3.js";const n=":host{display:block}.license__name{font-weight:var(--sc-font-weight-semibold)}.license__details{display:grid;gap:0.25em;color:var(--sc-input-label-color)}";const o=n;const c=class{constructor(e){t(this,e);this.query={page:1,per_page:10};this.heading=wp.i18n.__("Licenses","surecart");this.isCustomer=undefined;this.allLink=undefined;this.licenses=[];this.copied=false;this.loading=false;this.error="";this.pagination={total:0,total_pages:0}}componentWillLoad(){i(this.el,(()=>{this.initialFetch()}))}nextPage(){this.query.page=this.query.page+1;this.initialFetch()}prevPage(){this.query.page=this.query.page-1;this.initialFetch()}async initialFetch(){try{this.loading=true;await this.getLicenses()}catch(t){console.error(t);this.error=(t===null||t===void 0?void 0:t.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}async getLicenses(){if(!this.isCustomer){return}const t=await await a({path:r("surecart/v1/licenses",{expand:["purchase","purchase.product","activations"],...this.query}),parse:false});this.pagination={total:parseInt(t.headers.get("X-WP-Total")),total_pages:parseInt(t.headers.get("X-WP-TotalPages"))};this.licenses=await t.json();return this.licenses}renderStatus(t){if(t==="active"){return e("sc-tag",{type:"success"},wp.i18n.__("Active","surecart"))}if(t==="revoked"){return e("sc-tag",{type:"danger"},wp.i18n.__("Revoked","surecart"))}if(t==="inactive"){return e("sc-tag",{type:"info"},wp.i18n.__("Not Activated","surecart"))}return e("sc-tag",{type:"info"},t)}async copyKey(t){try{await navigator.clipboard.writeText(t);this.copied=true;setTimeout((()=>{this.copied=false}),2e3)}catch(t){console.error(t);alert(wp.i18n.__("Error copying to clipboard","surecart"))}}renderLoading(){return e("sc-card",{"no-padding":true,style:{"--overflow":"hidden"}},e("sc-stacked-list",null,e("sc-stacked-list-row",{style:{"--columns":"2"},"mobile-size":0},e("div",{style:{padding:"0.5em"}},e("sc-skeleton",{style:{width:"30%",marginBottom:"0.75em"}}),e("sc-skeleton",{style:{width:"20%",marginBottom:"0.75em"}}),e("sc-skeleton",{style:{width:"40%"}})))))}renderEmpty(){return e("div",null,e("sc-divider",{style:{"--spacing":"0"}}),e("slot",{name:"empty"},e("sc-empty",{icon:"file-text"},wp.i18n.__("You don't have any licenses.","surecart"))))}renderContent(){var t,s;if(this.loading){return this.renderLoading()}if(((t=this.licenses)===null||t===void 0?void 0:t.length)===0){return this.renderEmpty()}return e("sc-card",{"no-padding":true},e("sc-stacked-list",null,(s=this.licenses)===null||s===void 0?void 0:s.map((({id:t,purchase:s,status:i,activation_limit:a,activation_count:n})=>{var o;return e("sc-stacked-list-row",{key:t,href:r(window.location.href,{action:"show",model:"license",id:t}),"mobile-size":0},e("div",{class:"license__details"},e("div",{class:"license__name"},(o=s===null||s===void 0?void 0:s.product)===null||o===void 0?void 0:o.name),e("div",null,this.renderStatus(i)," ",wp.i18n.sprintf(wp.i18n.__("%1s of %2s Activations Used"),n||0,a||"∞"))),e("sc-icon",{name:"chevron-right",slot:"suffix"}))}))))}render(){var t,s;return e("sc-dashboard-module",{key:"34ee7df77370131e228af4bb0bef147c0222a5a2",class:"purchase",part:"base",error:this.error},e("span",{key:"6faa343acdb336ab94351f9372c5ed79b2b6bdbf",slot:"heading"},e("slot",{key:"e4a96afd6e194275a68d7c0eb07fe9bb4b2be5e7",name:"heading"},this.heading||wp.i18n.__("License Keys","surecart"))),!!this.allLink&&!!((t=this.licenses)===null||t===void 0?void 0:t.length)&&e("sc-button",{key:"a47686b70d445bb5363b8ddfb2d9ae8d3ce0dfdb",type:"link",href:this.allLink,slot:"end"},wp.i18n.__("View all","surecart"),e("sc-icon",{key:"d432bfd067f17d264ad83f86126cbec19cfd70fc",name:"chevron-right",slot:"suffix"})),this.renderContent(),!this.allLink&&e("sc-pagination",{key:"2fcd069e1d2b1fa826c8e5f8d98e0c8538e35d83",page:this.query.page,perPage:this.query.per_page,total:this.pagination.total,totalPages:this.pagination.total_pages,totalShowing:(s=this===null||this===void 0?void 0:this.licenses)===null||s===void 0?void 0:s.length,onScNextPage:()=>this.nextPage(),onScPrevPage:()=>this.prevPage()}))}get el(){return s(this)}};c.style=o;export{c as sc_licenses_list}; //# sourceMappingURL=p-d5a837be.entry.js.map
Save
Back