import{u as v,r as N,j as e,H as w,L as k}from"./app-2gKhTNh_.js";import{A as S}from"./AdminKampusLayout-QLddaMo-.js";import{F as o,f as A,a as P,b as x,c as C,d as E}from"./index-DQiLWVLj.js";import{S as m}from"./sweetalert2.esm.all-NNS-RXd7.js";import"./proxy-N6hiut4S.js";const L=({index:d,step:l,onStepChange:i,onStepRemove:t,errors:a})=>{const c=`steps.${d}`;return e.jsxs("div",{className:"flex space-x-3 mb-3 p-3 bg-gray-50 rounded-lg border border-gray-200 items-start",children:[e.jsxs("div",{className:"w-1/2",children:[e.jsx("input",{type:"text",placeholder:"Nama Langkah",value:l.name||"",onChange:n=>i(d,"name",n.target.value),className:`w-full text-sm border-gray-300 rounded-lg shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 ${a[`${c}.name`]?"border-red-500":""}`}),a[`${c}.name`]&&e.jsx("div",{className:"text-xs text-red-600 mt-1",children:a[`${c}.name`]})]}),e.jsx("button",{type:"button",onClick:()=>t(d),className:"text-red-500 hover:text-red-700 transition flex-shrink-0 mt-2",title:"Hapus Langkah",children:e.jsx(o,{icon:E,className:"w-4 h-4"})})]})};function H({auth:d,errors:l,alur:i}){const{data:t,setData:a,put:c,processing:n,recentlySuccessful:u,reset:f}=v({id:i.id,steps:i.steps||[{name:"Langkah Baru"}],is_active:i.is_active});N.useEffect(()=>{u&&m.fire({icon:"success",title:"Berhasil!",text:"Alur Pendaftaran berhasil diperbarui.",confirmButtonColor:"#4F46E5"}).then(()=>{f()})},[u]);const g=()=>{a("steps",[...t.steps,{name:"Langkah Baru"}])},b=r=>{const s=[...t.steps];s.splice(r,1),a("steps",s)},h=(r,s,y)=>{const p=[...t.steps];p[r][s]=y,a("steps",p)},j=r=>{r.preventDefault(),c(route("admin.kampus.alurPendaftaran.update",i.id),{onSuccess:()=>{m.fire({icon:"success",title:"Berhasil!",text:"Alur Pendaftaran berhasil disimpan.",confirmButtonColor:"#4F46E5"})},onError:s=>{console.error("Error submitting form:",s),m.fire({icon:"error",title:"Gagal!",text:"Terjadi kesalahan saat menyimpan data.",confirmButtonColor:"#DC2626"})}})};return e.jsxs(S,{user:d.user,children:[e.jsx(w,{title:"Edit Alur Pendaftaran"}),e.jsx("div",{className:"max-w-7xl mx-auto sm:px-6 lg:px-8 py-12",children:e.jsxs("form",{onSubmit:j,className:"bg-white overflow-hidden shadow-xl sm:rounded-lg p-8",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8 border-b pb-4",children:[e.jsxs("h3",{className:"text-2xl font-bold text-indigo-700 flex items-center",children:[e.jsx(o,{icon:A,className:"mr-3 w-6 h-6"}),"Edit Alur Pendaftaran"]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsxs(k,{href:route("admin.kampus.alurPendaftaran.index"),className:"inline-flex items-center px-4 py-2 bg-gray-200 border border-transparent rounded-lg font-semibold text-xs text-gray-700 uppercase tracking-widest hover:bg-gray-300 transition ease-in-out duration-150",children:[e.jsx(o,{icon:P,className:"w-3 h-3 mr-2"}),"Kembali"]}),e.jsxs("button",{type:"submit",disabled:n,className:`inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparent rounded-lg font-semibold text-xs text-white uppercase tracking-widest hover:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:border-indigo-900 focus:ring ring-indigo-300 transition ease-in-out duration-150 shadow-md ${n?"opacity-75":""}`,children:[e.jsx(o,{icon:x,className:"w-3 h-3 mr-2"}),n?"Menyimpan...":"Simpan Alur Pendaftaran"]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-lg font-semibold text-gray-700 mb-4",children:"Langkah Pendaftaran"}),t.steps.map((r,s)=>e.jsx(L,{index:s,step:r,onStepChange:h,onStepRemove:b,errors:l},s)),e.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center px-3 py-1 bg-gray-100 border border-gray-300 rounded-lg font-medium text-xs text-gray-700 hover:bg-gray-200 transition mb-8",children:[e.jsx(o,{icon:C,className:"w-3 h-3 mr-2"}),"Tambah Langkah"]})]}),e.jsx("div",{className:"mb-8",children:e.jsxs("label",{className:"text-sm font-medium text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:t.is_active,onChange:()=>a("is_active",!t.is_active),className:"mr-2"}),"Aktif"]})}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs("button",{type:"submit",disabled:n,className:`inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparent rounded-lg font-semibold text-xs text-white uppercase tracking-widest hover:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:border-indigo-900 focus:ring ring-indigo-300 transition ease-in-out duration-150 shadow-md ${n?"opacity-75":""}`,children:[e.jsx(o,{icon:x,className:"w-3 h-3 mr-2"}),n?"Menyimpan...":"Simpan Alur Pendaftaran"]})})]})})]})}export{H as default};
