import{r as n,j as e}from"./login-aN2dRsX6.js";import{g as x,i as j}from"./query-c3dDncii.js";import{b as N,a as f}from"./alert-CsXKWu2a.js";import{S as b,B as v}from"./button_submit-wN0ayemz.js";import{u as g}from"./modalBrowseAkun-CPnbOv5J.js";import{N as k}from"./react-number-format.es-iP3AzcWx.js";import{u as w,L as y}from"./app-gmlkJjeD.js";import{S}from"./save-CB8xeERj.js";import"./ThemeProvider-Cx_yflmw.js";import"./modalAkun-DKxSDKLU.js";import"./Select-B6FG_hRH.js";import"./defineProperty-DRmM3rRU.js";import"./typeof-QjJsDpFa.js";import"./setPrototypeOf-B4fUID9J.js";import"./index-Ci65TyJp.js";import"./floating-ui.dom-C5vApqfE.js";import"./Modal-Dn58D0E5.js";import"./search-4uBqei5W.js";import"./createLucideIcon-C44k9nIN.js";function Q(){var o,t;const{id:m}=w(),[D,d]=n.useState(!0),l=x(m),i=g({onSelected:({akun:a,selector:c})=>{c=="jurnal"&&r({...s,jurnal:a,akun_kas:a.kode_akun})}}),[s,r]=n.useState(),u=async()=>{console.log(s);const a=await j(s),c=await a.json();if(a.status==201||a.status==200){const h=c.id;r({...s,id:h}),l.refetch(),await N("Data berhasil disimpan");return}else f(c.message)},p=a=>{r({...s,[a.target.name]:a.target.value.toUpperCase()})};return n.useEffect(()=>{if(l.data){const a=l.data;r(a)}d(!1)},[l.data]),l.isLoading?e.jsx("div",{className:"p-3 text-center",children:e.jsx(b,{})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"container",style:{width:1024},children:e.jsxs("div",{className:"card rounded-4 shadow-lg mx-auto",children:[e.jsx("div",{className:"card-header py-3 bg-transparent",children:e.jsx("h5",{className:"m-0",children:"Data Kas"})}),e.jsx("div",{className:"card-body",children:e.jsxs("div",{className:"row",children:[e.jsxs("div",{className:"col-md-9",children:[e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-3",children:"ID"}),e.jsx("div",{className:"col-md-5",children:e.jsx("div",{className:"input-group",children:e.jsx("input",{className:"form-control",placeholder:"ID Penempatan Bank",readOnly:!0,value:(s==null?void 0:s.id)??""})})})]}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-3",children:"Nama"}),e.jsx("div",{className:"col-md-9",children:e.jsx("div",{className:"input-group",children:e.jsx("input",{className:"form-control",placeholder:"Nama",value:(s==null?void 0:s.nama)??"",name:"nama",onChange:p})})})]}),e.jsx("hr",{}),e.jsx("div",{children:e.jsxs("div",{className:"form-group row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-3",children:"Saldo"}),e.jsx("div",{className:"col-md-5",children:e.jsxs("div",{className:"input-group",children:[e.jsx("span",{className:"input-group-text bg-white border-end-0",children:"Rp"}),e.jsx(k,{className:"form-control border-start-0 text-end",readOnly:!0,thousandSeparator:".",decimalSeparator:",",value:(s==null?void 0:s.saldo)??"0"})]})})]})}),e.jsx("hr",{}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-3",children:"Akun Jurnal"}),e.jsx("div",{className:"col-md-5",children:e.jsxs("div",{className:"input-group",children:[e.jsx("input",{className:"form-control border-end-0",placeholder:"Rekening",readOnly:!0,value:((o=s==null?void 0:s.jurnal)==null?void 0:o.kode_akun)??""}),e.jsx("span",{className:"input-group-text bg-white c-pointer",onClick:()=>i.open("jurnal"),children:"Browse"})]})})]}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-3"}),e.jsx("div",{className:"col-md-9",children:e.jsx("input",{className:"form-control",placeholder:"Nama Akun",readOnly:!0,value:((t=s==null?void 0:s.jurnal)==null?void 0:t.nama)??""})})]}),e.jsxs("div",{className:"row mb-2",children:[e.jsx("label",{className:"col-form-label col-md-3",children:"Atur sebagai default"}),e.jsx("div",{className:"col-md-5 d-flex align-items-center",children:e.jsx("div",{className:"form-check form-switch",children:e.jsx("input",{className:"form-check-input",type:"checkbox",role:"switch",id:"switchCheckChecked",checked:!!(s!=null&&s.is_default),onChange:()=>r({...s,is_default:s!=null&&s.is_default?0:1})})})})]})]}),e.jsx("div",{className:"col-md-3",children:e.jsx("div",{className:"row gap-2",children:e.jsx("div",{className:"col-md-12 gap-2 d-flex flex-column",children:e.jsx("div",{className:"d-flex",children:e.jsx("button",{className:"btn btn-primary flex-grow-1",children:"Statement Transaksi"})})})})})]})}),e.jsxs("div",{className:"card-footer py-3 justify-content-between d-flex bg-transparent",children:[e.jsx(y,{to:"/app/master/kas/",className:"btn btn-danger",children:"Kembali"}),e.jsx(v,{className:"btn btn-success",icon:e.jsx(S,{size:18}),onClick:async()=>u(),children:"Simpan"})]})]})}),i.modal]})}export{Q as default};
