import{q as x,r as f,S as b,j as e,f as j}from"./app-Bup04Qnx.js";import{S}from"./Select-Cs0aMrtU.js";import{W as _}from"./WithModal-CbKxT3eW.js";import{l as g}from"./format-CisCU4Rs.js";import"./index-CtjruoRR.js";import"./floating-ui.dom-CwWDmSD9.js";import"./BaseForm-wkPKZ5Eg.js";const y=k=>{var m;const{props:a}=x(),r="department",i=f.useRef();let o=new URLSearchParams(new URL(a.location).search).get("department_id");const{data:n,setData:p,errors:c,processing:d}=b({department_id:((m=a.department)==null?void 0:m.id)??o});let l=null;a.departments.length>0&&(l=n.department_id?a.departments.findIndex(t=>t.value==n.department_id):null);const h=t=>{p(s=>({...s,department_id:t==null?void 0:t.value}))},u=t=>{t.preventDefault(),g("department_id",n.department_id,365,{onSuccess:()=>{var s;(s=i.current)==null||s.click(),j.visit("/admin/dashboard")}})};return e.jsx(_,{type:r,modalBoxSize:"max-w-2xl",children:e.jsxs("form",{action:"",children:[e.jsx("h1",{className:"text-lg font-bold",children:"Pilih Departemen Aktif"}),e.jsx("p",{children:"Semua aktivitas selama sesi ini akan terkait dengan departemen yang dipilih."}),e.jsx("div",{className:"mt-4",children:e.jsx(S,{isReactSelect:!0,isVirtualized:!0,isLabel:!1,name:"department_id",handleChange:h,data:n,errors:c,defaultValue:a.departments[l],options:a.departments})}),e.jsxs("div",{className:"modal-action",children:[e.jsx("label",{ref:i,htmlFor:`modal_${r}`,className:"btn btn-sm btn-neutral btn-outline",children:"Kembali"}),e.jsx("button",{onClick:u,className:"btn btn-sm btn-primary text-white ",disabled:d,children:e.jsx("span",{className:`${d&&"loading"}`,children:"Simpan"})})]})]})})};export{y as default};
