1import{u as e,n as s,j as a}from"./main-BmYsSTrY.js";import{r as l,A as t}from"./vendor-DI-zMLkP.js";import{ba as o}from"./index-9Yy5i9pU.js";const r=()=>{const[a,o]=l.useState([]),[r,i]=l.useState(!0),[n,d]=l.useState([]),{t:u}=e(),m=l.useRef(null),c=[{field:"password",requisite:{name:"password",labelValue:`${u("form.txt_password")}`,placeholder:`${u("form.txt_password")}`,className:"px-4 basis-full md:basis-6/12"}},{field:"password",requisite:{name:"confirm_password",labelValue:`${u("form.txt_confirm_password")}`,placeholder:`${u("form.txt_confirm_password")}`,className:"px-4 basis-full md:basis-6/12"}}],f=[{field:"text",requisite:{name:"first_name",labelValue:`${u("form.txt_first_name")}`,placeholder:`${u("form.txt_first_name")}`,className:"px-4 basis-full md:basis-6/12",validation:{required:{value:!0,message:`${u("form.txt_first_name_msg")}`}}}},{field:"text",requisite:{name:"last_name",labelValue:`${u("form.txt_last_name")}`,placeholder:`${u("form.txt_last_name")}`,className:"px-4 basis-full md:basis-6/12",validation:{required:{value:!0,message:`${u("form.txt_last_name_msg")}`}}}},{field:"text",requisite:{name:"email",labelValue:`${u("form.txt_email")}`,placeholder:`${u("form.txt_email")}`,className:"px-4 basis-full md:basis-6/12",validation:{required:{value:!0,message:`${u("form.txt_email_msg")}`}}}},{field:"text",requisite:{name:"phone",labelValue:`${u("form.txt_phone")}`,placeholder:`${u("form.txt_phone")}`,className:"px-4 basis-full md:basis-6/12",validation:{required:{value:!0,message:`${u("form.txt_phone_msg")}`}}}}];l.useEffect((()=>{p()}),[]);const p=async()=>{var e;try{const s=await t.getCustomerDetails();i(!1);const a=null==s?void 0:s.Data;null==a||delete a.common_details.accepts_product_review_abandoned_cart_emails,d(null==a?void 0:a.common_details);const l=null==(e=null==a?void 0:a.dynamic_details)?void 0:e.map(((e,s)=>{var a,l;const t={key:s,field:null==e?void 0:e.fieldType,requisite:{name:null==e?void 0:e.label,labelValue:null==e?void 0:e.label,className:"px-4 basis-full md:basis-6/12",placeholder:null==e?void 0:e.label,validation:{required:{value:null==e?void 0:e.required,message:`${null==e?void 0:e.label} ${u("form.txt_is_required")}`}}}};if(null==e?void 0:e.options){t.requisite.options=null==e?void 0:e.options.items;const s=null==(l=null==(a=null==t?void 0:t.requisite)?void 0:a.options)?void 0:l.map((s=>({value:null==s?void 0:s.label,label:null==s?void 0:s.label,isSelected:!!(null==e?void 0:e.value)&&("object"==typeof(null==e?void 0:e.value)?null==e?void 0:e.value.includes(null==s?void 0:s.label):(null==e?void 0:e.value)===(null==s?void 0:s.label))})));t.requisite.options=s}return t}));l.push(c[0]),l.push(c[1]),o([...f,...l])}catch(s){console.error(s)}};return{dynamicForm:a,onSubmitAdressesForm:async e=>{const a={},l={};for(const s in e)n.hasOwnProperty(s)&&e.hasOwnProperty(s)?a[s]=e[s]:l[s]=e[s];(async(e,a)=>{try{a.password===a.confirm_password?a.password&&a.password.length?(e.password=a.password,delete a.confirm_password,null==e||delete e.company,delete a.password,await t.updateCustomerDetails(e,a)&&s.success(u("toast_msg_success.user_detail_update"))):(delete a.confirm_password,delete a.password,null==e||delete e.company,await t.updateCustomerDetails(e,a||{})&&s.success(u("toast_msg_success.user_detail_update"))):s.error(u("toast_msg_error.pass_and_confirm_pass_match"))}catch(l){console.error(l)}})(a,l)},isLoading:r,formRef:m,commonData:n}},i=()=>{const{dynamicForm:s,onSubmitAdressesForm:t,isLoading:i,formRef:n,commonData:d}=r(),{t:u}=e();return l.useEffect((()=>{d&&Object.entries(d).forEach((([e,s])=>{n.current&&n.current.setValue(e,s)}))}),[d,n.current]),a.jsx(a.Fragment,{children:i?a.jsxs("div",{className:"flex justify-center items-center absolute top-0 left-0 right-0 w-full mobile:h-64 h-full",children:[a.jsx("div",{className:"w-14 h-14 rounded-full absolute border-2 border-solid border-gray-100"}),a.jsx("div",{className:"w-14 h-14 rounded-full animate-spin absolute border-2 border-solid border-primary-default border-t-transparent"})]}):a.jsx(a.Fragment,{children:a.jsx(o,{ref:n,config:s,isLoading:i,onSubmit:t,buttonText:u("common.txt_update_details"),buttonClass:"button-primary button-large w-full sm:w-auto"})})})};export{i as default};
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.