import{r as o,j as e}from"./login-aN2dRsX6.js";import{n as m,w as p,o as d}from"./query-c3dDncii.js";import{b as l,a as u,c as k}from"./alert-CsXKWu2a.js";import{B as h}from"./button_submit-wN0ayemz.js";import{D as g}from"./DataTable-D2rA17vR.js";import{P as b}from"./page_header-wdV8ucix.js";import{u as f}from"./modalAkun-DKxSDKLU.js";import{C as j}from"./circle-plus-D9wc3WnO.js";import"./app-gmlkJjeD.js";import"./ThemeProvider-Cx_yflmw.js";import"./search-4uBqei5W.js";import"./createLucideIcon-C44k9nIN.js";import"./delete-PVCdpT-9.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"./save-CB8xeERj.js";function q(){const r=m(),n=f({onSubmit:async a=>{const t=await d(a),s=await t.json();return t.status==200||t.status==201?(r.refetch(),await l("Akun berhasil disimpan"),!0):(await u(s.message),!1)}}),i=o.useCallback(async a=>{const t=await p(a),s=await t.json();return t.status==200||t.status==201?(r.refetch(),await l("Akun berhasil dihapus"),!0):(await u(s.message),!1)},[r]),c=o.useMemo(()=>[{label:e.jsx("center",{children:"Kode Akun"}),width:120,align:"center",value:a=>a.kode_akun},{label:e.jsx("center",{children:"Nama Akun"}),value:a=>a.nama},{label:e.jsx("center",{children:"Kategori"}),width:200,align:"center",value:a=>a.kategori},{label:e.jsx("center",{children:"Jurnal"}),width:100,align:"center",value:a=>a.jurnal},{label:e.jsx("center",{children:"Aksi"}),width:120,align:"center",value:a=>a.kode_akun&&e.jsxs("div",{className:"d-flex gap-2 justify-content-center",children:[e.jsx("div",{className:"badge bg-primary",style:{cursor:"pointer"},onClick:()=>{n.open(a)},children:"Edit"}),e.jsx("div",{className:"badge bg-danger",style:{cursor:"pointer"},onClick:async()=>{(await k("Apakah anda yakin ingin menghapus akun ini?")).isConfirmed&&await i(a)},children:"Hapus"})]})}],[i,n]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container",children:[e.jsx(b,{title:"Akun",breadcrumb:[{title:"Pengaturan",path:"/app/pengaturan"},{title:"Akun",path:"/app/pengaturan/akun"}]}),e.jsx(g,{data:r.data??[],column:c,pagination:!0,item_per_page:15,search:!0,buttons:e.jsx(h,{className:"btn btn-primary",icon:e.jsx(j,{size:18}),onClick:()=>{n.open()},children:"Tambah Akun"})})]}),n.modal]})}export{q as default};
