import{r as c,j as a}from"./login-aN2dRsX6.js";import{j as x,I as j}from"./query-c3dDncii.js";import{b as f,a as b}from"./alert-CsXKWu2a.js";import{B as p}from"./button_submit-wN0ayemz.js";import{D as N}from"./DataTable-D2rA17vR.js";import{P as v}from"./page_header-wdV8ucix.js";import{M as i}from"./Modal-Dn58D0E5.js";import{S as B}from"./save-CB8xeERj.js";import{C as g}from"./circle-plus-D9wc3WnO.js";import{E as k}from"./eye-By1xm0Dd.js";import"./app-gmlkJjeD.js";import"./ThemeProvider-Cx_yflmw.js";import"./search-4uBqei5W.js";import"./createLucideIcon-C44k9nIN.js";import"./delete-PVCdpT-9.js";import"./index-Ci65TyJp.js";import"./setPrototypeOf-B4fUID9J.js";const w=({onSubmit:t})=>{const[l,o]=c.useState(!1),[e,s]=c.useState(),d=n=>{n&&s(n),o(!0)},r=()=>{o(!1)},u=()=>{s(void 0)},m=c.useCallback(n=>{s(h=>({...h,[n.target.name]:n.target.value.toUpperCase()}))},[]);return{modal:c.useMemo(()=>a.jsxs(i,{show:l,onHide:r,onExited:u,children:[a.jsx(i.Header,{closeButton:!0,children:a.jsx("h5",{className:"m-0",children:"Data Bank"})}),a.jsxs(i.Body,{children:[a.jsxs("div",{className:"row mb-2",children:[a.jsx("label",{className:"col-form-label col-md-4",children:"Nama Bank"}),a.jsx("div",{className:"col-md-8",children:a.jsx("input",{className:"form-control",name:"nama",value:(e==null?void 0:e.nama)||"",onChange:m})})]}),a.jsxs("div",{className:"row mb-2",children:[a.jsx("label",{className:"col-form-label col-md-4",children:"Alamat"}),a.jsx("div",{className:"col-md-8",children:a.jsx("input",{className:"form-control",name:"alamat",value:(e==null?void 0:e.alamat)||"",onChange:m})})]}),a.jsxs("div",{className:"row mb-2",children:[a.jsx("label",{className:"col-form-label col-md-4",children:"Nomor Telp"}),a.jsx("div",{className:"col-md-8",children:a.jsx("input",{className:"form-control",name:"nomor_telp",value:(e==null?void 0:e.nomor_telp)||"",onChange:m})})]})]}),a.jsxs(i.Footer,{children:[a.jsx("button",{className:"btn btn-primary",onClick:r,children:"Tutup"}),a.jsx(p,{className:"btn-success",disable:!e,icon:a.jsx(B,{size:18}),onClick:async()=>{t&&await t(e)&&r()},children:"Simpan"})]})]}),[e,m,t,l]),open:d,close:r}};function J(){const t=x(),l=w({onSubmit:async e=>{const s=await j(e),d=await s.json();return s.status==200||s.status==201?(t.refetch(),await f("Bank berhasil disimpan"),!0):(await b(d.message),!1)}}),o=[{label:"Nama Bank",value:e=>e.nama},{label:"Alamat",value:e=>e.alamat},{label:a.jsx("center",{children:"No. Telp"}),width:200,align:"center",value:e=>e.nomor_telp},{label:a.jsx("center",{}),width:80,align:"center",value:e=>a.jsx("span",{onClick:()=>l.open(e),className:"c-pointer",children:a.jsx(k,{size:18})})}];return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"container",children:[a.jsx(v,{title:"Data Bank",breadcrumb:[{title:"Pengaturan",path:"/app/pengaturan"},{title:"Bank",path:"/app/pengaturan/bank"}]}),a.jsx(N,{data:t.data??[],column:o,search:!0,pagination:!0,item_per_page:15,buttons:a.jsx(p,{className:"btn btn-primary",onClick:l.open,icon:a.jsx(g,{size:18}),children:"Tambah Bank"})})]}),l.modal]})}export{J as default};
