import{t as e}from"./axios-DHQprbt3.js";import{M as t,O as n,c as r,ct as i,d as a,h as o,j as s,m as c,t as l,u,w as d}from"./_plugin-vue_export-helper-Conii5fq.js";import{a as f,c as p}from"./runtime-dom.esm-bundler-CI28bPhn.js";import{n as m}from"./vuex.esm-bundler-CDO_-3pz.js";var h={name:`DialogComponent`,props:{title:{type:String,required:!0},message:{type:String,required:!0},modelValue:{type:Boolean,default:!1}},methods:{closeDialog(){this.$emit(`update:modelValue`,!1),this.$emit(`close`)}}},g={key:0,class:`dialog-overlay`},_={class:`dialog`};function v(e,t,n,o,s,c){return n.modelValue?(d(),a(`div`,g,[r(`div`,_,[r(`h2`,null,i(n.title),1),r(`p`,null,i(n.message),1),r(`button`,{onClick:t[0]||=(...e)=>c.closeDialog&&c.closeDialog(...e)},`OK`)])])):u(``,!0)}var y={name:`LoginComponent`,components:{DialogComponent:l(h,[[`render`,v],[`__scopeId`,`data-v-7743bdb5`]])},data(){return{email:``,password:``,dialogTitle:``,dialogMessage:``,dialogVisible:!1}},methods:{...m([`login`]),async runLogin(){try{let t=await e.post(`/auth/login`,{email:this.email,password:this.password}),n=t.data.token,r=t.data;localStorage.setItem(`token`,n),this.login(r.user),e.defaults.headers.common.Authorization=`Bearer ${n}`,this.$router.push(`/admin/index`)}catch(e){e.response?this.showDialog(`Fehler`,e.response.data.message):this.showDialog(`Ein Fehler ist aufgetreten`,e.message)}},showDialog(e,t){this.dialogTitle=e,this.dialogMessage=t,this.dialogVisible=!0},closeDialog(){this.dialogVisible=!1}}},b={class:`login`};function x(e,i,l,u,m,h){let g=n(`router-link`),_=n(`DialogComponent`);return d(),a(`div`,b,[i[9]||=r(`h2`,null,`Login`,-1),r(`form`,{onSubmit:i[2]||=p((...e)=>h.runLogin&&h.runLogin(...e),[`prevent`])},[i[4]||=r(`label`,{for:`email`},`Email-Adresse:`,-1),t(r(`input`,{type:`email`,id:`email`,"onUpdate:modelValue":i[0]||=e=>m.email=e,required:``},null,512),[[f,m.email]]),i[5]||=r(`label`,{for:`password`},`Passwort:`,-1),t(r(`input`,{type:`password`,id:`password`,"onUpdate:modelValue":i[1]||=e=>m.password=e,required:``},null,512),[[f,m.password]]),i[6]||=r(`button`,{type:`submit`},`Login`,-1)],32),r(`p`,null,[o(g,{to:`/register`},{default:s(()=>[...i[7]||=[c(`Registrieren`,-1)]]),_:1})]),r(`p`,null,[o(g,{to:`/forgot-password`},{default:s(()=>[...i[8]||=[c(`Passwort vergessen?`,-1)]]),_:1})]),o(_,{title:m.dialogTitle,message:m.dialogMessage,modelValue:m.dialogVisible,"onUpdate:modelValue":i[3]||=e=>m.dialogVisible=e,onClose:h.closeDialog},null,8,[`title`,`message`,`modelValue`,`onClose`])])}var S=l(y,[[`render`,x],[`__scopeId`,`data-v-5eeff340`]]);export{S as default};
//# sourceMappingURL=LoginContent-CBY-p8Uh.js.map