FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-subscription-next-payment2.js
import{proxyCustomElement,HTMLElement,h,Host,Fragment}from"@stencil/core/internal/client";import{a as apiFetch}from"./fetch.js";import{f as formatTaxDisplay}from"./tax.js";import{d as defineCustomElement$p}from"./sc-button2.js";import{d as defineCustomElement$o}from"./sc-card2.js";import{d as defineCustomElement$n}from"./sc-cc-logo2.js";import{d as defineCustomElement$m}from"./sc-dialog2.js";import{d as defineCustomElement$l}from"./sc-divider2.js";import{d as defineCustomElement$k}from"./sc-flex2.js";import{d as defineCustomElement$j}from"./sc-format-number2.js";import{d as defineCustomElement$i}from"./sc-icon2.js";import{d as defineCustomElement$h}from"./sc-line-item2.js";import{d as defineCustomElement$g}from"./sc-manual-payment-method2.js";import{d as defineCustomElement$f}from"./sc-payment-method2.js";import{d as defineCustomElement$e}from"./sc-product-line-item2.js";import{d as defineCustomElement$d}from"./sc-product-line-item-note2.js";import{d as defineCustomElement$c}from"./sc-prose2.js";import{d as defineCustomElement$b}from"./sc-quantity-select2.js";import{d as defineCustomElement$a}from"./sc-skeleton2.js";import{d as defineCustomElement$9}from"./sc-spinner2.js";import{d as defineCustomElement$8}from"./sc-stacked-list2.js";import{d as defineCustomElement$7}from"./sc-stacked-list-row2.js";import{d as defineCustomElement$6}from"./sc-subscription-details2.js";import{d as defineCustomElement$5}from"./sc-subscription-status-badge2.js";import{d as defineCustomElement$4}from"./sc-tag2.js";import{d as defineCustomElement$3}from"./sc-text2.js";import{d as defineCustomElement$2}from"./sc-toggle2.js";import{d as defineCustomElement$1}from"./sc-tooltip2.js";import{a as addQueryArgs}from"./add-query-args.js";const ScSubscriptionNextPayment=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.subscription=void 0,this.updatePaymentMethodUrl=void 0,this.period=void 0,this.loading=!0,this.error=void 0,this.details=void 0}componentWillLoad(){this.fetch()}handleSubscriptionChange(){this.fetch()}async fetch(){var e,t,s;if((null===(e=this.subscription)||void 0===e?void 0:e.cancel_at_period_end)&&this.subscription.current_period_end_at)this.loading=!1;else if("canceled"!==(null===(t=this.subscription)||void 0===t?void 0:t.status))try{this.loading=!0,this.period=await apiFetch({method:"PATCH",path:addQueryArgs(`surecart/v1/subscriptions/${null===(s=this.subscription)||void 0===s?void 0:s.id}/upcoming_period`,{skip_product_group_validation:!0,expand:["period.checkout","checkout.line_items","checkout.checkout_fees","checkout.shipping_fees","checkout.payment_method","checkout.manual_payment_method","payment_method.card","payment_method.payment_instrument","payment_method.paypal_account","payment_method.bank_account","line_item.price","line_item.fees","price.product","period.subscription"]}),data:{purge_pending_update:!1}})}catch(e){console.error(e),this.error=e}finally{this.loading=!1}else this.loading=!1}render(){var e,t,s,i,n,o,l,a;if(this.loading)return h("sc-toggle",{borderless:!0,disabled:!0},h("sc-flex",{slot:"summary",flexDirection:"column"},h("sc-skeleton",{style:{width:"200px"}}),h("sc-skeleton",{style:{width:"400px"}}),h("sc-skeleton",{style:{width:"300px"}})));const m=null===(e=null==this?void 0:this.period)||void 0===e?void 0:e.checkout;if(!m)return h("div",{style:{padding:"var(--sc-spacing-medium)"}},h("sc-subscription-details",{slot:"summary",subscription:this.subscription}));const c=(null==m?void 0:m.manual_payment)?null==m?void 0:m.manual_payment_method:null,d=(null==this?void 0:this.subscription.payment_method)||(null==this?void 0:this.subscription.manual_payment),r=null===(t=null==m?void 0:m.checkout_fees)||void 0===t?void 0:t.data,u=null===(s=null==m?void 0:m.shipping_fees)||void 0===s?void 0:s.data;return h(Host,null,h("sc-toggle",{borderless:!0,shady:!0},h("span",{slot:"summary"},h("sc-subscription-details",{subscription:this.subscription},h("div",{style:{fontSize:"var(--sc-font-size-small)"}},wp.i18n.__("Your next payment is","surecart")," ",h("strong",null,null==m?void 0:m.amount_due_display_amount)," ",!!(null===(i=this.subscription)||void 0===i?void 0:i.remaining_period_text)&&`— ${null===(n=this.subscription)||void 0===n?void 0:n.remaining_period_text}`))),h("sc-card",{noPadding:!0,borderless:!0},null===(o=null==m?void 0:m.line_items)||void 0===o?void 0:o.data.map((e=>{var t,s,i,n,o,l,a,m;return h("sc-product-line-item",{image:null===(s=null===(t=e.price)||void 0===t?void 0:t.product)||void 0===s?void 0:s.line_item_image,name:null===(n=null===(i=e.price)||void 0===i?void 0:i.product)||void 0===n?void 0:n.name,price:null===(o=null==e?void 0:e.price)||void 0===o?void 0:o.name,variant:null==e?void 0:e.variant_display_options,editable:!1,removable:!1,note:null==e?void 0:e.display_note,scratchDisplayAmount:null==e?void 0:e.scratch_display_amount,displayAmount:null==e?void 0:e.subtotal_display_amount,quantity:null==e?void 0:e.quantity,amount:null==e?void 0:e.subtotal_display_amount,interval:`${null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.short_interval_text} ${null===(a=null==e?void 0:e.price)||void 0===a?void 0:a.short_interval_count_text}`,purchasableStatus:null==e?void 0:e.purchasable_status_display,fees:null===(m=null==e?void 0:e.fees)||void 0===m?void 0:m.data})})),h("sc-line-item",null,h("span",{slot:"description"},wp.i18n.__("Subtotal","surecart")),h("span",{slot:"price-description"},null==m?void 0:m.subtotal_display_amount)),!!m.proration_amount&&h("sc-line-item",null,h("span",{slot:"description"},wp.i18n.__("Proration Credit","surecart")),h("span",{slot:"price-description"},null==m?void 0:m.proration_display_amount)),!!m.applied_balance_amount&&h("sc-line-item",null,h("span",{slot:"description"},wp.i18n.__("Applied Balance","surecart")),h("span",{slot:"price-description"},null==m?void 0:m.applied_balance_display_amount)),(null==r?void 0:r.length)>0&&h(Fragment,null,null==r?void 0:r.map((e=>h("sc-line-item",null,h("span",{slot:"description"},null==e?void 0:e.description),h("span",{slot:"price"},null==e?void 0:e.display_amount))))),!!m.trial_amount&&h("sc-line-item",null,h("span",{slot:"description"},wp.i18n.__("Trial","surecart")),h("span",{slot:"price-description"},null==m?void 0:m.trial_display_amount)),!!(null==m?void 0:m.discount_amount)&&h("sc-line-item",null,h("span",{slot:"description"},wp.i18n.__("Discounts","surecart")),h("span",{slot:"price-description"},null==m?void 0:m.discounts_display_amount)),!!(null==m?void 0:m.shipping_amount)&&h(Fragment,null,h("sc-line-item",{style:{marginTop:"var(--sc-spacing-small)"}},h("span",{slot:"description"},wp.i18n.__("Shipping","surecart")),h("span",{slot:"price-description"},null==m?void 0:m.shipping_display_amount)),(null==u?void 0:u.length)>0&&h(Fragment,null,null==u?void 0:u.map((e=>h("sc-line-item",null,h("span",{slot:"description"},null==e?void 0:e.description),h("span",{slot:"price"},null==e?void 0:e.display_amount)))))),!!m.tax_amount&&h("sc-line-item",null,h("span",{slot:"description"},formatTaxDisplay(null==m?void 0:m.tax_label)),h("span",{slot:"price-description"},null==m?void 0:m.tax_display_amount)),h("sc-divider",{style:{"--spacing":"0"}}),(null===(l=null==this?void 0:this.subscription)||void 0===l?void 0:l.can_modify)&&h("sc-line-item",null,h("span",{slot:"description"},wp.i18n.__("Payment","surecart")),d&&h("a",{href:this.updatePaymentMethodUrl,slot:"price-description"},h("sc-flex",{"justify-content":"flex-start","align-items":"center",style:{"--spacing":"0.5em"}},c?h("sc-manual-payment-method",{paymentMethod:c}):h("sc-payment-method",{paymentMethod:null==m?void 0:m.payment_method}),h("sc-icon",{name:"edit-3"}))),!d&&h("a",{href:addQueryArgs(window.location.href,{action:"create",model:"payment_method",id:null==this?void 0:this.subscription.id,...!1===(null===(a=null==this?void 0:this.subscription)||void 0===a?void 0:a.live_mode)?{live_mode:!1}:{}}),slot:"price-description"},wp.i18n.__("Add Payment Method","surecart"))),h("sc-line-item",{style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{slot:"title"},wp.i18n.__("Total Due","surecart")),h("span",{slot:"price"},null==m?void 0:m.amount_due_display_amount),h("span",{slot:"currency"},m.currency)))))}static get watchers(){return{subscription:["handleSubscriptionChange"]}}},[1,"sc-subscription-next-payment",{subscription:[16],updatePaymentMethodUrl:[1,"update-payment-method-url"],period:[32],loading:[32],error:[32],details:[32]},void 0,{subscription:["handleSubscriptionChange"]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["sc-subscription-next-payment","sc-button","sc-card","sc-cc-logo","sc-dialog","sc-divider","sc-flex","sc-format-number","sc-icon","sc-line-item","sc-manual-payment-method","sc-payment-method","sc-product-line-item","sc-product-line-item-note","sc-prose","sc-quantity-select","sc-skeleton","sc-spinner","sc-stacked-list","sc-stacked-list-row","sc-subscription-details","sc-subscription-status-badge","sc-tag","sc-text","sc-toggle","sc-tooltip"].forEach((e=>{switch(e){case"sc-subscription-next-payment":customElements.get(e)||customElements.define(e,ScSubscriptionNextPayment);break;case"sc-button":customElements.get(e)||defineCustomElement$p();break;case"sc-card":customElements.get(e)||defineCustomElement$o();break;case"sc-cc-logo":customElements.get(e)||defineCustomElement$n();break;case"sc-dialog":customElements.get(e)||defineCustomElement$m();break;case"sc-divider":customElements.get(e)||defineCustomElement$l();break;case"sc-flex":customElements.get(e)||defineCustomElement$k();break;case"sc-format-number":customElements.get(e)||defineCustomElement$j();break;case"sc-icon":customElements.get(e)||defineCustomElement$i();break;case"sc-line-item":customElements.get(e)||defineCustomElement$h();break;case"sc-manual-payment-method":customElements.get(e)||defineCustomElement$g();break;case"sc-payment-method":customElements.get(e)||defineCustomElement$f();break;case"sc-product-line-item":customElements.get(e)||defineCustomElement$e();break;case"sc-product-line-item-note":customElements.get(e)||defineCustomElement$d();break;case"sc-prose":customElements.get(e)||defineCustomElement$c();break;case"sc-quantity-select":customElements.get(e)||defineCustomElement$b();break;case"sc-skeleton":customElements.get(e)||defineCustomElement$a();break;case"sc-spinner":customElements.get(e)||defineCustomElement$9();break;case"sc-stacked-list":customElements.get(e)||defineCustomElement$8();break;case"sc-stacked-list-row":customElements.get(e)||defineCustomElement$7();break;case"sc-subscription-details":customElements.get(e)||defineCustomElement$6();break;case"sc-subscription-status-badge":customElements.get(e)||defineCustomElement$5();break;case"sc-tag":customElements.get(e)||defineCustomElement$4();break;case"sc-text":customElements.get(e)||defineCustomElement$3();break;case"sc-toggle":customElements.get(e)||defineCustomElement$2();break;case"sc-tooltip":customElements.get(e)||defineCustomElement$1()}}))}export{ScSubscriptionNextPayment as S,defineCustomElement as d};
Save
Back