import{j as e,r as t}from"./login-aN2dRsX6.js";import{B as x}from"./button_submit-wN0ayemz.js";import{S as N}from"./Select-B6FG_hRH.js";import{M as i}from"./Modal-Dn58D0E5.js";import{S as j}from"./save-CB8xeERj.js";const b=[{label:"1 : DEBET",value:"D"},{label:"2 : KREDIT",value:"K"}],g=l=>{const o=b.find(n=>n.value===l.value)??"";return e.jsx(N,{value:o,defaultValue:o,options:b,isDisabled:l.disable,placeholder:"Pilih Jurnal",onChange:n=>{var s;const a=n;(s=l.onChange)==null||s.call(l,a==null?void 0:a.value)}})},v=[{label:"1 : AKTIVA",value:"AKTIVA"},{label:"2 : PASIVA",value:"PASIVA"},{label:"3 : PENDAPATAN",value:"PENDAPATAN"},{label:"4 : BIAYA",value:"BIAYA"}],C=l=>{const o=v.find(n=>n.value===l.value);return e.jsx(N,{defaultValue:o,options:v,isDisabled:l.disable,placeholder:"Pilih Kategori Jurnal",onChange:n=>{var s;const a=n;(s=l.onChange)==null||s.call(l,a==null?void 0:a.value)}})},P=({onSubmit:l})=>{const[o,n]=t.useState(!1),[a,s]=t.useState(),[u,h]=t.useState(!1),f=c=>{c&&(s(c),h(!0)),n(!0)},r=()=>{n(!1)},A=()=>{s(void 0),h(!1)},m=t.useCallback(c=>{s({...a,[c.target.name]:c.target.value})},[a]),d=t.useCallback(async()=>{l&&await l(a)},[l,a]);return{modal:t.useMemo(()=>e.jsxs(i,{show:o,onHide:r,onExited:A,children:[e.jsx(i.Header,{closeButton:!0,children:e.jsx("h5",{className:"m-0",children:"Data Akun"})}),e.jsxs(i.Body,{children:[e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-4",children:"Kode Akun"}),e.jsx("div",{className:"col-md-8",children:e.jsx("input",{className:"form-control",name:"kode_akun",value:(a==null?void 0:a.kode_akun)||"",onChange:m})})]}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-4",children:"Nama Akun"}),e.jsx("div",{className:"col-md-8",children:e.jsx("input",{className:"form-control",name:"nama",value:(a==null?void 0:a.nama)||"",onChange:m})})]}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-4",children:"Kategori"}),e.jsx("div",{className:"col-md-8",children:e.jsx(C,{value:(a==null?void 0:a.kategori)||"",onChange:c=>{s({...a,kategori:c})}})})]}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-4",children:"Jurnal"}),e.jsx("div",{className:"col-md-8",children:e.jsx(g,{value:(a==null?void 0:a.jurnal)||"",onChange:c=>{s({...a,jurnal:c})}})})]})]}),e.jsxs(i.Footer,{children:[e.jsx("button",{className:"btn btn-primary",onClick:r,children:"Tutup"}),e.jsx(x,{className:"btn-success",icon:e.jsx(j,{size:18}),onClick:async()=>{await d()},children:"Simpan"}),!u&&e.jsx(x,{className:"btn-success",icon:e.jsx(j,{size:18}),onClick:async()=>{await d()},children:"Simpan dan Tambah"})]})]}),[a,m,d,u,o]),open:f,close:r}};export{P as u};
