import{r as x,j as e,H as j,L as m,b as u}from"./app-2gKhTNh_.js";import{A as y}from"./AdminKampusLayout-QLddaMo-.js";import{F as s,S as b,T as k,g as N,q as w,j as v,d as S,k as T,l as C}from"./index-DQiLWVLj.js";import{S as h}from"./sweetalert2.esm.all-NNS-RXd7.js";import"./proxy-N6hiut4S.js";const B=({isOpen:n,onClose:t,onConfirm:l,history:r})=>n?e.jsx("div",{className:"fixed inset-0 bg-gray-900 bg-opacity-75 flex items-center justify-center z-50 p-4 transition-opacity duration-300",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-md",children:[e.jsxs("div",{className:"p-6 border-b border-gray-100 flex justify-between items-center bg-red-50 rounded-t-xl",children:[e.jsxs("h3",{className:"text-xl font-bold text-red-700 flex items-center",children:[e.jsx(s,{icon:T,className:"mr-3 w-5 h-5"}),"Konfirmasi Penghapusan"]}),e.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 transition",children:e.jsx(s,{icon:C,className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("p",{className:"text-gray-700",children:["Anda yakin ingin menghapus ",r?.title,"? Data ini tidak bisa dipulihkan, dan setelah dihapus Anda bisa membuat data sejarah baru."]})}),e.jsxs("div",{className:"p-6 border-t border-gray-100 flex justify-end space-x-3 rounded-b-xl",children:[e.jsx("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 transition duration-150",children:"Batal"}),e.jsx("button",{onClick:l,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 transition duration-150",children:"Ya, Hapus"})]})]})}):null;function I({auth:n,history:t}){const[l,r]=x.useState(!1),[o,d]=x.useState(null),c=t?[t]:[],p=a=>{d(a),r(!0)},g=()=>{o&&u.delete(route("admin.kampus.sejarah.destroy"),{preserveScroll:!0,onSuccess:()=>{r(!1),d(null)},onError:a=>{console.error("Gagal menghapus sejarah:",a),r(!1),d(null),h.fire("Gagal!","Terjadi kesalahan saat menghapus data.","error")}})},f=a=>{t&&(a.preventDefault(),h.fire({title:"Data Sejarah Sudah Ada",icon:"info",html:`
                    <div style="text-align: center; margin-top: 10px;">
                        <p style="font-size: 1.05rem; color: #4b5563;">
                            Kampus Anda hanya diizinkan memiliki satu data Sejarah.
                        </p>
                        <p style="margin-top: 15px; font-size: 0.95rem; color: #1f2937;">
                            Untuk melakukan perubahan, silakan gunakan:
                        </p>
                        <ul style="list-style: none; padding: 0; margin-top: 10px; font-weight: 600;">
                            <li style="margin-bottom: 5px;"><span style="color: #4f46e5;">Ikon Pensil</span> untuk Mengedit data yang ada.</li>
                            <li><span style="color: #dc2626;">Ikon Tempat Sampah</span> untuk Menghapus data (jika ingin membuat yang baru).</li>
                        </ul>
                    </div>
                `,showCancelButton:!0,confirmButtonText:"Lanjut Edit Data",cancelButtonText:"Oke, Saya Mengerti",confirmButtonColor:"#4F46E5",cancelButtonColor:"#6B7280"}).then(i=>{i.isConfirmed&&u.get(route("admin.kampus.sejarah.edit"))}))};return e.jsxs(y,{user:n.user,header:e.jsx("h2",{className:"font-semibold text-xl text-gray-800 leading-tight",children:"Manajemen Sejarah Kampus"}),children:[e.jsx(j,{title:"Sejarah Kampus"}),e.jsx(B,{isOpen:l,onClose:()=>r(!1),onConfirm:g,history:o}),e.jsx("div",{className:"max-w-7xl mx-auto sm:px-6 lg:px-8 py-12",children:e.jsxs("div",{className:"bg-white overflow-hidden shadow-xl sm:rounded-lg p-6",children:[e.jsxs("h3",{className:"text-2xl font-bold text-gray-800 mb-6 flex items-center",children:[e.jsx(s,{icon:b,className:"mr-3 text-indigo-600"}),"Daftar Sejarah Kampus"]}),e.jsx("div",{className:"flex justify-end mb-6",children:e.jsxs(m,{href:route("admin.kampus.sejarah.create"),onClick:f,className:`inline-flex items-center px-4 py-2 border border-transparent rounded-lg font-semibold text-xs uppercase tracking-widest transition ease-in-out duration-150 shadow-md justify-center
                                ${t?"bg-gray-400 text-gray-700 cursor-pointer opacity-90":"bg-indigo-600 text-white hover:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:border-indigo-900 focus:ring ring-indigo-300"}`,title:t?"Klik untuk Edit atau Hapus data yang ada.":"Tambah Sejarah Baru",children:[e.jsx(s,{icon:t?k:N,className:"w-4 h-4 mr-2"}),t?"Tambah Sejarah Baru (Edit Data)":"Tambah Sejarah Baru"]})}),e.jsx("div",{className:"overflow-x-auto rounded-lg shadow-lg border border-gray-200",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Judul"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Subtitle"}),e.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Foto"}),e.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Aksi"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:c.length>0?c.map(a=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:a.title}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700",children:a.subtitle||"Tidak ada subtitle"}),e.jsx("td",{className:"px-6 py-4 text-center",children:a.image_url_public?e.jsx("img",{src:a.image_url_public,alt:`Foto ${a.title}`,className:"w-20 h-20 object-cover rounded-md mx-auto shadow-md border border-gray-100",onError:i=>{i.target.onerror=null,i.target.src="https://placehold.co/80x80/E5E7EB/6B7280?text=No+Img"}}):e.jsxs("span",{className:"text-gray-400 italic text-xs flex flex-col items-center justify-center h-full",children:[e.jsx(s,{icon:w,className:"w-5 h-5 mb-1"}),"Tidak Ada Foto"]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-center text-sm font-medium",children:e.jsxs("div",{className:"flex justify-center space-x-2",children:[e.jsx(m,{href:route("admin.kampus.sejarah.edit"),className:"transition duration-150 p-2 rounded-full text-indigo-600 hover:text-indigo-900 hover:bg-indigo-100",title:"Edit Sejarah",children:e.jsx(s,{icon:v,className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>p(a),className:"transition duration-150 p-2 rounded-full text-red-600 hover:text-red-900 hover:bg-red-100",title:"Hapus Sejarah",children:e.jsx(s,{icon:S,className:"w-4 h-4"})})]})})]},a.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:"4",className:"px-6 py-4 text-center text-gray-500 italic",children:"Tidak ada data sejarah kampus. Klik **Tambah Sejarah Baru** untuk membuat."})})})]})})]})})]})}export{I as default};
