PageSourceSearch

https://www.pelangicomm.net/assets/ManagePartners-CBF2c3Po.js

js pelangicomm.net collected 2026-10-08 17:30:29 UTC 6,079 bytes, 1 lines download raw bytes

1import{r,v as E,i as z,j as e,p as j,X as y,g as N,$ as D,K as G,a0 as I}from"./index-BO4j6sSs.js";import{U as A}from"./upload-cloud-LNG-JyEH.js";import{S as T}from"./save--9VoRomy.js";import{P as B}from"./plus-D5dtA7NP.js";import{S as L}from"./square-pen-BBI5OpRP.js";import{T as M}from"./trash-BFzoBGyr.js";const R=()=>{const[c,v]=r.useState([]),[w,h]=r.useState(!0),[i,p]=r.useState(!1),[t,b]=r.useState(null),[m,x]=r.useState(""),[n,o]=r.useState(""),{showToast:s,confirm:P}=E();r.useEffect(()=>{g()},[]);const g=async()=>{h(!0);const a=await z();v(a),h(!1)},k=async a=>{var f;const l=(f=a.target.files)==null?void 0:f[0];if(l){p(!0);try{const u=await G(l);o(u),s("Gambar berhasil diupload","success")}catch(u){s("Gagal upload gambar: "+u.message,"error")}finally{p(!1)}}},d=()=>{b(null),x(""),o("")},S=a=>{b(a.id),x(a.name),o(a.imageUrl),window.scrollTo({top:0,behavior:"smooth"})},U=async a=>{if(a.preventDefault(),!m){s("Nama partner wajib diisi","error");return}try{const l={id:t||Date.now().toString(),name:m,imageUrl:n};await D(l),s(t?"Partner berhasil diperbarui":"Partner berhasil ditambahkan","success"),d(),g()}catch{s("Gagal menyimpan partner","error")}},C=a=>{P({title:"Hapus Partner",message:"Apakah Anda yakin ingin menghapus partner ini?",onConfirm:async()=>{try{await I(a),s("Partner berhasil dihapus","success"),g(),t===a&&d()}catch{s("Gagal menghapus partner","error")}}})};return w&&c.length===0?e.jsx("div",{className:"p-8 text-center",children:e.jsx(j,{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 Partner & Mitra"}),e.jsxs("div",{className:"bg-white p-6 rounded-xl shadow-sm mb-8 border border-gray-100",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-700",children:t?"Edit Partner":"Tambah Partner Baru"}),t&&e.jsxs("button",{onClick:d,className:"text-sm text-gray-500 hover:text-gray-700 flex items-center",children:[e.jsx(y,{size:16,className:"mr-1"})," Batal Edit"]})]}),e.jsxs("form",{onSubmit:U,className:"flex flex-col md:flex-row gap-6 items-start",children:[e.jsx("div",{className:"w-full md:w-1/3",children:e.jsxs("div",{className:`border-2 border-dashed ${n?"border-red-200 bg-red-50":"border-gray-300 bg-gray-50"} rounded-xl p-4 text-center hover:bg-gray-100 transition relative h-40 flex items-center justify-center overflow-hidden group`,children:[n?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:N(n),alt:"Preview",className:"h-full w-auto object-contain"}),e.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white text-xs font-medium cursor-pointer pointer-events-none",children:"Ganti Logo"})]}):e.jsxs("div",{className:"flex flex-col items-center",children:[i?e.jsx(j,{className:"animate-spin mb-2 text-red-700"}):e.jsx(A,{className:"mb-2 text-gray-400"}),e.jsx("span",{className:"text-xs text-gray-500",children:i?"Uploading...":"Upload Logo (Opsional)"})]}),e.jsx("input",{type:"file",accept:"image/*",onChange:k,className:"absolute inset-0 opacity-0 cursor-pointer",disabled:i}),n&&e.jsx("button",{type:"button",onClick:a=>{a.preventDefault(),o("")},className:"absolute top-2 right-2 bg-white rounded-full p-1 shadow-md text-gray-500 hover:text-red-500 z-10",title:"Hapus Gambar",children:e.jsx(y,{size:14})})]})}),e.jsxs("div",{className:"w-full md:w-2/3 flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Nama Perusahaan / Partner ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:m,onChange:a=>x(a.target.value),className:"w-full p-2 border rounded-lg focus:ring-2 focus:ring-red-500 outline-none",placeholder:"Contoh: Google, Mikrotik...",required:!0})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"submit",disabled:i,className:"bg-red-700 text-white px-6 py-2.5 rounded-lg font-medium hover:bg-red-800 transition shadow disabled:opacity-50 flex items-center justify-center min-w-[120px]",children:[t?e.jsx(T,{size:18,className:"mr-2"}):e.jsx(B,{size:18,className:"mr-2"}),t?"Update Partner":"Simpan Partner"]}),t&&e.jsx("button",{type:"button",onClick:d,className:"bg-gray-100 text-gray-700 px-6 py-2.5 rounded-lg font-medium hover:bg-gray-200 transition",children:"Batal"})]})]})]})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-700 mb-4",children:"Daftar Partner Aktif"}),c.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 partner. Silakan tambahkan."}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 ga
1p-6",children:c.map(a=>e.jsxs("div",{className:`group relative bg-white rounded-xl p-4 shadow-sm border ${t===a.id?"border-red-500 ring-2 ring-red-100":"border-gray-100"} flex flex-col items-center transition-all`,children:[e.jsx("div",{className:"h-24 w-full flex items-center justify-center mb-3 bg-gray-50 rounded-lg overflow-hidden",children:a.imageUrl?e.jsx("img",{src:N(a.imageUrl),alt:a.name,className:"max-h-full max-w-full object-contain grayscale group-hover:grayscale-0 transition-all duration-300"}):e.jsx("span",{className:"text-xs text-gray-400 italic",children:"No Image"})}),e.jsx("span",{className:"text-sm font-semibold text-gray-700 text-center line-clamp-2",children:a.name}),e.jsxs("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1",children:[e.jsx("button",{onClick:()=>S(a),className:"bg-white text-blue-600 p-1.5 rounded-full shadow-md hover:bg-blue-50 border border-blue-100",title:"Edit",children:e.jsx(L,{size:14})}),e.jsx("button",{onClick:()=>C(a.id),className:"bg-white text-red-600 p-1.5 rounded-full shadow-md hover:bg-red-50 border border-red-100",title:"Hapus",children:e.jsx(M,{size:14})})]})]},a.id))})]})};export{R as ManagePartners};

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.