FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-customer-edit.js
import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{a as apiFetch}from"./fetch.js";import{d as defineCustomElement$p}from"./sc-address2.js";import{d as defineCustomElement$o}from"./sc-alert2.js";import{d as defineCustomElement$n}from"./sc-block-ui2.js";import{d as defineCustomElement$m}from"./sc-button2.js";import{d as defineCustomElement$l}from"./sc-card2.js";import{d as defineCustomElement$k}from"./sc-checkbox2.js";import{d as defineCustomElement$j}from"./sc-column2.js";import{d as defineCustomElement$i}from"./sc-columns2.js";import{d as defineCustomElement$h}from"./sc-dashboard-module2.js";import{d as defineCustomElement$g}from"./dropdown.js";import{d as defineCustomElement$f}from"./sc-flex2.js";import{d as defineCustomElement$e}from"./sc-form2.js";import{d as defineCustomElement$d}from"./sc-form-control2.js";import{d as defineCustomElement$c}from"./sc-icon2.js";import{d as defineCustomElement$b}from"./sc-input2.js";import{d as defineCustomElement$a}from"./sc-menu2.js";import{d as defineCustomElement$9}from"./sc-menu-item2.js";import{d as defineCustomElement$8}from"./sc-menu-label2.js";import{d as defineCustomElement$7}from"./sc-phone-input2.js";import{d as defineCustomElement$6}from"./sc-select2.js";import{d as defineCustomElement$5}from"./sc-spinner2.js";import{d as defineCustomElement$4}from"./sc-tag2.js";import{d as defineCustomElement$3}from"./sc-tax-id-input2.js";import{d as defineCustomElement$2}from"./sc-visually-hidden2.js";import{a as addQueryArgs}from"./add-query-args.js";const scCustomerEditCss=":host{display:block;position:relative}.customer-edit{display:grid;gap:0.75em}",ScCustomerEditStyle0=scCustomerEditCss,ScCustomerEdit$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.heading=void 0,this.customer=void 0,this.successUrl=void 0,this.loading=void 0,this.error=void 0}async handleSubmit(e){var s,t;this.loading=!0;try{const{email:t,first_name:i,last_name:n,phone:c,billing_matches_shipping:o,shipping_name:m,shipping_city:a,"tax_identifier.number_type":d,"tax_identifier.number":l,shipping_country:r,shipping_line_1:u,shipping_line_2:f,shipping_postal_code:p,shipping_state:h,billing_name:b,billing_city:g,billing_country:_,billing_line_1:E,billing_line_2:C,billing_postal_code:y,billing_state:k}=await e.target.getFormJson();this.customer.billing_address={name:b,city:g,country:_,line_1:E,line_2:C,postal_code:y,state:k},this.customer.shipping_address={name:m,city:a,country:r,line_1:u,line_2:f,postal_code:p,state:h},await apiFetch({path:addQueryArgs(`surecart/v1/customers/${null===(s=this.customer)||void 0===s?void 0:s.id}`,{expand:["tax_identifier"]}),method:"PATCH",data:{email:t,first_name:i,last_name:n,phone:c,billing_matches_shipping:!0===o||"on"===o,shipping_address:this.customer.shipping_address,billing_address:this.customer.billing_address,...l&&d?{tax_identifier:{number:l,number_type:d}}:{}}}),this.successUrl?window.location.assign(this.successUrl):this.loading=!1}catch(e){this.error=(null===(t=null==e?void 0:e.additional_errors)||void 0===t?void 0:t.length)?e.additional_errors.map((e=>e.message)).join(", "):(null==e?void 0:e.message)||wp.i18n.__("Something went wrong","surecart"),this.loading=!1}}render(){var e,s,t,i,n,c,o,m,a,d,l,r;return h("sc-dashboard-module",{key:"f6f28add4917670d41905c34f2ce3ecca0359f2a",class:"customer-edit",error:this.error},h("span",{key:"52a7be03cc3772e08253045a926dba4727eb8d9b",slot:"heading"},this.heading||wp.i18n.__("Update Billing Details","surecart")," ",!(null===(e=null==this?void 0:this.customer)||void 0===e?void 0:e.live_mode)&&h("sc-tag",{key:"a716da09e5acaffef6f50155ca8c1ccdccb9971c",type:"warning",size:"small"},wp.i18n.__("Test","surecart"))),h("sc-card",{key:"4b27a010d9a76a8dd5ec4848d7dd792e23ac25a9"},h("sc-form",{key:"173f5f3dccc357d18b236b9d8100ff28522e5614",onScFormSubmit:e=>this.handleSubmit(e)},h("sc-columns",{key:"ff57688ebcdf69ca83ccef6704b51df973a38920",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},h("sc-column",{key:"da47915b3e89b3bfd12f3a71da070c7aaffa0571"},h("sc-input",{key:"7b65bade03d0a6c8d4d092c09956d37015cec012",label:wp.i18n.__("First Name","surecart"),name:"first_name",value:null===(s=this.customer)||void 0===s?void 0:s.first_name})),h("sc-column",{key:"a974aa096e1122636ce40f9acc917d8535d981a2"},h("sc-input",{key:"c4714c876c767f2183e9f456d1c33ce75ad9e132",label:wp.i18n.__("Last Name","surecart"),name:"last_name",value:null===(t=this.customer)||void 0===t?void 0:t.last_name}))),h("sc-column",{key:"68b7aa6719978747e9b912a78c0e5dbf479fc734"},h("sc-phone-input",{key:"54683f88de8b5edba9ace499efbc25736cc7cf3e",label:wp.i18n.__("Phone","surecart"),name:"phone",value:null===(i=this.customer)||void 0===i?void 0:i.phone})),h("sc-flex",{key:"a545f3091574e2e17a8f2f031e957e46ff2bc7c5",style:{"--sc-flex-column-gap":"var(--sc-spacing-medium)"},flexDirection:"column"},h("div",{key:"38af463d3cce767ca2eae9f0e63463f65f40f0c4"},h("sc-address",{key:"7a05e86bd9140cc0206cfb936622104cd5b7cbbc",label:wp.i18n.__("Shipping Address","surecart"),showName:!0,address:{...null===(n=this.customer)||void 0===n?void 0:n.shipping_address},showLine2:!0,required:!1,names:{name:"shipping_name",country:"shipping_country",line_1:"shipping_line_1",line_2:"shipping_line_2",city:"shipping_city",postal_code:"shipping_postal_code",state:"shipping_state"}})),h("div",{key:"7cbc7a550fa9cbcd9bcdf0817c2a365e57c29af0"},h("sc-checkbox",{key:"cab147a7ffd45d81eb65ce02afeb49da89236c7d",name:"billing_matches_shipping",checked:null===(c=this.customer)||void 0===c?void 0:c.billing_matches_shipping,onScChange:e=>{this.customer={...this.customer,billing_matches_shipping:e.target.checked}},value:"on"},wp.i18n.__("Billing address is same as shipping","surecart"))),h("div",{key:"3328d77750122d5741cfb19e6a5d0567c0859dd0",style:{display:(null===(o=this.customer)||void 0===o?void 0:o.billing_matches_shipping)?"none":"block"}},h("sc-address",{key:"6a6f3468053cf0f995268b924ef1cc55e05cdb2c",label:wp.i18n.__("Billing Address","surecart"),showName:!0,address:{...null===(m=this.customer)||void 0===m?void 0:m.billing_address},showLine2:!0,names:{name:"billing_name",country:"billing_country",line_1:"billing_line_1",line_2:"billing_line_2",city:"billing_city",postal_code:"billing_postal_code",state:"billing_state"},required:!0})),h("sc-tax-id-input",{key:"86e96249004f5ee6b4d2f39ac57c48cdf329a154",show:!0,number:null===(d=null===(a=this.customer)||void 0===a?void 0:a.tax_identifier)||void 0===d?void 0:d.number,type:null===(r=null===(l=this.customer)||void 0===l?void 0:l.tax_identifier)||void 0===r?void 0:r.number_type})),h("div",{key:"e4d18af488131e86142b9cf0e21581a9da6d48d3"},h("sc-button",{key:"ad82f758e874abbc12f5b05e8fa065916b230221",type:"primary",full:!0,submit:!0},wp.i18n.__("Save","surecart"))))),this.loading&&h("sc-block-ui",{key:"24cbcea4babe0de8909cb00b40efbeea3b04169d",spinner:!0}))}static get style(){return ScCustomerEditStyle0}},[1,"sc-customer-edit",{heading:[1],customer:[1040],successUrl:[1,"success-url"],loading:[32],error:[32]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["sc-customer-edit","sc-address","sc-alert","sc-block-ui","sc-button","sc-card","sc-checkbox","sc-column","sc-columns","sc-dashboard-module","sc-dropdown","sc-flex","sc-form","sc-form-control","sc-icon","sc-input","sc-menu","sc-menu-item","sc-menu-label","sc-phone-input","sc-select","sc-spinner","sc-tag","sc-tax-id-input","sc-visually-hidden"].forEach((e=>{switch(e){case"sc-customer-edit":customElements.get(e)||customElements.define(e,ScCustomerEdit$1);break;case"sc-address":customElements.get(e)||defineCustomElement$p();break;case"sc-alert":customElements.get(e)||defineCustomElement$o();break;case"sc-block-ui":customElements.get(e)||defineCustomElement$n();break;case"sc-button":customElements.get(e)||defineCustomElement$m();break;case"sc-card":customElements.get(e)||defineCustomElement$l();break;case"sc-checkbox":customElements.get(e)||defineCustomElement$k();break;case"sc-column":customElements.get(e)||defineCustomElement$j();break;case"sc-columns":customElements.get(e)||defineCustomElement$i();break;case"sc-dashboard-module":customElements.get(e)||defineCustomElement$h();break;case"sc-dropdown":customElements.get(e)||defineCustomElement$g();break;case"sc-flex":customElements.get(e)||defineCustomElement$f();break;case"sc-form":customElements.get(e)||defineCustomElement$e();break;case"sc-form-control":customElements.get(e)||defineCustomElement$d();break;case"sc-icon":customElements.get(e)||defineCustomElement$c();break;case"sc-input":customElements.get(e)||defineCustomElement$b();break;case"sc-menu":customElements.get(e)||defineCustomElement$a();break;case"sc-menu-item":customElements.get(e)||defineCustomElement$9();break;case"sc-menu-label":customElements.get(e)||defineCustomElement$8();break;case"sc-phone-input":customElements.get(e)||defineCustomElement$7();break;case"sc-select":customElements.get(e)||defineCustomElement$6();break;case"sc-spinner":customElements.get(e)||defineCustomElement$5();break;case"sc-tag":customElements.get(e)||defineCustomElement$4();break;case"sc-tax-id-input":customElements.get(e)||defineCustomElement$3();break;case"sc-visually-hidden":customElements.get(e)||defineCustomElement$2()}}))}const ScCustomerEdit=ScCustomerEdit$1,defineCustomElement=defineCustomElement$1;export{ScCustomerEdit,defineCustomElement};
Save
Back