import{u as N,m as T,q as A,t as v,s as D,c as H,v as I,L as M,r as p,o as u,a as b,k as w,e as t,b as g,f as l,l as V,F as B,d as m,x as z,y as G}from"./app-44623493.js";const J={class:"grid grid-cols-3 gap-6"},K={class:"col-span-3 sm:col-span-1"},Q={class:"grid grid-cols-3 gap-6"},W={class:"col-span-3 sm:col-span-1"},X={key:0,class:"col-span-3 sm:col-span-1"},Y={class:"col-span-3 sm:col-span-1"},Z={class:"col-span-3 sm:col-span-1"},_={class:"col-span-3 sm:col-span-1"},h={class:"col-span-3 sm:col-span-1"},ee={name:"EmployeeEditLogin"},se=Object.assign(ee,{props:{employee:{type:Object,default(){return{}}}},setup(d){const $=d,k=N(),S=T(),q=A("emitter"),c={username:"",email:"",password:"",passwordConfirmation:"",roles:[]},U="employee/",j="user/",C=v({}),r=D(U),y=H(()=>$.employee.contact.user),n=v({isValidated:!1,existingUser:null}),a=v({...c}),F=s=>{Object.assign(C,s)},P=s=>{n.isValidated=!0,n.existingUser=s||null,a.username=s==null?void 0:s.username},R=()=>{q.emit("employeeUpdated"),S.push({name:"EmployeeShowLogin",params:{uuid:$.employee.uuid}})};return I(async()=>{var s,e,f;n.isValidated=!!y.value,n.existingUser=y.value,Object.assign(c,{username:(s=y.value)==null?void 0:s.username,email:(e=y.value)==null?void 0:e.email,roles:((f=y.value)==null?void 0:f.roles.map(i=>i.uuid))||[]}),Object.assign(a,M(c))}),(s,e)=>{const f=p("PageHeader"),i=p("BaseInput"),O=p("BaseButton"),E=p("FormAction"),x=p("BaseSelect"),L=p("ParentTransition");return u(),b(B,null,[d.employee.uuid?(u(),w(f,{key:0,title:s.$trans(t(k).meta.trans,{attribute:s.$trans(t(k).meta.label)}),navs:[{label:s.$trans("employee.employee"),path:"Employee"},{label:d.employee.contact.name,path:{name:"EmployeeShow",params:{uuid:d.employee.uuid}}}]},null,8,["title","navs"])):g("",!0),l(L,{appear:"",visibility:!0},{default:V(()=>[d.employee.uuid?(u(),b(B,{key:0},[n.isValidated?(u(),w(E,{key:1,"no-data-fetch":"","pre-requisites":!0,"pre-requisite-url":j,onSetPreRequisites:F,"init-url":U,action:n.existingUser?"updateUser":"createUser","init-form":c,form:a,"after-submit":R},{default:V(()=>[m("div",Q,[m("div",W,[l(i,{readonly:"",disabled:"",type:"text",modelValue:a.email,"onUpdate:modelValue":e[2]||(e[2]=o=>a.email=o),name:"email",label:s.$trans("contact.login.props.email"),error:t(r).email,"onUpdate:error":e[3]||(e[3]=o=>t(r).email=o)},null,8,["modelValue","label","error"])]),n.existingUser?(u(),b("div",X,[l(i,{readonly:"",disabled:"",type:"text",modelValue:a.username,"onUpdate:modelValue":e[4]||(e[4]=o=>a.username=o),name:"username",label:s.$trans("contact.login.props.username"),error:t(r).username,"onUpdate:error":e[5]||(e[5]=o=>t(r).username=o)},null,8,["modelValue","label","error"])])):g("",!0),n.existingUser?g("",!0):(u(),b(B,{key:1},[m("div",Y,[l(i,{type:"text",modelValue:a.username,"onUpdate:modelValue":e[6]||(e[6]=o=>a.username=o),name:"username",label:s.$trans("contact.login.props.username"),error:t(r).username,"onUpdate:error":e[7]||(e[7]=o=>t(r).username=o)},null,8,["modelValue","label","error"])]),m("div",Z,[l(i,{type:"password",modelValue:a.password,"onUpdate:modelValue":e[8]||(e[8]=o=>a.password=o),name:"password",label:s.$trans("contact.login.props.password"),error:t(r).password,"onUpdate:error":e[9]||(e[9]=o=>t(r).password=o)},null,8,["modelValue","label","error"])]),m("div",_,[l(i,{type:"password",modelValue:a.passwordConfirmation,"onUpdate:modelValue":e[10]||(e[10]=o=>a.passwordConfirmation=o),name:"passwordConfirmation",label:s.$trans("contact.login.props.password_confirmation"),error:t(r).passwordConfirmation,"onUpdate:error":e[11]||(e[11]=o=>t(r).passwordConfirmation=o)},null,8,["modelValue","label","error"])])],64)),m("div",h,[l(x,{modelValue:a.roles,"onUpdate:modelValue":e[12]||(e[12]=o=>a.roles=o),name:"roles",label:s.$trans("contact.login.props.role"),options:C.roles,multiple:"","label-prop":"label","value-prop":"uuid",error:t(r).roles,"onUpdate:error":e[13]||(e[13]=o=>t(r).roles=o)},null,8,["modelValue","label","options","error"])])])]),_:1},8,["action","form"])):(u(),w(E,{key:0,"no-action-button":"","no-data-fetch":"","init-url":U,action:"confirmUser","init-form":c,form:a,"after-submit":P,"stay-on":"",redirect:{name:"EmployeeShowLogin",params:{uuid:d.employee.uuid}}},{default:V(()=>[m("div",J,[m("div",K,[l(i,{type:"text",modelValue:a.email,"onUpdate:modelValue":e[0]||(e[0]=o=>a.email=o),name:"email",label:s.$trans("contact.login.props.email"),error:t(r).email,"onUpdate:error":e[1]||(e[1]=o=>t(r).email=o)},null,8,["modelValue","label","error"])])]),l(O,{class:"mt-4",type:"submit"},{default:V(()=>[z(G(s.$trans("general.validate")),1)]),_:1})]),_:1},8,["form","redirect"]))],64)):g("",!0)]),_:1})],64)}}});export{se as default};
