import{c as V,a as r,b as h}from"./index.esm-17a8dbbe.js";import{k as g,b as y,a as N,L as O,x as U,r as s,o as b,c as f,w as _,j as v,d as p,f as t,n as T,t as D,e as I,l as S}from"./index-0c00d6f8.js";const J="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADhSURBVHgBnVLbEYIwELwwFJAOiB1QiiXYghUoFViCdCAdYAdoBVJCOoh7eJF8BBLYmc3jcnuPJEQrcM5p0NAesBD8CDVtBUSDmzEs+RUL4ismzvoEO16LLTu7kf5b8O73Md9SBHx4AivJfFZKWdgnJ6xHCXLD1oJv2NqwhR68iJiCOYSV2bAvgvW+3FouykRamVqI2LVoqsJn4zIpE9yeLA++hZG2Y+ShTDh1ifN/gOgTodS1AJOmWAuQwE8T3OgxV8m+otGlfJgG9od8HEvzm8ey+mob1qogKh/UlIeXf8ov7rKesLicyC0AAAAASUVORK5CYII=";const $={class:"profile_page mt-11"},x={class:"grid grid-cols-1 md:grid-cols-2 gap-2"},F={class:"md:col-span-2 relative"},Y={class:"flex items-center justify-end mt-3"},k=["disabled"],X={__name:"Account",setup(q){const u=g(!0),d=g(!1),c=y(),{t:i}=N(),a=O({name:"",email:"",phoneNumber:"",preview:"",phoneCode:"",image:""}),L=V().shape({name:r().required(i("ERRORS.name")),email:r().required(i("ERRORS.emailAddress")),phoneCode:h().required(i("ERRORS.phoneCode")),phoneNumber:r().required(i("ERRORS.phoneNumber")),image:h().test("image",i("ERRORS.isRequired",{name:i("LABELS.image")}),o=>{if(o||a.preview)return!0})});function w(o){d.value=!0;const e=new FormData;a.image&&e.append("image",a.image),e.append("_method","PUT"),e.append("full_name",o.name),e.append("phone",o.phoneNumber),e.append("phone_code",o.phoneCode.phone_code),e.append("email",o.email),v({method:"POST",url:"profile/update",data:e}).then(l=>{S.success(l.data.message);const n=l.data.data;a.name=n.full_name,a.email=n.email,a.phoneNumber=n.phone,a.phoneCode=n.phone_code,a.preview=n.image,a.image="",c.userData=n,d.value=!1}).catch(l=>{d.value=!1,S.error(l.response.data.message)})}function E(){v({method:"GET",url:"profile"}).then(o=>{const e=o.data.data;localStorage.setItem("ngt_global_user_data",JSON.stringify(e)),a.name=e.full_name,a.email=e.email,a.phoneNumber=e.phone,a.phoneCode=e.country,c.userData=e,a.preview=e.image??e.logo,u.value=!1})}return U(()=>{E()}),(o,e)=>{const l=s("FormSkelton"),n=s("base-file"),A=s("base-input"),B=s("base-phone"),C=s("VeeForm"),R=s("base-card1");return u.value?(b(),f(l,{key:0})):(b(),f(R,{key:1,title:o.$t("TITLES.Account Information")},{default:_(()=>[p(C,{as:"div","validation-schema":I(L),onSubmit:w,"initial-values":a},{default:_(()=>[t("form",$,[t("div",x,[t("div",F,[p(n,{modalName:"users",modalType:"image",id:"image",name:"image",placeholder:o.$t("LABELS.image"),label:"",itemValue:a.preview,"onUpdate:itemValue":e[0]||(e[0]=m=>a.preview=m),image:a.image,"onUpdate:image":e[1]||(e[1]=m=>a.image=m),accept:"image/png, image/webp, image/jpeg",no_preview:!0},null,8,["placeholder","itemValue","image"]),t("label",{for:"image",class:T(["w-10 h-10 bg-main rounded-full flex justify-center items-center absolute bottom-2",o.$i18n.locale=="en"?"left-[120px]":"right-[120px]"])},e[3]||(e[3]=[t("img",{class:"!object-contain",src:J,alt:"solar icon"},null,-1)]),2)]),p(A,{id:"name",name:"name",placeholder:o.$t("LABELS.name"),label:o.$t("LABELS.name"),type:"text"},null,8,["placeholder","label"]),p(A,{id:"email",name:"email",placeholder:o.$t("LABELS.email"),label:o.$t("LABELS.email"),type:"text"},null,8,["placeholder","label"]),p(B,{id:"phoneNumber",name:"phoneNumber",url:"countries-without-paginated",placeholder:o.$t("LABELS.phone"),phoneCode:"phoneCode",phone_code:a.phoneCode,"onUpdate:phone_code":e[2]||(e[2]=m=>a.phoneCode=m)},null,8,["placeholder","phone_code"])]),t("div",Y,[t("button",{type:"submit",class:"h-[57px] bg-main !text-white w-full lg:w-[165px] rounded-[10px] disabled:opacity-60 disabled:cursor-not-allowed",disabled:d.value},D(o.$t("BUTTONS.save")),9,k)])])]),_:1},8,["validation-schema","initial-values"])]),_:1},8,["title"]))}}};export{X as default};
