FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-wordpress-user-edit.js
import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{a as apiFetch}from"./fetch.js";import{d as defineCustomElement$e}from"./sc-alert2.js";import{d as defineCustomElement$d}from"./sc-block-ui2.js";import{d as defineCustomElement$c}from"./sc-button2.js";import{d as defineCustomElement$b}from"./sc-card2.js";import{d as defineCustomElement$a}from"./sc-column2.js";import{d as defineCustomElement$9}from"./sc-columns2.js";import{d as defineCustomElement$8}from"./sc-dashboard-module2.js";import{d as defineCustomElement$7}from"./sc-form2.js";import{d as defineCustomElement$6}from"./sc-form-control2.js";import{d as defineCustomElement$5}from"./sc-icon2.js";import{d as defineCustomElement$4}from"./sc-input2.js";import{d as defineCustomElement$3}from"./sc-spinner2.js";import{d as defineCustomElement$2}from"./sc-visually-hidden2.js";const scWordpressUserEditCss=":host{display:block;position:relative}.customer-details{display:grid;gap:0.75em}",ScWordpressUserEditStyle0=scWordpressUserEditCss,ScWordPressUserEdit=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.heading=void 0,this.successUrl=void 0,this.user=void 0,this.loading=void 0,this.error=void 0}renderEmpty(){return h("slot",{name:"empty"},wp.i18n.__("User not found.","surecart"))}async handleSubmit(e){this.loading=!0;try{const{email:s,first_name:t,last_name:c,name:a}=await e.target.getFormJson();await apiFetch({path:"wp/v2/users/me",method:"PATCH",data:{first_name:t,last_name:c,email:s,name:a}}),this.successUrl?window.location.assign(this.successUrl):this.loading=!1}catch(e){this.error=(null==e?void 0:e.message)||wp.i18n.__("Something went wrong","surecart"),this.loading=!1}}render(){var e,s,t,c;return h("sc-dashboard-module",{key:"d3991ade900d5c99a0bb2ecc6a950e0dd4ee9282",class:"account-details",error:this.error},h("span",{key:"69d5f747a614066842989061c3ff71b4b56bd66b",slot:"heading"},this.heading||wp.i18n.__("Account Details","surecart")," "),h("sc-card",{key:"c4050793f41a8d1ec77e098904946017d99df3b5"},h("sc-form",{key:"f4f31d0c65dea331b7f410157136e77c6273606d",onScFormSubmit:e=>this.handleSubmit(e)},h("sc-input",{key:"acdf922f1b37989987d92792fd8ce9e2cfbdf6ab",label:wp.i18n.__("Account Email","surecart"),name:"email",value:null===(e=this.user)||void 0===e?void 0:e.email,required:!0}),h("sc-columns",{key:"80301d7d30fd69520b76f1e4ea85f6f7a073e3ab",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},h("sc-column",{key:"6382e6ac670f72fa2a0753cfb599ba2136962233"},h("sc-input",{key:"4e194a470f8a05b1b4f331b4f4bdfebd58c4cd0a",label:wp.i18n.__("First Name","surecart"),name:"first_name",value:null===(s=this.user)||void 0===s?void 0:s.first_name})),h("sc-column",{key:"965ba5f1c8334a07345da22895cf1bbf5d0c49fe"},h("sc-input",{key:"8c6f3cbdaa3aca5354af59aed523cd1dcf21b04f",label:wp.i18n.__("Last Name","surecart"),name:"last_name",value:null===(t=this.user)||void 0===t?void 0:t.last_name}))),h("sc-input",{key:"9bf51f77a4e564bb2c63d80e14c0137d79c49dba",label:wp.i18n.__("Display Name","surecart"),name:"name",value:null===(c=this.user)||void 0===c?void 0:c.display_name}),h("div",{key:"561569acd51110e7c34861ca94d7d2a364ae2722"},h("sc-button",{key:"90eb919999749bfce5502ed127c5509bc31f96d2",type:"primary",full:!0,submit:!0},wp.i18n.__("Save","surecart"))))),this.loading&&h("sc-block-ui",{key:"1603d379be8ba340238fa4af47f7ce14d9eeafcd",spinner:!0}))}static get style(){return ScWordpressUserEditStyle0}},[1,"sc-wordpress-user-edit",{heading:[1],successUrl:[1,"success-url"],user:[16],loading:[32],error:[32]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["sc-wordpress-user-edit","sc-alert","sc-block-ui","sc-button","sc-card","sc-column","sc-columns","sc-dashboard-module","sc-form","sc-form-control","sc-icon","sc-input","sc-spinner","sc-visually-hidden"].forEach((e=>{switch(e){case"sc-wordpress-user-edit":customElements.get(e)||customElements.define(e,ScWordPressUserEdit);break;case"sc-alert":customElements.get(e)||defineCustomElement$e();break;case"sc-block-ui":customElements.get(e)||defineCustomElement$d();break;case"sc-button":customElements.get(e)||defineCustomElement$c();break;case"sc-card":customElements.get(e)||defineCustomElement$b();break;case"sc-column":customElements.get(e)||defineCustomElement$a();break;case"sc-columns":customElements.get(e)||defineCustomElement$9();break;case"sc-dashboard-module":customElements.get(e)||defineCustomElement$8();break;case"sc-form":customElements.get(e)||defineCustomElement$7();break;case"sc-form-control":customElements.get(e)||defineCustomElement$6();break;case"sc-icon":customElements.get(e)||defineCustomElement$5();break;case"sc-input":customElements.get(e)||defineCustomElement$4();break;case"sc-spinner":customElements.get(e)||defineCustomElement$3();break;case"sc-visually-hidden":customElements.get(e)||defineCustomElement$2()}}))}const ScWordpressUserEdit=ScWordPressUserEdit,defineCustomElement=defineCustomElement$1;export{ScWordpressUserEdit,defineCustomElement};
Save
Back