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{eventPlaces:[],newEventPlace:{name:``,street:``,zipcode:``,city:``,backgroundColor:`#ffffff`,website:``},editMode:!1,editId:null}},methods:{async fetchEventPlaces(){this.eventPlaces=(await e.get(`/event-places`)).data},async addEventPlace(){if(this.editMode)await e.put(`/event-places/${this.editId}`,this.newEventPlace);else{let t=await e.post(`/event-places`,this.newEventPlace);this.eventPlaces.push(t.data)}this.resetForm(),await this.fetchEventPlaces()},async updateEventPlace(t){await e.put(`/event-places/${t.id}`,t),this.fetchEventPlaces()},async deleteEventPlace(t){await e.delete(`/event-places/${t}`),this.fetchEventPlaces()},editEventPlace(e){this.newEventPlace={...e},this.editMode=!0,this.editId=e.id},resetForm(){this.newEventPlace={name:``,street:``,zipcode:``,city:``,backgroundColor:`#ffffff`,website:``},this.editMode=!1,this.editId=null}},created(){this.fetchEventPlaces()}},p={class:`event-places-management`},m=[`onClick`],h=[`onClick`];function g(e,s,f,g,_,v){return l(),a(`div`,p,[s[16]||=r(`h2`,null,`Veranstaltungsorte verwalten`,-1),r(`form`,{onSubmit:s[7]||=d((...e)=>v.addEventPlace&&v.addEventPlace(...e),[`prevent`])},[s[8]||=r(`label`,{for:`name`},`Name:`,-1),n(r(`input`,{type:`text`,id:`name`,"onUpdate:modelValue":s[0]||=e=>_.newEventPlace.name=e,placeholder:`Name`,required:``},null,512),[[u,_.newEventPlace.name]]),s[9]||=r(`label`,{for:`street`},`Straße:`,-1),n(r(`input`,{type:`text`,id:`street`,"onUpdate:modelValue":s[1]||=e=>_.newEventPlace.street=e,placeholder:`Straße`,required:``},null,512),[[u,_.newEventPlace.street]]),s[10]||=r(`label`,{for:`zipcode`},`PLZ:`,-1),n(r(`input`,{type:`text`,id:`zipcode`,"onUpdate:modelValue":s[2]||=e=>_.newEventPlace.zipcode=e,placeholder:`PLZ`,required:``},null,512),[[u,_.newEventPlace.zipcode]]),s[11]||=r(`label`,{for:`city`},`Stadt:`,-1),n(r(`input`,{type:`text`,id:`city`,"onUpdate:modelValue":s[3]||=e=>_.newEventPlace.city=e,placeholder:`Stadt`,required:``},null,512),[[u,_.newEventPlace.city]]),s[12]||=r(`label`,{for:`city`},`Webseite:`,-1),n(r(`input`,{type:`text`,id:`website`,"onUpdate:modelValue":s[4]||=e=>_.newEventPlace.website=e,placeholder:`Webseite`,required:``},null,512),[[u,_.newEventPlace.website]]),s[13]||=r(`label`,{for:`backgroundColor`},`Hintergrundfarbe:`,-1),n(r(`input`,{type:`color`,id:`backgroundColor`,"onUpdate:modelValue":s[5]||=e=>_.newEventPlace.backgroundColor=e},null,512),[[u,_.newEventPlace.backgroundColor]]),s[14]||=r(`button`,{type:`submit`},`Speichern`,-1),_.editMode?(l(),a(`button`,{key:0,type:`button`,onClick:s[6]||=(...e)=>v.resetForm&&v.resetForm(...e)},`Neuen Veranstaltungsort erstellen`)):c(``,!0)],32),r(`table`,null,[s[15]||=r(`thead`,null,[r(`tr`,null,[r(`th`,null,`Name`),r(`th`,null,`Bearbeiten`),r(`th`,null,`Löschen`)])],-1),r(`tbody`,null,[(l(!0),a(o,null,t(_.eventPlaces,e=>(l(),a(`tr`,{key:e.id},[r(`td`,null,i(e.name),1),r(`td`,null,[r(`button`,{onClick:t=>v.editEventPlace(e)},`Bearbeiten`,8,m)]),r(`td`,null,[r(`button`,{onClick:t=>v.deleteEventPlace(e.id)},`Löschen`,8,h)])]))),128))])])])}var _=s(f,[[`render`,g],[`__scopeId`,`data-v-3dfc8a79`]]);export{_ as default};
//# sourceMappingURL=EventPlacesManagement-BHvzm7Go.js.map