1import{r as e,h as i}from"./p-9add63ef.js";import"./p-8dccb656.js";import{a as s}from"./p-401e165e.js";import{a}from"./p-259c3935.js";import"./p-d3366af3.js";const n=":host{display:block;position:relative}.customer-edit{display:grid;gap:0.75em}";const t=n;const d=class{constructor(i){e(this,i);this.heading=undefined;this.customer=undefined;this.successUrl=undefined;this.loading=undefined;this.error=undefined}async handleSubmit(e){var i,n;this.loading=true;try{const{email:n,first_name:t,last_name:d,phone:l,billing_matches_shipping:c,shipping_name:o,shipping_city:b,"tax_identifier.number_type":r,"tax_identifier.number":f,shipping_country:p,shipping_line_1:u,shipping_line_2:h,shipping_postal_code:_,shipping_state:m,billing_name:g,billing_city:y,billing_country:v,billing_line_1:k,billing_line_2:w,billing_postal_code:x,billing_state:S}=await e.target.getFormJson();this.customer.billing_address={name:g,city:y,country:v,line_1:k,line_2:w,postal_code:x,state:S};this.customer.shipping_address={name:o,city:b,country:p,line_1:u,line_2:h,postal_code:_,state:m};await a({path:s(`surecart/v1/customers/${(i=this.customer)===null||i===void 0?void 0:i.id}`,{expand:["tax_identifier"]}),method:"PATCH",data:{email:n,first_name:t,last_name:d,phone:l,billing_matches_shipping:c===true||c==="on",shipping_address:this.customer.shipping_address,billing_address:this.customer.billing_address,...f&&r?{tax_identifier:{number:f,number_type:r}}:{}}});if(this.successUrl){window.location.assign(this.successUrl)}else{this.loading=false}}catch(e){this.error=((n=e===null||e===void 0?void 0:e.additional_errors)===null||n===void 0?void 0:n.length)?e.additional_errors.map((e=>e.message)).join(", "):(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart");this.loading=false}}render(){var e,s,a,n,t,d,l,c,o,b,r,f;return i("sc-dashboard-module",{key:"a98f2574174a213f82aff1da5de2fd3d57c5ee40",class:"customer-edit",error:this.error},i("span",{key:"4e971fb63300b57df168a89eb8d3465e63058f8d",slot:"heading"},this.heading||wp.i18n.__("Update Billing Details","surecart")," ",!((e=this===null||this===void 0?void 0:this.customer)===null||e===void 0?void 0:e.live_mode)&&i("sc-tag",{key:"ff9ec704fd6881e080d1783a46e27cb6f1e7ceaa",type:"warning",size:"small"},wp.i18n.__("Test","surecart"))),i("sc-card",{key:"ffc117ad7dad4f2e422ca51734188f6ae457ea93"},i("sc-form",{key:"3e38bcd2ef6b6cb99f216eb939b2b2497b9b1c04",onScFormSubmit:e=>this.handleSubmit(e)},i("sc-columns",{key:"7b3e2573f57e5a37549d9ff5a2cbb0bc9e544f45",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},i("sc-column",{key:"6924d8e9ca85967d49300d925a43ea13311737a5"},i("sc-input",{key:"593c99a7473cf44be10e21091b166658c351652f",label:wp.i18n.__("First Name","surecart"),name:"first_name",value:(s=this.customer)===null||s===void 0?void 0:s.first_name})),i("sc-column",{key:"f9f712bdece7fbc4b7924f18b4686d9e4072cdf5"},i("sc-input",{key:"6eef3b3553a9a61b8732bb0902750a8b4a7b6d74",label:wp.i18n.__("Last Name","surecart"),name:"last_name",value:(a=this.customer)===null||a===void 0?void 0:a.last_name}))),i("sc-column",{key:"fdb1f1dd1fa58106712fa3bf80c85f98f1f2930a"},i("sc-phone-input",{key:"f254c078519533aa4699805eb482522579f0bd37",label:wp.i18n.__("Phone","surecart"),name:"phone",value:(n=this.customer)===null||n===void 0?void 0:n.phone})),i("sc-flex",{key:"5b4f01983228c854158f6b30483823519a74f3f5",style:{"--sc-flex-column-gap":"var(--sc-spacing-medium)"},flexDirection:"column"},i("div",{key:"97b0da5fd51f1192ea2758b2ff73df738f5f8a49"},i("sc-address",{key:"a7bbeebb1efa7b29495448f645282587c2bb975f",label:wp.i18n.__("Shipping Address","surecart"),showName:true,address:{...(t=this.customer)===null||t===void 0?void 0:t.shipping_address},showLine2:true,required:false,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"}})),i("div",{key:"9bc391963a3a6e87fba721409c92f5cfc6d264f8"},i("sc-checkbox",{key:"82ff06ed05e175c042376a0da259de7f47836973",name:"billing_matches_shipping",checked:(d=this.customer)===null||d===void 0?void 0:d.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"))),i("div",{key:"fdefbbb70d9b1198b2bcdc632c8a6f281d28181d",style:{display:((l=this.customer)===null||l===void 0?void 0:l.billing_matches_shipping)?"none":"block"}},i("sc-address",{key:"a5db072f80c8dde6436373579de6f527e0455236",label:wp.i18n.__("Billing Address","surecart"),showName:true,address:{...(c=this.customer)===null||c===void 0?void 0:c.billing_address},showLine2:true,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:true})),i("sc-tax-id-input",{key:"cfe575912b2f928a2ef4bc3bb8352a46fe9375f1",show:true,number:(b=(o=this.customer)===null||o===void 0?void 0:o.tax_identifier)===null||b===void 0?void 0:b.number,type:(f=(r=this.customer)===null||r===void 0?void 0:r.tax_identifier)===null||f===void 0?void 0:f.number_type})),i("div",{key:"63c655477269f99dbfa7739694d42add065943b5"},i("sc-button",{key:"ed58acf9ab50f7fb02898e4b2608ac0a3710602d",type:"primary",full:true,submit:true},wp.i18n.__("Save","surecart"))))),this.loading&&i("sc-block-ui",{key:"71fb6e532b16f94ff6a6c6b54
10b6ba14b51d39b8",spinner:true}))}};d.style=t;export{d as sc_customer_edit}; 2//# sourceMappingURL=p-9c2db8bf.entry.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.