module.exports=[56436,a=>{"use strict";let b=async a=>{if(!a)return"";try{let b=new FormData;b.append("file",a);let c=await fetch("/api/upload",{method:"POST",body:b});if(!c.ok)throw Error("Server returned error status "+c.status);let d=await c.json();if(d.success&&d.url)return d.url;throw Error(d.error||"Gagal menyimpan berkas di server")}catch(a){throw console.error("Upload failed: ",a),a}};a.s(["uploadImage",0,b])},98469,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(23292),e=a.i(56436),f=a.i(5050);let g=(0,f.createServerReference)("6082d397241cb6ec88dfd572bd04fb66cbfd1d197d",f.callServer,void 0,f.findSourceMapURL,"updateOrganigramDpm");var h=a.i(99570),i=a.i(66718);function j({profilId:a,initialUrl:f}){let[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(f),[n,o]=(0,c.useState)(!1),p=async()=>{if(!j)return void d.toast.error("Pilih file terlebih dahulu");o(!0);try{let b=await (0,e.uploadImage)(j),c=await g(a,b);c.success?(d.toast.success(c.message),m(b),k(null)):d.toast.error(c.message)}catch(a){d.toast.error(a.message)}finally{o(!1)}},q=j?URL.createObjectURL(j):l;return(0,b.jsxs)("div",{className:"bg-white border border-slate-200 rounded-3xl p-8 relative overflow-hidden flex flex-col md:flex-row gap-6 shadow-sm",children:[(0,b.jsxs)("div",{className:"flex-1 space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-xl font-bold text-slate-800",children:"Organigram DPM"}),(0,b.jsx)("p",{className:"text-slate-500 text-sm mt-1",children:"Unggah bagan struktur organisasi Dewan Perwakilan Mahasiswa."})]}),(0,b.jsx)("div",{className:"space-y-2",children:(0,b.jsx)(i.Input,{type:"file",accept:"image/*",onChange:a=>k(a.target.files?.[0]||null)})}),(0,b.jsx)(h.Button,{onClick:p,disabled:!j||n,children:n?"Menyimpan...":"Simpan Organigram"})]}),(0,b.jsx)("div",{className:"w-full md:w-1/3 aspect-video bg-slate-50 border-2 border-dashed border-slate-200 rounded-xl flex items-center justify-center overflow-hidden",children:q?(0,b.jsx)("img",{src:q,alt:"Organigram",className:"w-full h-full object-contain"}):(0,b.jsx)("span",{className:"text-slate-400 text-sm font-medium",children:"Belum ada bagan"})})]})}a.s(["default",()=>j],98469)}];

//# sourceMappingURL=src_41a61ca5._.js.map