import{c as j}from"./createLucideIcon-C44k9nIN.js";import{j as e,r as l}from"./login-aN2dRsX6.js";import{b as N}from"./index-26bvdVY4.js";import{S as _,B as k}from"./button_submit-wN0ayemz.js";import{T as R}from"./trash-CTcWUXGP.js";/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const J=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],S=j("Check",J);/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const E=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],G=j("Filter",E);/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const B=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],L=j("Info",B),z=async s=>await fetch(`/api/jurnal/${s}`,{method:"GET",headers:{Accept:"application/json"}}),w=()=>e.jsx("div",{className:"alert alert-danger mb-0 mt-3",children:e.jsxs("div",{className:"d-flex align-items-center flex-column gap-2",children:[e.jsx(L,{}),e.jsx("span",{children:"Jurnal transaksi tidak ditemukan."})]})}),I=({className:s})=>e.jsx("div",{className:`d-flex justify-content-center align-items-center p-3 ${s??""}`,children:e.jsx(_,{size:"sm"})}),M=({show:s,onClose:d,size:x="md",children:o,onExited:c})=>{const u=l.useRef(null);return l.useEffect(()=>(s?document.body.style.overflow="hidden":(document.body.style.overflow="",c&&c()),()=>{document.body.style.overflow=""}),[s,c]),l.useEffect(()=>{const i=b=>{b.key==="Escape"&&s&&d()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[s,d]),s?e.jsx("div",{className:"custom-modal-backdrop",style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"rgba(0,0,0,0.5)",zIndex:1050,display:"flex",alignItems:"center",justifyContent:"center"},onClick:d,"aria-modal":"true",role:"dialog",children:e.jsx("div",{className:"custom-modal-content",style:{borderRadius:8,maxHeight:"90vh",overflow:"auto",minWidth:1320,maxWidth:1320,boxShadow:"0 2px 16px rgba(0,0,0,0.2)",position:"relative"},ref:u,onClick:i=>i.stopPropagation(),children:o})}):null};function H({column:s,onValidate:d,onDelete:x,onPrint:o}){const[c,u]=l.useState(!1),[i,b]=l.useState(),[t,v]=l.useState(),[f,p]=l.useState(!0),T=a=>{u(!0),v(a),C(a.trans_id).then(()=>{p(!1)})},h=()=>{u(!1)},C=async a=>{const r=await z(a),n=await r.json();r.status==200&&b(n)},y=l.useCallback(()=>e.jsxs("table",{className:"table-bordered table-sm mb-0 table table-fixed",style:{width:"100%"},children:[e.jsx("thead",{children:e.jsx("tr",{children:s&&(s==null?void 0:s.map((a,r)=>r<s.length-1?e.jsx("th",{style:a.style,className:a.class,children:a.label},r):null))})}),e.jsx("tbody",{children:s&&[t].map((a,r)=>e.jsx("tr",{style:{verticalAlign:"middle"},children:s.map((n,m)=>m<s.length-1?e.jsx("td",{width:n.width,align:n.align,className:n.class,style:n.style,children:a&&n.value?n.value(a,r)??"":e.jsx("div",{style:{height:"22.75px"}})},m):null)},r))})]}),[s,t]),g=l.useCallback(({loading:a,transaksi:r})=>{if(a)return e.jsx(I,{className:"mt-3"});if(i&&r){if(r.status==9||i.length==0)return e.jsx(w,{});if(r.status==1)return e.jsxs("div",{children:[e.jsx("h6",{className:"my-3",children:"Jurnal Transaksi"}),e.jsxs("table",{className:"table-bordered table-sm table-responsive mb-0 table table-fixed",style:{width:"100%"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-center",children:"#"}),e.jsx("th",{className:"text-center",children:"Kode Akun"}),e.jsx("th",{className:"ellipsis text-center",children:"Nama Akun"}),e.jsx("th",{className:"text-center",children:"Debet"}),e.jsx("th",{className:"text-center",children:"Kredit"}),e.jsx("th",{className:"ellipsis",children:"Keterangan"})]})}),e.jsx("tbody",{children:i.map((n,m)=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-center",width:50,children:m+1}),e.jsx("td",{className:"text-center",width:100,children:n.akun.kode_akun}),e.jsx("td",{width:250,children:n.akun.nama}),e.jsx("td",{width:120,className:"text-end",children:N(n.debet)}),e.jsx("td",{width:120,className:"text-end",children:N(n.kredit)}),e.jsx("td",{className:"ellipsis",children:n.keterangan})]},m))})]})]})}return e.jsx(w,{})},[i]);return{modal:l.useMemo(()=>e.jsxs(M,{show:c,onClose:h,size:"xl",onExited:()=>p(!0),children:[e.jsx("div",{className:"modal-header bg-white p-3 border-bottom-1",style:{borderTopLeftRadius:8,borderTopRightRadius:8},children:e.jsxs("h5",{className:"mb-0",children:["Transaksi ID : ",t==null?void 0:t.trans_id]})}),e.jsxs("div",{className:"modal-body p-3 bg-white",children:[e.jsx(y,{}),e.jsx(g,{loading:f,transaksi:t})]}),e.jsxs("div",{className:"modal-footer bg-white p-3 d-flex gap-2",style:{borderBottomLeftRadius:8,borderBottomRightRadius:8,borderTop:"1px solid #dee2e6"},children:[e.jsx("button",{className:"btn btn-secondary",onClick:h,children:"Kembali"}),o&&e.jsxs("button",{className:"btn btn-primary align-center flex",onClick:()=>o(t==null?void 0:t.trans_id),children:[e.jsx("i",{className:"ri-printer-line mr-2"}),"Cetak"]}),(t==null?void 0:t.status)==1&&e.jsx(k,{className:"btn btn-danger align-center flex",icon:e.jsx(R,{size:18}),onClick:async()=>{x&&await x(t.trans_id)&&h()},children:"Batalkan Transaksi"}),(t==null?void 0:t.status)==9&&e.jsx(k,{className:"btn btn-success",icon:e.jsx(S,{size:18}),onClick:async()=>{d&&await d(t.trans_id)&&h()},children:"Validasi Transaksi"})]})]}),[c,t,y,g,f,o,x,d]),open:T,close:h}}export{G as F,H as u};
