import{r as h,j as e}from"./login-aN2dRsX6.js";import{B as y}from"./button_submit-wN0ayemz.js";import{D as v}from"./DataTable-D2rA17vR.js";import{P as D}from"./page_header-wdV8ucix.js";import{u as T,F as _}from"./modalJurnalCostum-CegFdN4Y.js";import{f as l,b as k}from"./index-26bvdVY4.js";import{y as C,z as N,A as S}from"./query-c3dDncii.js";/* empty css               */import{useModalTransaksiDeposito as E}from"./modalTransaksiDeposito-ZtdfKS5i.js";import{p as f,b as w,a as i}from"./alert-CsXKWu2a.js";import{C as A}from"./circle-plus-D9wc3WnO.js";import{E as F}from"./eye-By1xm0Dd.js";import"./ThemeProvider-Cx_yflmw.js";import"./app-gmlkJjeD.js";import"./search-4uBqei5W.js";import"./createLucideIcon-C44k9nIN.js";import"./delete-PVCdpT-9.js";import"./trash-CTcWUXGP.js";import"./modalBrowseRekeningDeposito-DdEppIA3.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"./index-B595qSOc.js";import"./Modal-Dn58D0E5.js";import"./modalBrowseRekeningTabungan-1RIamgea.js";import"./SelectProdukTabungan-2_58_DnQ.js";import"./react-number-format.es-iP3AzcWx.js";import"./x-CZwmhdFm.js";import"./save-CB8xeERj.js";function pa(){const m=new URLSearchParams(window.location.search),j=m.get("tgl_awal")||l(new Date),x=m.get("tgl_akhir")||l(new Date),[c,b]=h.useState({tgl_awal:j,tgl_akhir:x}),[r,p]=h.useState(c),n=C(c),d=E({onSubmit:async()=>(await n.refetch(),!0)}),u=[{label:e.jsx("center",{children:"Trans ID"}),width:150,align:"center",value:a=>a.trans_id},{label:e.jsx("center",{children:"Anggota"}),width:200,value:a=>{var s,t;return(t=(s=a.deposito)==null?void 0:s.anggota)==null?void 0:t.nama_lengkap}},{label:e.jsx("center",{children:"Setor"}),width:120,align:"right",value:a=>k(a.setor)},{label:e.jsx("center",{children:"Tarik"}),width:120,align:"right",value:a=>k(a.tarik)},{label:"Keterangan",value:a=>a.keterangan},{label:e.jsx("center",{children:"Trans Date"}),width:120,align:"center",value:a=>l(a.trans_date)},{label:e.jsx("center",{children:"User"}),width:120,align:"center",value:a=>{var s;return(s=a.user)==null?void 0:s.username}},{label:e.jsx("center",{}),width:80,align:"center",value:a=>e.jsx("span",{className:"c-pointer",onClick:()=>g.open(a),children:e.jsx(F,{size:18})})}],g=T({column:u,onDelete:async a=>{const{isConfirmed:s}=await f({message:"Apa kamu yakin akan membatalkan transaksi ini?",callback:async()=>{try{console.log("Deleting transaction with ID:",a);const t=await S(a),o=await t.json();return t.status==200?(await w(o.message||"Transaksi berhasil dihapus"),!0):(i(o.message||"Gagal menghapus transaksi"),!1)}catch(t){return console.error("Error deleting transaction:",t),t instanceof Error?i(t.message):i("Terjadi kesalahan saat menghapus transaksi"),!1}finally{n.refetch()}}});return s},onValidate:async a=>{const{isConfirmed:s}=await f({message:"Apa kamu yakin akan memvalidasi transaksi ini?",callback:async()=>{try{const t=await N(a);console.log(t);const o=await t.json();return t.status==200?(await w(o.message||"Transaksi berhasil divalidasi"),!0):(i(o.message||"Gagal memvalidasi transaksi"),!1)}catch(t){return console.error("Error validating transaction:",t),t instanceof Error?i(t.message):i("Terjadi kesalahan saat memvalidasi transaksi"),!1}finally{n.refetch()}}});return s}});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container",children:[e.jsx(D,{title:"Transaksi Deposito",breadcrumb:[{title:"Transaksi",path:"/app/transaksi"},{title:"Deposito",path:"/app/transaksi/deposito"}]}),e.jsx(v,{data:n.data??[],column:u,search:!0,pagination:!0,item_per_page:15,loading:n.isLoading,buttons:e.jsxs("div",{className:"d-flex gap-2",children:[e.jsxs("div",{className:"input-group",children:[e.jsx("input",{className:"form-control",type:"date",value:r.tgl_awal??"",onChange:a=>p({...r,tgl_awal:a.target.value})}),e.jsx("span",{className:"input-group-text",children:" sampai "}),e.jsx("input",{className:"form-control",type:"date",value:r.tgl_akhir??"",onChange:a=>p({...r,tgl_akhir:a.target.value})}),e.jsx(y,{className:"btn-secondary",icon:e.jsx(_,{size:18}),onClick:()=>{window.history.replaceState({},"",`?tgl_awal=${encodeURIComponent(r.tgl_awal)}&tgl_akhir=${encodeURIComponent(r.tgl_akhir)}`),b(r)},children:"Filter"})]}),e.jsxs("button",{className:"btn btn-primary d-flex gap-2 align-items-center justify-content-center",style:{width:230},onClick:()=>d.open(),children:[e.jsx(A,{size:18}),"Tambah Transaksi"]})]})})]}),g.modal,d.modal]})}export{pa as default};
