import{q as N,S as P,r as v,j as t}from"./app-Bup04Qnx.js";import{W as C}from"./WithModal-CbKxT3eW.js";import{b as _}from"./FormBuilder-B6qVpe84.js";import{u as k}from"./useFormChange-D35moWjQ.js";import"./Input-Bs1ncZB7.js";import"./format-CisCU4Rs.js";import"./BaseForm-wkPKZ5Eg.js";import"./Select-Cs0aMrtU.js";import"./index-CtjruoRR.js";import"./floating-ui.dom-CwWDmSD9.js";import"./TextArea-DiAj0IR8.js";import"./clsx-B-dksMZM.js";import"./index-Dy_g3AZ5.js";function T({onClose:e,onSuccess:r,id:i="create_vendor_modal"}){const{props:s}=N(),l=P({ref_url:`${s.location}?ref=${s.location}`,name:"",company_name:"",phone:"",city:"",status:"active",address:""}),{data:n,setData:p,post:c,processing:m,errors:d,reset:u}=l,b=o=>{const{name:a,value:g}=k(o,n);p(j=>({...j,[a]:g}))},f=o=>{c("/admin/vendors",{onSuccess:()=>{u(),o(),r&&r()},onError:a=>{console.error(a)}})},x={data:n,setData:p,handleChange:b,errors:d},h=S(),y=v.useRef();return t.jsxs(C,{type:i,backdrop:!0,children:[t.jsx("h3",{className:"font-bold text-lg mb-4",children:"Tambah Vendor"}),t.jsx(_,{properties:h,inputProps:x}),t.jsxs("div",{className:"modal-action",children:[t.jsx("button",{ref:y,type:"button",className:"btn btn-sm btn-ghost",onClick:e,children:"Batal"}),t.jsxs("button",{onClick:()=>f(()=>e()),className:"btn btn-sm btn-primary",disabled:m,children:[m&&t.jsx("span",{className:"loading loading-spinner loading-xs"}),"Simpan"]})]})]})}const S=e=>[[{form:"input",props:{name:"name",label:"Nama PIC",type:"text",required:!0}},{form:"input",props:{name:"company_name",label:"Nama Perusahaan",type:"text",required:!0}}],[{form:"input",props:{name:"phone",label:"No. HP PIC",type:"text"}},{form:"input",props:{name:"city",label:"Kota",type:"text"}}],[{form:"textarea",props:{name:"address",label:"Alamat"}}]];export{T as default};
