1import{r,v as y,h as j,j as e,p as g,g as N,K as v,Z as w,_ as S}from"./index-BO4j6sSs.js";import{U as k}from"./upload-cloud-LNG-JyEH.js";import{T as U}from"./trash-BFzoBGyr.js";const D=()=>{const[d,u]=r.useState([]),[x,n]=r.useState(!0),[s,c]=r.useState(!1),{showToast:t,confirm:h}=y();r.useEffect(()=>{l()},[]);const l=async()=>{n(!0);const a=await j();u(a),n(!1)},p=async a=>{var m;const i=(m=a.target.files)==null?void 0:m[0];if(i){c(!0);try{const o=await v(i),f={id:Date.now().toString(),imageUrl:o,caption:""};await w(f),t("Gambar berhasil ditambahkan ke carousel","success"),l()}catch(o){t("Gagal upload gambar: "+o.message,"error")}finally{c(!1)}}},b=a=>{h({title:"Hapus Slide",message:"Apakah Anda yakin ingin menghapus slide ini?",onConfirm:async()=>{try{await S(a),t("Slide berhasil dihapus","success"),l()}catch{t("Gagal menghapus slide","error")}}})};return x?e.jsx("div",{className:"p-8 text-center",children:e.jsx(g,{className:"animate-spin mx-auto"})}):e.jsxs("div",{className:"max-w-6xl",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-8",children:"Manajemen Banner Carousel"}),e.jsxs("div",{className:"bg-white p-6 rounded-xl shadow-sm mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-700 mb-4",children:"Upload Banner Baru"}),e.jsxs("div",{className:"border-2 border-dashed border-gray-300 rounded-xl p-8 text-center bg-gray-50 hover:bg-gray-100 transition",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:p,className:"hidden",id:"carouselUpload",disabled:s}),e.jsxs("label",{htmlFor:"carouselUpload",className:`cursor-pointer flex flex-col items-center justify-center ${s?"opacity-50":""}`,children:[s?e.jsx(g,{className:"animate-spin mb-2 text-red-700",size:32}):e.jsx(k,{className:"mb-2 text-gray-400",size:32}),e.jsx("span",{className:"font-medium text-gray-700",children:s?"Mengupload...":"Klik untuk memilih gambar"}),e.jsx("span",{className:"text-xs text-gray-500 mt-2",children:"Rekomendasi ukuran: 1200 x 400 px (Rasio 3:1) atau 16:9"})]})]})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-700 mb-4",children:"Daftar Slide Aktif"}),d.length===0?e.jsx("div",{className:"text-center py-12 bg-gray-50 rounded-xl border border-dashed border-gray-200 text-gray-400",children:"Belum ada slide gambar. Silakan upload gambar baru."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:d.map(a=>e.jsxs("div",{className:"group relative rounded-xl overflow-hidden shadow-md bg-gray-100 aspect-[3/1]",children:[e.jsx("img",{src:N(a.imageUrl),alt:"Slide",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-4",children:e.jsxs("button",{onClick:()=>b(a.id),className:"bg-red-600 text-white px-4 py-2 rounded-lg font-medium hover:bg-red-700 flex items-center shadow-lg",children:[e.jsx(U,{size:18,className:"mr-2"})," Hapus"]})})]},a.id))})]})};export{D as ManageCarousel};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.