"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[446],{446:function(e,a,l){l.r(a),l.d(a,{default:function(){return w}});var t=l(641),n=l(3751),i=l(33);const o={class:"upload-files"},r={class:"file-list"},u={class:"file-info"},d=["onClick"],s=["onClick"],c={class:"file-date"};function f(e,a,l,f,h,p){return(0,t.uX)(),(0,t.CE)("div",o,[a[5]||(a[5]=(0,t.Lk)("h2",null,"Dateien hochladen",-1)),(0,t.Lk)("div",null,[a[3]||(a[3]=(0,t.Lk)("label",{for:"file-upload"},"Datei auswählen:",-1)),(0,t.Lk)("input",{id:"file-upload",type:"file",onChange:a[0]||(a[0]=(...e)=>f.handleFileUpload&&f.handleFileUpload(...e))},null,32)]),(0,t.Lk)("div",null,[a[4]||(a[4]=(0,t.Lk)("label",{for:"file-title"},"Titel eingeben:",-1)),(0,t.bo)((0,t.Lk)("input",{id:"file-title",type:"text","onUpdate:modelValue":a[1]||(a[1]=e=>f.fileTitle=e)},null,512),[[n.Jo,f.fileTitle]])]),(0,t.Lk)("button",{onClick:a[2]||(a[2]=(...e)=>f.uploadFiles&&f.uploadFiles(...e))},"Hochladen"),(0,t.Lk)("ul",r,[((0,t.uX)(!0),(0,t.CE)(t.FK,null,(0,t.pI)(f.uploadedFiles,e=>((0,t.uX)(),(0,t.CE)("li",{key:e.id},[(0,t.Lk)("div",u,[(0,t.Lk)("span",{class:"file-title",onClick:a=>f.downloadFile(e)},(0,i.v_)(e.title),9,d),(0,t.Lk)("span",{class:"file-name",onClick:a=>f.downloadFile(e)},(0,i.v_)(e.originalName),9,s),(0,t.Lk)("span",c,(0,i.v_)(f.formatDate(e.createdAt)),1)])]))),128))])])}l(4114),l(4603),l(7566),l(8721);var h=l(953),p=l(6296),v={name:"UploadFilesComponent",setup(){const e=(0,h.KR)(null),a=(0,h.KR)(""),l=(0,h.KR)([]),n=a=>{e.value=a.target.files[0]},i=async()=>{if(!e.value||!a.value)return void alert("Bitte wählen Sie eine Datei aus und geben Sie einen Titel ein.");const t=new FormData;t.append("file",e.value),t.append("title",a.value);try{const n=await p.A.post("/files",t,{headers:{"Content-Type":"multipart/form-data"}}),i=n.data;l.value.push({id:i.id,title:i.title,originalName:i.originalName,createdAt:i.createdAt,hash:i.hash}),e.value=null,a.value=""}catch(n){console.error("Fehler beim Hochladen der Datei:",n)}},o=async e=>{const a=e.originalName.substring(e.originalName.lastIndexOf(".")),l=await p.A.get(`/files/download/${e.hash}`,{responseType:"blob"}),t=new Blob([l.data],{type:l.data.type}),n=document.createElement("a");n.href=window.URL.createObjectURL(t),n.download=`${e.title}${a}`,n.click(),window.URL.revokeObjectURL(n.href)},r=e=>{const a={year:"numeric",month:"long",day:"numeric"};return new Date(e).toLocaleDateString(void 0,a)},u=async()=>{try{const e=await p.A.get("/files");l.value=e.data}catch(e){console.error("Fehler beim Abrufen der Dateien:",e)}};return(0,t.sV)(u),{fileToUpload:e,fileTitle:a,uploadedFiles:l,handleFileUpload:n,uploadFiles:i,downloadFile:o,formatDate:r}}},m=l(6262);const k=(0,m.A)(v,[["render",f],["__scopeId","data-v-f2694614"]]);var w=k},2812:function(e){var a=TypeError;e.exports=function(e,l){if(e