birzha-legalizasia-frontend/dist/assets/Main.12de8e25.js

2 lines
4.8 KiB
JavaScript

import{a as V,s as D,q as O,K as U,J as p,N as P,r as b,e as d,f as e,t as r,g as I,h as s,j as u,O as h,P as v,n as w,F as g,i as E,M as q,l as C,E as F,c as n}from"./index.91bacc32.js";import{c as _,r as N,m as $,u as B}from"./index.esm.823d60a9.js";const G={class:"intro-y flex items-center mt-8"},H={class:"text-lg font-medium mr-auto"},j={class:"grid grid-cols-12 gap-6"},Q={class:"col-span-12 lg:col-span-4 2xl:col-span-3 flex lg:block flex-col-reverse"},W={class:"intro-y box mt-5"},z={class:"relative flex items-center p-5"},J={class:"w-12 h-12"},K={class:"ml-4 mr-auto"},X={key:0,class:"font-medium text-base"},Y={class:"col-span-12 lg:col-span-8 2xl:col-span-9"},Z={class:"intro-y box mt-5"},ee={class:"flex items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400"},se={class:"font-medium text-base mr-auto"},te={class:"p-5"},oe={class:"grid grid-cols-12 gap-x-5"},ae={class:"col-span-12 xl:col-span-6"},re={for:"update-profile-form-1",class:"form-label"},le=["placeholder"],ne={class:"mt-3"},ie={for:"update-profile-form-2",class:"form-label"},de=["placeholder"],ce={class:"col-span-12 xl:col-span-6"},me={for:"update-profile-form-3",class:"form-label"},pe=["placeholder"],ue={class:"mt-3 xl:mt-3"},_e={for:"update-profile-form-4",class:"form-label"},fe={class:"relative"},he=["placeholder"],ve={class:"flex justify-end mt-4"},ge=["onClick","disabled"],$e={__name:"Main",setup(be){const y=V(),{user:c}=D(y);console.log("user state: ",c.value);const f=O(!1),i=U({firstname:c.value.firstname,lastname:c.value.lastname,email:c.value.email,password:""}),A={firstname:{required:_.withMessage(p.global.t("REQUIRED_VALIDATION"),N),minLength:_.withMessage(p.global.t("MIN_LENGTH_VALIDATION",{min:2}),$(2))},lastname:{required:_.withMessage(p.global.t("REQUIRED_VALIDATION"),N),minLength:_.withMessage(p.global.t("MIN_LENGTH_VALIDATION",{min:2}),$(2))},password:{minLength:_.withMessage(p.global.t("MIN_LENGTH_VALIDATION",{min:8}),$(8))}},t=B(A,P(i)),L=()=>{document.querySelector("input[name='password']").type="text"},x=()=>{document.querySelector("input[name='password']").type="password"},M=()=>i.password==="",T=async()=>{if(t.value.$touch(),!t.value.$invalid){let o={firstname:i.firstname,lastname:i.lastname},l=M()?{}:{password:i.password};f.value=!0,await y.updateClient({...o,...l}),f.value=!1,i.password=""}};return(o,l)=>{const k=b("UserIcon"),R=b("EyeIcon"),S=b("LoadingIcon");return n(),d(g,null,[e("div",G,[e("h2",H,r(o.$t("UPDATE_PROFILE")),1)]),e("div",j,[e("div",Q,[e("div",W,[e("div",z,[e("div",J,[I(k,{class:"text-dark w-12 h-12"})]),e("div",K,[s(c)?(n(),d("div",X,r(s(c).firstname)+" "+r(s(c).lastname),1)):u("",!0)])])])]),e("div",Y,[e("div",Z,[e("div",ee,[e("h2",se,r(o.$t("PERSONAL_INFO")),1)]),e("div",te,[e("div",oe,[e("div",ae,[e("div",null,[e("label",re,r(o.$t("FIRSTNAME")),1),h(e("input",{id:"update-profile-form-1",type:"text","onUpdate:modelValue":l[0]||(l[0]=a=>s(t).firstname.$model=a),class:w([{"border-danger":s(t).firstname.$error},"form-control"]),placeholder:o.$t("ENTER_FIRSTNAME")},null,10,le),[[v,s(t).firstname.$model,void 0,{trim:!0}]]),s(t).firstname.$error?(n(!0),d(g,{key:0},E(s(t).firstname.$errors,(a,m)=>(n(),d("div",{key:m,class:"text-danger mt-2"},r(a.$message),1))),128)):u("",!0)]),e("div",ne,[e("label",ie,r(o.$t("LASTNAME")),1),h(e("input",{id:"update-profile-form-2",type:"text","onUpdate:modelValue":l[1]||(l[1]=a=>s(t).lastname.$model=a),class:w([{"border-danger":s(t).lastname.$error},"form-control"]),placeholder:o.$t("ENTER_LASTNAME")},null,10,de),[[v,s(t).lastname.$model,void 0,{trim:!0}]]),s(t).lastname.$error?(n(!0),d(g,{key:0},E(s(t).lastname.$errors,(a,m)=>(n(),d("div",{key:m,class:"text-danger mt-2"},r(a.$message),1))),128)):u("",!0)])]),e("div",ce,[e("div",null,[e("label",me,r(o.$t("EMAIL")),1),h(e("input",{id:"update-profile-form-3",type:"text","onUpdate:modelValue":l[2]||(l[2]=a=>i.email=a),class:"form-control",placeholder:o.$t("ENTER_EMAIL"),disabled:""},null,8,pe),[[v,i.email,void 0,{trim:!0}]])]),e("div",ue,[e("label",_e,r(o.$t("PASSWORD")),1),e("div",fe,[h(e("input",{id:"update-profile-form-4",type:"password","onUpdate:modelValue":l[3]||(l[3]=a=>s(t).password.$model=a),class:w([{"border-danger":s(t).password.$error},"form-control"]),name:"password",placeholder:o.$t("ENTER_PASSWORD")},null,10,he),[[v,s(t).password.$model,void 0,{trim:!0}]]),I(R,{class:"block mx-auto absolute top-1/2 transform -translate-y-1/2 right-3 text-slate-400 cursor-pointer",onMousedown:L,onMouseup:x})]),s(t).password.$error?(n(!0),d(g,{key:0},E(s(t).password.$errors,(a,m)=>(n(),d("div",{key:m,class:"text-danger mt-2"},r(a.$message),1))),128)):u("",!0)])])]),e("div",ve,[e("button",{type:"button",class:"btn btn-primary w-20 mr-auto",onClick:q(T,["prevent"]),disabled:f.value},[C(r(o.$t("SAVE"))+" ",1),f.value?(n(),F(S,{key:0,icon:"oval",color:"white",class:"w-4 h-4 ml-2"})):u("",!0)],8,ge)])])])])])],64)}}};export{$e as default};