D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafdxji
/
shihty.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
/
Filename :
p-65bb746a.entry.js
back
Copy
import{r as t,h as e,a as i}from"./p-e97fde0a.js";import{a as s}from"./p-dd3464cd.js";import{o as a}from"./p-b719a497.js";import{a as o}from"./p-401e165e.js";import"./p-d3366af3.js";const n=":host{display:block}.orders-list{display:grid;gap:0.75em}.orders-list__heading{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between}.orders-list__title{font-size:var(--sc-font-size-x-large);font-weight:var(--sc-font-weight-bold);line-height:var(--sc-line-height-dense)}.orders-list a{text-decoration:none;font-weight:var(--sc-font-weight-semibold);display:inline-flex;align-items:center;gap:0.25em;color:var(--sc-color-primary-500)}.order__row{color:var(--sc-color-gray-800);text-decoration:none;display:grid;align-items:center;justify-content:space-between;gap:0;grid-template-columns:1fr 1fr 1fr auto;margin:0;padding:var(--sc-spacing-small) var(--sc-spacing-large)}.order__row:not(:last-child){border-bottom:1px solid var(--sc-color-gray-200)}.order__row:hover{background:var(--sc-color-gray-50)}.order__date{font-weight:var(--sc-font-weight-semibold)}";const r=n;const d=class{constructor(e){t(this,e);this.query={page:1,per_page:10};this.allLink=undefined;this.heading=undefined;this.isCustomer=undefined;this.invoices=[];this.loading=undefined;this.busy=undefined;this.error=undefined;this.pagination={total:0,total_pages:0}}componentWillLoad(){a(this.el,(()=>{this.initialFetch()}))}async initialFetch(){try{this.loading=true;await this.getInvoices()}catch(t){console.error(this.error);this.error=(t===null||t===void 0?void 0:t.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}async fetchInvoices(){try{this.busy=true;await this.getInvoices()}catch(t){console.error(this.error);this.error=(t===null||t===void 0?void 0:t.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.busy=false}}async getInvoices(){if(!this.isCustomer){return}const t=await await s({path:o(`surecart/v1/invoices/`,{expand:["checkout"],...this.query}),parse:false});this.pagination={total:parseInt(t.headers.get("X-WP-Total")),total_pages:parseInt(t.headers.get("X-WP-TotalPages"))};this.invoices=await t.json();return this.invoices}nextPage(){this.query.page=this.query.page+1;this.fetchInvoices()}prevPage(){this.query.page=this.query.page-1;this.fetchInvoices()}renderLoading(){return e("sc-card",{noPadding:true},e("sc-stacked-list",null,e("sc-stacked-list-row",{style:{"--columns":"4"},"mobile-size":500},[...Array(4)].map((()=>e("sc-skeleton",{style:{width:"100px",display:"inline-block"}}))))))}renderEmpty(){return e("div",null,e("sc-divider",{style:{"--spacing":"0"}}),e("slot",{name:"empty"},e("sc-empty",{icon:"shopping-bag"},wp.i18n.__("You don't have any invoices.","surecart"))))}getInvoiceRedirectUrl(t){var e,i,s;if(t.status==="open"){return`${window.scData.pages.checkout}?checkout_id=${(e=t===null||t===void 0?void 0:t.checkout)===null||e===void 0?void 0:e.id}`}return o(window.location.href,{action:"show",model:"order",id:(s=(i=t===null||t===void 0?void 0:t.checkout)===null||i===void 0?void 0:i.order)===null||s===void 0?void 0:s.id})}renderList(){return this.invoices.map((t=>{const{checkout:i,due_date_date:s}=t;if(!i)return null;const{amount_due_display_amount:a}=i;return e("sc-stacked-list-row",{href:this.getInvoiceRedirectUrl(t),style:{"--columns":"4"},"mobile-size":500},e("div",null,"#",t===null||t===void 0?void 0:t.order_number),e("div",null,s&&(t===null||t===void 0?void 0:t.status)==="open"?wp.i18n.sprintf(wp.i18n.__("Due %s","surecart"),s):"—"),e("div",{class:"invoices-list__status"},e("sc-invoice-status-badge",{status:t===null||t===void 0?void 0:t.status})),e("div",null,a))}))}renderContent(){var t;if(this.loading){return this.renderLoading()}if(((t=this.invoices)===null||t===void 0?void 0:t.length)===0){return this.renderEmpty()}return e("sc-card",{"no-padding":true},e("sc-stacked-list",null,this.renderList()))}render(){var t,i;return e("sc-dashboard-module",{key:"798ce604d127fd18b0404df9cf84b8438fb55f7d",class:"invoices-list",error:this.error},e("span",{key:"bcf991cc7fef319bbf151e54bf6c3ede9fa8c5d0",slot:"heading"},e("slot",{key:"2322dda77fb0430a7350a7f9ea27974e5504ec29",name:"heading"},this.heading||wp.i18n.__("Invoices","surecart"))),!!this.allLink&&!!((t=this.invoices)===null||t===void 0?void 0:t.length)&&e("sc-button",{key:"bc64d73c93193c042db4d2caa6fdf2a993919a9b",type:"link",href:this.allLink,slot:"end","aria-label":wp.i18n.sprintf(wp.i18n.__("View all %s","surecart"),this.heading||wp.i18n.__("Invoices","surecart"))},wp.i18n.__("View all","surecart"),e("sc-icon",{key:"cb42cb21b25e868c7374956f0d28d9966df97fd1","aria-hidden":"true",name:"chevron-right",slot:"suffix"})),this.renderContent(),!this.allLink&&e("sc-pagination",{key:"ae3775a273bf76ea73bf002ffad9d8b8902fea0a",page:this.query.page,perPage:this.query.per_page,total:this.pagination.total,totalPages:this.pagination.total_pages,totalShowing:(i=this===null||this===void 0?void 0:this.invoices)===null||i===void 0?void 0:i.length,onScNextPage:()=>this.nextPage(),onScPrevPage:()=>this.prevPage()}),this.busy&&e("sc-block-ui",{key:"733716e7cf095f7412ed6f5710d70476d948b2d1"}))}get el(){return i(this)}};d.style=r;export{d as sc_invoices_list}; //# sourceMappingURL=p-65bb746a.entry.js.map