import{t as e}from"./axios-DHQprbt3.js";import{E as t,M as n,c as r,ct as i,d as a,i as o,t as s,u as c,w as l}from"./_plugin-vue_export-helper-Conii5fq.js";import{a as u,c as d}from"./runtime-dom.esm-bundler-CI28bPhn.js";var f={data(){return{eventTypes:[],eventTypeData:{caption:``},editMode:!1,editId:null}},methods:{async fetchEventTypes(){try{this.eventTypes=(await e.get(`/event-types`)).data}catch(e){console.error(`Fehler beim Abrufen der Event-Typen:`,e)}},async saveEventType(){try{if(this.editMode)await e.put(`/event-types/${this.editId}`,this.eventTypeData);else{let t=await e.post(`/event-types`,this.eventTypeData);this.eventTypes.push(t.data)}this.resetForm(),await this.fetchEventTypes()}catch(e){console.error(`Fehler beim Speichern des Event-Typs:`,e)}},editEventType(e){this.eventTypeData={...e},this.editMode=!0,this.editId=e.id},async deleteEventType(t){try{await e.delete(`/event-types/${t}`),await this.fetchEventTypes()}catch(e){console.error(`Fehler beim Löschen des Event-Typs:`,e)}},resetForm(){this.eventTypeData={caption:``},this.editMode=!1,this.editId=null}},async created(){await this.fetchEventTypes()}},p={class:`event-types-management`},m={type:`submit`},h=[`onClick`],g=[`onClick`];function _(e,s,f,_,v,y){return l(),a(`div`,p,[s[4]||=r(`h2`,null,`Event-Typen Verwaltung`,-1),r(`form`,{onSubmit:s[2]||=d((...e)=>y.saveEventType&&y.saveEventType(...e),[`prevent`])},[s[3]||=r(`label`,{for:`newEventType`},`Event-Typ:`,-1),n(r(`input`,{type:`text`,id:`newEventType`,"onUpdate:modelValue":s[0]||=e=>v.eventTypeData.caption=e,placeholder:`Event-Typ`,required:``},null,512),[[u,v.eventTypeData.caption]]),r(`button`,m,i(v.editMode?`Aktualisieren`:`Hinzufügen`),1),v.editMode?(l(),a(`button`,{key:0,type:`button`,onClick:s[1]||=(...e)=>y.resetForm&&y.resetForm(...e)},`Abbrechen`)):c(``,!0)],32),r(`table`,null,[(l(!0),a(o,null,t(v.eventTypes,e=>(l(),a(`tr`,{key:e.id},[r(`td`,null,i(e.caption),1),r(`td`,null,[r(`button`,{onClick:t=>y.editEventType(e)},`Bearbeiten`,8,h)]),r(`td`,null,[r(`button`,{onClick:t=>y.deleteEventType(e.id)},`Löschen`,8,g)])]))),128))])])}var v=s(f,[[`render`,_],[`__scopeId`,`data-v-76d51395`]]);export{v as default};
//# sourceMappingURL=EventTypesManagement-BHPLrWT6.js.map