FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
Edit File: p-8432d0d2.entry.js
import{r as e,h as i}from"./p-e97fde0a.js";import{a}from"./p-dd3464cd.js";import{a as s}from"./p-401e165e.js";import"./p-d3366af3.js";const c=":host{display:block;position:relative}.customer-edit{display:grid;gap:0.75em}";const n=c;const t=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,c;this.loading=true;try{const{email:c,first_name:n,last_name:t,phone:d,billing_matches_shipping:l,shipping_name:o,shipping_city:r,"tax_identifier.number_type":p,"tax_identifier.number":u,shipping_country:b,shipping_line_1:f,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:r,country:b,line_1:f,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:c,first_name:n,last_name:t,phone:d,billing_matches_shipping:l===true||l==="on",shipping_address:this.customer.shipping_address,billing_address:this.customer.billing_address,...u&&p?{tax_identifier:{number:u,number_type:p}}:{}}});if(this.successUrl){window.location.assign(this.successUrl)}else{this.loading=false}}catch(e){this.error=((c=e===null||e===void 0?void 0:e.additional_errors)===null||c===void 0?void 0:c.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,a,s,c,n,t,d,l,o,r,p,u;return i("sc-dashboard-module",{key:"f6f28add4917670d41905c34f2ce3ecca0359f2a",class:"customer-edit",error:this.error},i("span",{key:"52a7be03cc3772e08253045a926dba4727eb8d9b",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:"a716da09e5acaffef6f50155ca8c1ccdccb9971c",type:"warning",size:"small"},wp.i18n.__("Test","surecart"))),i("sc-card",{key:"4b27a010d9a76a8dd5ec4848d7dd792e23ac25a9"},i("sc-form",{key:"173f5f3dccc357d18b236b9d8100ff28522e5614",onScFormSubmit:e=>this.handleSubmit(e)},i("sc-columns",{key:"ff57688ebcdf69ca83ccef6704b51df973a38920",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},i("sc-column",{key:"da47915b3e89b3bfd12f3a71da070c7aaffa0571"},i("sc-input",{key:"7b65bade03d0a6c8d4d092c09956d37015cec012",label:wp.i18n.__("First Name","surecart"),name:"first_name",value:(a=this.customer)===null||a===void 0?void 0:a.first_name})),i("sc-column",{key:"a974aa096e1122636ce40f9acc917d8535d981a2"},i("sc-input",{key:"c4714c876c767f2183e9f456d1c33ce75ad9e132",label:wp.i18n.__("Last Name","surecart"),name:"last_name",value:(s=this.customer)===null||s===void 0?void 0:s.last_name}))),i("sc-column",{key:"68b7aa6719978747e9b912a78c0e5dbf479fc734"},i("sc-phone-input",{key:"54683f88de8b5edba9ace499efbc25736cc7cf3e",label:wp.i18n.__("Phone","surecart"),name:"phone",value:(c=this.customer)===null||c===void 0?void 0:c.phone})),i("sc-flex",{key:"a545f3091574e2e17a8f2f031e957e46ff2bc7c5",style:{"--sc-flex-column-gap":"var(--sc-spacing-medium)"},flexDirection:"column"},i("div",{key:"38af463d3cce767ca2eae9f0e63463f65f40f0c4"},i("sc-address",{key:"7a05e86bd9140cc0206cfb936622104cd5b7cbbc",label:wp.i18n.__("Shipping Address","surecart"),showName:true,address:{...(n=this.customer)===null||n===void 0?void 0:n.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:"7cbc7a550fa9cbcd9bcdf0817c2a365e57c29af0"},i("sc-checkbox",{key:"cab147a7ffd45d81eb65ce02afeb49da89236c7d",name:"billing_matches_shipping",checked:(t=this.customer)===null||t===void 0?void 0:t.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:"3328d77750122d5741cfb19e6a5d0567c0859dd0",style:{display:((d=this.customer)===null||d===void 0?void 0:d.billing_matches_shipping)?"none":"block"}},i("sc-address",{key:"6a6f3468053cf0f995268b924ef1cc55e05cdb2c",label:wp.i18n.__("Billing Address","surecart"),showName:true,address:{...(l=this.customer)===null||l===void 0?void 0:l.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:"86e96249004f5ee6b4d2f39ac57c48cdf329a154",show:true,number:(r=(o=this.customer)===null||o===void 0?void 0:o.tax_identifier)===null||r===void 0?void 0:r.number,type:(u=(p=this.customer)===null||p===void 0?void 0:p.tax_identifier)===null||u===void 0?void 0:u.number_type})),i("div",{key:"e4d18af488131e86142b9cf0e21581a9da6d48d3"},i("sc-button",{key:"ad82f758e874abbc12f5b05e8fa065916b230221",type:"primary",full:true,submit:true},wp.i18n.__("Save","surecart"))))),this.loading&&i("sc-block-ui",{key:"24cbcea4babe0de8909cb00b40efbeea3b04169d",spinner:true}))}};t.style=n;export{t as sc_customer_edit}; //# sourceMappingURL=p-8432d0d2.entry.js.map
Save
Back