Files
aso/public/dashboard/assets/Index.f3d723b1.js
2023-02-15 10:14:20 +07:00

2 lines
5.5 KiB
JavaScript

import{H as G}from"./HeaderBreadcrumbs.ee9f8edb.js";import{P as $}from"./Page.3eb9727b.js";import{a as H,aT as j,a0 as N,r as l,t as q,P,f as e,S as I,j as t,i as w,$ as m,au as C,g as K,bL as D,aB as M,B as U,T as Y,Y as R,av as J,I as Q,aU as L,ap as V,C as X}from"./index.0faebef5.js";import{d as Z,a as ee}from"./KeyboardArrowRight.7395f55e.js";import{d as ae}from"./Add.5b61a821.js";import{B as te}from"./BasePagination.d5aceb52.js";import{C as ne}from"./Card.22d2456b.js";import{T as re}from"./TableContainer.364c29dd.js";import{T as ie,a as S,b as g,c as i}from"./TableRow.ed50c5b9.js";import{B as le}from"./ButtonGroup.e4fa49f2.js";import{G as o}from"./Grid.2ab88907.js";import{D as oe,a as se}from"./DialogContent.7d5a9c36.js";import{D as ce}from"./DialogContentText.e127bb83.js";import{D as de}from"./DialogActions.59182940.js";import{S as he}from"./Search.f7fc3919.js";import"./jsx-runtime_commonjs-proxy.54cae7fc.js";function pe(){H(),j();const[c,h]=N();l.exports.useState(null),q(P)(({theme:n})=>({textAlign:"left"}));function A(n){const a=l.exports.useRef(null),[r,x]=l.exports.useState(""),T=s=>{var d;const B=(d=s.target.value)!=null?d:"";x(B)},u=s=>{s.preventDefault(),n.onSearch(r)};return l.exports.useEffect(()=>{var s;x((s=c.get("search"))!=null?s:"")},[c]),e("form",{onSubmit:u,style:{width:"100%"},children:e(J,{id:"search-input",ref:a,variant:"outlined",fullWidth:!0,onChange:T,value:r,InputProps:{startAdornment:e(Q,{position:"start",children:e(he,{})}),placeholder:"Search"}})})}function F(n){return t(I,{direction:"row",spacing:2,sx:{p:2,justifyContent:"flex-end",alignItems:"center"},children:[e(A,{onSearch:W}),e(w,{to:"/master/hospitals/create",style:{textDecoration:"none"},children:e(m,{variant:"outlined",startIcon:e(ae,{}),sx:{p:1.8},children:"Create"})})]})}function O(n){const{row:a}=n,[r,x]=C.useState(!1),[T,u]=C.useState(!1),s=B=>{R.delete(`/organizations/${a.id}`).then(d=>{v({...p,data:p.data.filter(b=>b.id!=a.id)}),L("Data berhasil dihapus",{variant:"success"})}).catch(d=>{var b,_;L((_=(b=d.response.data.message)!=null?b:d.message)!=null?_:"Failed Processing Request",{variant:"error"})})};return t(C.Fragment,{children:[t(g,{sx:{backgroundColor:r?"rgba(244, 246, 248, 0.5)":"#fff","& > *":{borderBottom:"unset"}},children:[e(i,{children:e(K,{"aria-label":"expand row",size:"small",onClick:()=>x(!r),children:r?e(Z,{}):e(ee,{})})}),e(i,{align:"left",children:a.name}),e(i,{align:"left",children:a.phone}),e(i,{align:"left",children:a.address}),e(i,{align:"right",children:t(le,{variant:"text","aria-label":"text button group",children:[e(w,{to:"/master/hospitals/"+a.id+"/edit",children:e(m,{children:e(D,{icon:"ph:pencil-simple-fill",style:{width:"24px",height:"24px"}})})}),e(m,{onClick:()=>{u(!0)},children:e(D,{icon:"eva:trash-2-outline",style:{width:"24px",height:"24px"}})})]})})]}),e(g,{children:e(i,{style:{paddingBottom:0,paddingTop:0,backgroundColor:"rgba(244, 246, 248, 0.5)"},colSpan:6,children:e(M,{in:r,timeout:"auto",unmountOnExit:!0,children:e(U,{sx:{margin:1,pb:2,pl:4},children:e(o,{container:!0,children:e(o,{item:!0,xs:6,sx:{padding:2},children:t(o,{container:!0,children:[e(o,{item:!0,xs:6,children:"Kode Rumah Sakit"}),t(o,{item:!0,xs:6,children:[": ",a.code?a.code:"-"]}),e(o,{item:!0,xs:6,children:"Longitude"}),t(o,{item:!0,xs:6,children:[": ",a.lng?a.lng:"-"]}),e(o,{item:!0,xs:6,children:"Latittude"}),t(o,{item:!0,xs:6,children:[": ",a.lat?a.lat:"-"]})]})})})})})})}),t(oe,{open:T,onClose:()=>{u(!1)},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[t(se,{sx:{p:5},children:[e(D,{icon:"eva:trash-2-outline",style:{width:"100px",height:"100px",color:"#FF0000",margin:"auto",display:"block",marginBottom:"20px",alignContent:"center"}}),e(ce,{sx:{fontWeight:"bold",pb:1},id:"alert-dialog-title",children:"Apakah anda yakin ingin menghapus"}),t(Y,{sx:{fontWeight:"bold"},id:"alert-dialog-title",children:[a.name,"?"]})]}),t(de,{children:[e(m,{onClick:()=>{u(!1)},color:"primary",variant:"outlined",children:"Batal"}),e(m,{onClick:()=>{s(a.id)},color:"primary",variant:"contained",autoFocus:!0,children:"Hapus"})]})]})]})}const f={fontWeight:"bold"},[E,k]=l.exports.useState(!0);l.exports.useState(0),l.exports.useState("idle");const[p,v]=l.exports.useState({current_page:1,data:[],path:"",first_page_url:"",last_page:1,last_page_url:"",next_page_url:"",prev_page_url:"",per_page:10,from:0,to:0,total:0});l.exports.useState(5);const y=async(n=null)=>{k(!0);const a=n||Object.fromEntries([...c.entries()]),r=await R.get("/organizations",{params:a});console.log(r.data),k(!1),v(r.data)},W=async n=>{await y({search:n}),h({search:n})},z=(n,a)=>{const r=Object.fromEntries([...c.entries(),["page",a]]);y(r),h(r)};return l.exports.useEffect(()=>{y()},[]),e(I,{children:t(ne,{sx:{marginTop:"30px"},children:[e(F,{sx:{marginTop:"100px"}}),e(re,{component:P,children:t(ie,{"aria-label":"collapsible table",children:[e(S,{children:t(g,{children:[e(i,{style:f,align:"left"}),e(i,{style:f,align:"left",children:"Rumah Sakit"}),e(i,{style:f,align:"left",children:"Nomor IGD"}),e(i,{style:f,align:"left",children:"Alamat"})]})}),E?e(S,{children:e(g,{children:e(i,{colSpan:8,align:"center",children:"Loading"})})}):p.data.length==0?e(S,{children:e(g,{children:e(i,{colSpan:8,align:"center",children:"No Data"})})}):e(S,{children:p.data.map(n=>e(O,{row:n},n.id))})]})}),e(te,{paginationData:p,onPageChange:z})]})})}function Ie(){const{themeStretch:c}=V();j();const h="Rumah Sakit";return e($,{title:h,children:t(X,{maxWidth:c?!1:"xl",children:[e(G,{heading:h,links:[{name:"Master",href:"/master"},{name:"Rumah Sakit",href:"/master/hospitals"}]}),e(pe,{})]})})}export{Ie as default};