mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
5.0 KiB
JavaScript
2 lines
5.0 KiB
JavaScript
import{G as R,J as G,B as p,k as C,L as c,M as k,N as S,Q as L,P,T as A,r as v,o as g,e as D,f as u,w as i,h as _,t as h,u as e,x as b,l as y,m as O,j as T,i as z,U as J}from"./vendor.d12b5734.js";import{a as Q,u as H}from"./global.1ac91de5.js";import"./auth.a07e0850.js";import"./main.c7bd6c0e.js";const K=["onSubmit"],W={class:"font-bold text-left"},X={class:"mt-2 text-sm leading-snug text-left text-gray-500",style:{"max-width":"680px"}},Y={class:"grid gap-6 sm:grid-col-1 md:grid-cols-2 mt-6"},Z=_("span",null,null,-1),te={setup(ee){const r=Q();H(),R();const{t:m,tm:U}=G();let f=p([]),d=p(!1),w=p(null),n=p(!1),l=p(!1);const I=p(!1);r.userForm.avatar&&f.value.push({image:r.userForm.avatar});const x=C(()=>({userForm:{name:{required:c.withMessage(m("validation.required"),k),minLength:c.withMessage(m("validation.name_min_length",{count:3}),S(3))},email:{required:c.withMessage(m("validation.required"),k),email:c.withMessage(m("validation.email_incorrect"),L)},password:{minLength:c.withMessage(m("validation.password_min_length",{count:8}),S(8))},confirm_password:{sameAsPassword:c.withMessage(m("validation.password_incorrect"),P(r.userForm.password))}}})),o=A(x,C(()=>r));function M(t,s){w.value=s}function q(){w.value=null,I.value=!0}function N(){if(o.value.userForm.$touch(),o.value.userForm.$invalid)return!0;d.value=!0;let t=new FormData;t.append("name",r.userForm.name),t.append("email",r.userForm.email),r.userForm.password!=null&&r.userForm.password!==void 0&&r.userForm.password!==""&&t.append("password",r.userForm.password),w.value&&t.append("customer_avatar",w.value),t.append("is_customer_avatar_removed",I.value),r.updateCurrentUser({data:t,message:U("settings.account_settings.updated_message")}).then(s=>{s.data.data&&(d.value=!1,r.$patch(B=>{B.userForm.password="",B.userForm.confirm_password=""}),w.value=null,I.value=!1)}).catch(s=>{d.value=!1})}return(t,s)=>{const B=v("BaseFileUploader"),F=v("BaseInputGroup"),V=v("BaseInput"),$=v("BaseIcon"),j=v("BaseButton"),E=v("BaseCard");return g(),D("form",{class:"relative h-full mt-4",onSubmit:J(N,["prevent"])},[u(E,null,{default:i(()=>[_("div",null,[_("h6",W,h(t.$t("settings.account_settings.account_settings")),1),_("p",X,h(t.$t("settings.account_settings.section_description")),1)]),_("div",Y,[u(F,{label:t.$tc("settings.account_settings.profile_picture")},{default:i(()=>[u(B,{modelValue:e(f),"onUpdate:modelValue":s[0]||(s[0]=a=>b(f)?f.value=a:f=a),avatar:!0,accept:"image/*",onChange:M,onRemove:q},null,8,["modelValue"])]),_:1},8,["label"]),Z,u(F,{label:t.$tc("settings.account_settings.name"),error:e(o).userForm.name.$error&&e(o).userForm.name.$errors[0].$message,required:""},{default:i(()=>[u(V,{modelValue:e(r).userForm.name,"onUpdate:modelValue":s[1]||(s[1]=a=>e(r).userForm.name=a),invalid:e(o).userForm.name.$error,onInput:s[2]||(s[2]=a=>e(o).userForm.name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),u(F,{label:t.$tc("settings.account_settings.email"),error:e(o).userForm.email.$error&&e(o).userForm.email.$errors[0].$message,required:""},{default:i(()=>[u(V,{modelValue:e(r).userForm.email,"onUpdate:modelValue":s[3]||(s[3]=a=>e(r).userForm.email=a),invalid:e(o).userForm.email.$error,onInput:s[4]||(s[4]=a=>e(o).userForm.email.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),u(F,{error:e(o).userForm.password.$error&&e(o).userForm.password.$errors[0].$message,label:t.$tc("settings.account_settings.password")},{default:i(()=>[u(V,{modelValue:e(r).userForm.password,"onUpdate:modelValue":s[7]||(s[7]=a=>e(r).userForm.password=a),type:e(n)?"text":"password",invalid:e(o).userForm.password.$error,onInput:s[8]||(s[8]=a=>e(o).userForm.password.$touch())},{right:i(()=>[e(n)?(g(),y($,{key:0,name:"EyeOffIcon",class:"w-5 h-5 mr-1 text-gray-500 cursor-pointer",onClick:s[5]||(s[5]=a=>b(n)?n.value=!e(n):n=!e(n))})):(g(),y($,{key:1,name:"EyeIcon",class:"w-5 h-5 mr-1 text-gray-500 cursor-pointer",onClick:s[6]||(s[6]=a=>b(n)?n.value=!e(n):n=!e(n))}))]),_:1},8,["modelValue","type","invalid"])]),_:1},8,["error","label"]),u(F,{label:t.$tc("settings.account_settings.confirm_password"),error:e(o).userForm.confirm_password.$error&&e(o).userForm.confirm_password.$errors[0].$message},{default:i(()=>[u(V,{modelValue:e(r).userForm.confirm_password,"onUpdate:modelValue":s[11]||(s[11]=a=>e(r).userForm.confirm_password=a),type:e(l)?"text":"password",invalid:e(o).userForm.confirm_password.$error,onInput:s[12]||(s[12]=a=>e(o).userForm.confirm_password.$touch())},{right:i(()=>[e(l)?(g(),y($,{key:0,name:"EyeOffIcon",class:"w-5 h-5 mr-1 text-gray-500 cursor-pointer",onClick:s[9]||(s[9]=a=>b(l)?l.value=!e(l):l=!e(l))})):(g(),y($,{key:1,name:"EyeIcon",class:"w-5 h-5 mr-1 text-gray-500 cursor-pointer",onClick:s[10]||(s[10]=a=>b(l)?l.value=!e(l):l=!e(l))}))]),_:1},8,["modelValue","type","invalid"])]),_:1},8,["label","error"])]),u(j,{loading:e(d),disabled:e(d),class:"mt-6"},{left:i(a=>[e(d)?T("",!0):(g(),y($,{key:0,name:"SaveIcon",class:O(a.class)},null,8,["class"]))]),default:i(()=>[z(" "+h(t.$t("general.save")),1)]),_:1},8,["loading","disabled"])]),_:1})],40,K)}}};export{te as default};
|