import{u as y,j as e,H as v,L as N}from"./app-2gKhTNh_.js";import{A as w}from"./AdminKampusLayout-QLddaMo-.js";import{F as i,f as k,a as S,b as u,c as A,d as P}from"./index-DQiLWVLj.js";import{S as x}from"./sweetalert2.esm.all-NNS-RXd7.js";import"./proxy-N6hiut4S.js";const C=({index:o,step:l,onStepChange:t,onStepRemove:r,errors:d})=>{const a=`steps.${o}`;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:c=>t(o,"name",c.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 ${d[`${a}.name`]?"border-red-500":""}`}),d[`${a}.name`]&&e.jsx("div",{className:"text-xs text-red-600 mt-1",children:d[`${a}.name`]})]}),e.jsx("button",{type:"button",onClick:()=>r(o),className:"text-red-500 hover:text-red-700 transition flex-shrink-0 mt-2",title:"Hapus Langkah",children:e.jsx(i,{icon:P,className:"w-4 h-4"})})]})};function E({auth:o,errors:l}){const{data:t,setData:r,post:d,processing:a,recentlySuccessful:c,reset:p}=y({steps:[{name:"Daftar Online"}],is_active:!0}),g=()=>{r("steps",[...t.steps,{name:"Langkah Baru"}])},f=n=>{const s=[...t.steps];s.splice(n,1),r("steps",s)},b=(n,s,j)=>{const m=[...t.steps];m[n][s]=j,r("steps",m)},h=n=>{n.preventDefault(),d(route("admin.kampus.alurPendaftaran.store"),{onSuccess:()=>{x.fire({icon:"success",title:"Berhasil!",text:"Alur Pendaftaran berhasil disimpan.",confirmButtonColor:"#4F46E5"}).then(()=>{p()})},onError:s=>{console.error("Error submitting form:",s),x.fire({icon:"error",title:"Gagal!",text:"Terjadi kesalahan saat menyimpan data.",confirmButtonColor:"#DC2626"})}})};return e.jsxs(w,{user:o.user,children:[e.jsx(v,{title:"Buat Alur Pendaftaran"}),e.jsx("div",{className:"max-w-7xl mx-auto sm:px-6 lg:px-8 py-12",children:e.jsxs("form",{onSubmit:h,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(i,{icon:k,className:"mr-3 w-6 h-6"}),"Buat Alur Pendaftaran"]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsxs(N,{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(i,{icon:S,className:"w-3 h-3 mr-2"}),"Kembali"]}),e.jsxs("button",{type:"submit",disabled:a,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 ${a?"opacity-75":""}`,children:[e.jsx(i,{icon:u,className:"w-3 h-3 mr-2"}),a?"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((n,s)=>e.jsx(C,{index:s,step:n,onStepChange:b,onStepRemove:f,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(i,{icon:A,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:()=>r("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:a,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 ${a?"opacity-75":""}`,children:[e.jsx(i,{icon:u,className:"w-3 h-3 mr-2"}),a?"Menyimpan...":"Simpan Alur Pendaftaran"]})})]})})]})}export{E as default};
