1import{_ as x,F as C}from"./Cy2I-V-Q.js";import{e as U,f as k,J as B,l as d,K as M,n as S,p as u,a2 as $,c as w,a as r,b as c,t as _,g as s,w as y,o as g,s as N,d as E,H as F,X as I}from"./DAxAtgHJ.js";import"./DJrdVCdT.js";const P={class:"flex flex-col gap-6"},T={class:"font-bold text-primary-300"},q={class:"grid md:grid-cols-2 gap-4"},z={class:"pt-4"},A=["disabled"],D={key:0,class:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24"},O=U({__name:"edit-auth",setup(H){const{t}=k(),m=B(),p=d(null),f=d(null),i=d(!1);M(()=>{const e=m.user;e&&(l.value={...l.value,email:e.email})});function b(e){console.log(e)}function v(e){var n;p.value=null,f.value=null,i.value=!0;const a={first_name:e.first_name,last_name:e.last_name,email:e.email,password:e.password,birthdate:e.birthdate,phone:e.phone,optin_mail:e.optin_mail,school:e.school,language:e.language};e.password&&(a.password=e.password),F(`/users/${(n=m.user)==null?void 0:n.id}`,{},{method:"PUT",body:a}).then(({data:o})=>{const h=o.value;if(h)m.setUser(h),f.value="Modifications enregistrées avec succès",I({name:"account"});else throw new Error("Une erreur s'est produite")}).catch(o=>{p.value=o}).finally(()=>{i.value=!1})}const l=d({first_name:"",last_name:"",email:"",password:"",confirm_password:"",birthdate:"",phone:"",optin_mail:!1,school:"",language:"fr"}),V=S({email:u().email().required(),password:u().nullable(),confirm_password:u().when("password",{is:e=>e&&e.length>0,then:e=>e.oneOf([$("password")],t("errors.confirmPassword")).required(),otherwise:e=>e.nullable()})});return(e,a)=>{const n=x;return g(),w("div",P,[r("h3",T,_(s(t)("auth.modify.title")),1),c(s(C),{onSubmit:v,onInvalidSubmit:b,"validation-schema":s(V)},{default:y(()=>[r("div",q,[c(n,{modelValue:s(l).email,"onUpdate:modelValue":a[0]||(a[0]=o=>s(l).email=o),name:"email",type:"email",label:s(t)("fields.email"),class:"flex-col md:col-span-2"},null,8,["modelValue","label"]),c(n,{modelValue:s(l).password,"onUpdate:modelValue":a[1]||(a[1]=o=>s(l).password=o),name:"password",type:"password",label:s(t)("fields.password"),placeholder:"Laisser vide pour ne pas modifier",class:"flex-col"},null,8,["modelValue","label"]),c(n,{modelValue:s(l).confirm_password,"onUpdate:modelValue":a[2]||(a[2]=o=>s(l).confirm_password=o),name:"confirm_password",type:"password",label:s(t)("fields.confirmPassword"),placeholder:"Confirmer si modifié",class:"flex-col"},null,8,["modelValue","label"])]),r("div",z,[r("button",{type:"submit",disabled:s(i),class:"btn-action"},[s(i)?(g(),w("svg",D,a[3]||(a[3]=[r("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),r("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)]))):N("",!0),E(" "+_(s(i)?"Enregistrement...":s(t)("auth.modify.saveChanges")),1)],8,A)])]),_:1},8,["validation-schema"])])}}});export{O 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.