import{e as y,b as w}from"./primevue-CfIk0_DY.js";import{u as C,s as a,n as _,L as k,b as M}from"./index-BxIwIJfy.js";import{b as V,c as h,d as t,t as l,v as r,y as c,E as N,a as E}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const U={class:"max-w-3xl mx-auto"},B={class:"bg-white rounded-xl shadow-sm p-6",style:{"margin-bottom":"20px"}},P={class:"grid grid-cols-1 sm:grid-cols-2 gap-4"},D={class:"font-medium text-gray-800"},$={class:"font-medium text-gray-800"},z={class:"bg-white rounded-xl shadow-sm p-6",style:{"margin-bottom":"20px"}},I={class:"grid grid-cols-1 sm:grid-cols-2 gap-4"},L={class:"font-medium text-gray-800"},S={class:"font-medium text-gray-800"},A={class:"font-medium text-gray-800"},R={class:"bg-white rounded-xl shadow-sm p-6"},q={class:"grid grid-cols-1 sm:grid-cols-3 gap-3 items-end"},F={class:"field"},G={class:"field"},O={class:"field"},T={style:{"margin-top":"12px"}},Y={__name:"PortailCabinetProfil",setup(W){const{showSuccess:p,showError:g,showWarn:d}=C(),f=c(()=>a.state.portailCabinetSociete||{}),i=c(()=>a.state.portailCabinetContact||{}),v=c(()=>a.state.portailCabinetNomCabinet||""),e=N({ancien:"",nouveau:"",confirme:""}),u=E(!1),b=async()=>{if(!e.ancien||!e.nouveau){d("Veuillez remplir tous les champs.");return}const n=_(e.nouveau,{mail:i.value?.email});if(n.niveau==="critique"||n.niveau==="faible"){d(n.raisons[0]||`Choisissez un mot de passe d'au moins ${k} caracteres melant lettres et chiffres.`);return}if(e.nouveau!==e.confirme){d("La confirmation ne correspond pas.");return}u.value=!0;try{await M.post(`${a.lienApi}/portail-cabinet/change-password`,{ancien:e.ancien,nouveau:e.nouveau},{headers:{Authorization:`Bearer ${a.state.portailCabinetToken}`}}),p("Mot de passe modifie avec succes."),e.ancien=e.nouveau=e.confirme=""}catch(s){g(s.response?.data?.message||"Erreur lors de la modification.")}finally{u.value=!1}};return(n,s)=>{const m=y,x=w;return V(),h("div",U,[s[14]||(s[14]=t("h1",{class:"text-2xl font-bold text-gray-800",style:{"margin-bottom":"16px"}},"Mon profil",-1)),t("div",B,[s[5]||(s[5]=t("h2",{class:"text-lg font-bold text-gray-800",style:{"margin-bottom":"12px"}},"Ma societe",-1)),t("div",P,[t("div",null,[s[3]||(s[3]=t("div",{class:"text-gray-400"},"Raison sociale",-1)),t("div",D,l(f.value.Nom||"—"),1)]),t("div",null,[s[4]||(s[4]=t("div",{class:"text-gray-400"},"Cabinet comptable",-1)),t("div",$,l(v.value||"—"),1)])])]),t("div",z,[s[9]||(s[9]=t("h2",{class:"text-lg font-bold text-gray-800",style:{"margin-bottom":"12px"}},"Mon compte",-1)),t("div",I,[t("div",null,[s[6]||(s[6]=t("div",{class:"text-gray-400"},"Nom",-1)),t("div",L,l(i.value.nom_contact||"—"),1)]),t("div",null,[s[7]||(s[7]=t("div",{class:"text-gray-400"},"Fonction",-1)),t("div",S,l(i.value.fonction||"—"),1)]),t("div",null,[s[8]||(s[8]=t("div",{class:"text-gray-400"},"Email",-1)),t("div",A,l(i.value.email||"—"),1)])])]),t("div",R,[s[13]||(s[13]=t("h2",{class:"text-lg font-bold text-gray-800",style:{"margin-bottom":"12px"}},"Changer mon mot de passe",-1)),t("div",q,[t("div",F,[s[10]||(s[10]=t("label",{class:"block mb-1"},"Mot de passe actuel",-1)),r(m,{modelValue:e.ancien,"onUpdate:modelValue":s[0]||(s[0]=o=>e.ancien=o),feedback:!1,toggleMask:"",inputClass:"w-full",class:"w-full"},null,8,["modelValue"])]),t("div",G,[s[11]||(s[11]=t("label",{class:"block mb-1"},"Nouveau mot de passe",-1)),r(m,{modelValue:e.nouveau,"onUpdate:modelValue":s[1]||(s[1]=o=>e.nouveau=o),feedback:!1,toggleMask:"",inputClass:"w-full",class:"w-full"},null,8,["modelValue"])]),t("div",O,[s[12]||(s[12]=t("label",{class:"block mb-1"},"Confirmer",-1)),r(m,{modelValue:e.confirme,"onUpdate:modelValue":s[2]||(s[2]=o=>e.confirme=o),feedback:!1,toggleMask:"",inputClass:"w-full",class:"w-full"},null,8,["modelValue"])])]),t("div",T,[r(x,{label:"Modifier",icon:"pi pi-lock",loading:u.value,onClick:b},null,8,["loading"])])])])}}};export{Y as default};
