"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[8183],{8183:function(e,r,t){t.r(r),t.d(r,{default:function(){return y}});var s=t(6768),n=t(5187),a=t(5688);const i=e=>((0,s.Qi)("data-v-a495c756"),e=e(),(0,s.jt)(),e),u={class:"user-administration"},l=i((()=>(0,s.Lk)("h1",null,"Benutzerverwaltung",-1))),o=i((()=>(0,s.Lk)("label",{for:"name"},"Name:",-1))),c=i((()=>(0,s.Lk)("label",{for:"email"},"Email:",-1))),d=i((()=>(0,s.Lk)("label",{for:"password"},"Passwort:",-1))),m=["required"],h=i((()=>(0,s.Lk)("label",{for:"active"},"Aktiv:",-1))),p={type:"submit"},U={key:1},k=i((()=>(0,s.Lk)("h2",null,"Vorhandene Benutzer",-1))),v=["onClick"];function b(e,r,t,i,b,C){return(0,s.uX)(),(0,s.CE)("div",u,[l,(0,s.Lk)("h2",null,(0,n.v_)(C.formTitle),1),(0,s.Lk)("form",{onSubmit:r[4]||(r[4]=(0,a.D$)(((...e)=>C.saveUser&&C.saveUser(...e)),["prevent"]))},[o,(0,s.bo)((0,s.Lk)("input",{id:"name","onUpdate:modelValue":r[0]||(r[0]=e=>b.currentUser.name=e),required:""},null,512),[[a.Jo,b.currentUser.name]]),c,(0,s.bo)((0,s.Lk)("input",{id:"email","onUpdate:modelValue":r[1]||(r[1]=e=>b.currentUser.email=e),type:"email",required:""},null,512),[[a.Jo,b.currentUser.email]]),d,(0,s.bo)((0,s.Lk)("input",{id:"password","onUpdate:modelValue":r[2]||(r[2]=e=>b.currentUser.password=e),type:"password",required:b.isCreating},null,8,m),[[a.Jo,b.currentUser.password]]),(0,s.Lk)("div",null,[h,(0,s.bo)((0,s.Lk)("input",{id:"active","onUpdate:modelValue":r[3]||(r[3]=e=>b.currentUser.active=e),type:"checkbox"},null,512),[[a.lH,b.currentUser.active]])]),(0,s.Lk)("button",p,(0,n.v_)(b.isCreating?"Erstellen":"Aktualisieren"),1)],32),b.isCreating?(0,s.Q3)("",!0):((0,s.uX)(),(0,s.CE)("button",{key:0,onClick:r[5]||(r[5]=(...e)=>C.resetForm&&C.resetForm(...e))},"Zurück zu Benutzer erstellen")),b.users.length?((0,s.uX)(),(0,s.CE)("div",U,[k,(0,s.Lk)("ul",null,[((0,s.uX)(!0),(0,s.CE)(s.FK,null,(0,s.pI)(b.users,(e=>((0,s.uX)(),(0,s.CE)("li",{key:e.id,onClick:r=>C.editUser(e)},(0,n.v_)(e.name)+" ("+(0,n.v_)(e.email)+") ",9,v)))),128))])])):(0,s.Q3)("",!0)])}var C=t(3173),f={name:"UserAdministration",data(){return{users:[],currentUser:{name:"",email:"",password:"",active:!1},isCreating:!0}},computed:{formTitle(){return this.isCreating?"Benutzer erstellen":"Benutzer bearbeiten"}},methods:{async fetchUsers(){try{const e=await C.A.get("/users");this.users=e.data}catch(e){console.error("Fehler beim Abrufen der Benutzer:",e)}},async saveUser(){this.isCreating?await this.createUser():await this.updateUser(),this.resetForm(),this.fetchUsers()},async createUser(){try{await C.A.post("/users",this.currentUser)}catch(e){console.error("Fehler beim Erstellen des Benutzers:",e)}},async updateUser(){try{await C.A.put(`/users/${this.currentUser.id}`,this.currentUser)}catch(e){console.error("Fehler beim Aktualisieren des Benutzers:",e)}},editUser(e){this.currentUser={...e,password:""},this.isCreating=!1},resetForm(){this.currentUser={name:"",email:"",password:"",active:!1},this.isCreating=!0}},mounted(){this.fetchUsers()}},w=t(1241);const L=(0,w.A)(f,[["render",b],["__scopeId","data-v-a495c756"]]);var y=L}}]); //# sourceMappingURL=8183.73935aeb.js.map