Files
aso/public/dashboard/assets/Index.9d195342.js
2023-02-01 19:39:33 +07:00

2 lines
5.0 KiB
JavaScript

import{H as W}from"./HeaderBreadcrumbs.48c93fe3.js";import{P as G}from"./Page.1b52de0c.js";import{a as H,aT as L,a0 as N,r as s,t as $,P,f as e,S as _,j as n,au as D,g as q,aB as K,B as M,bL as U,T as Y,$ as I,Y as w,av as J,I as Q,aU as R,ap as V,C as X}from"./index.2830a4a3.js";import{d as Z,a as ee}from"./KeyboardArrowRight.833db889.js";import{B as ae}from"./BasePagination.a0790cbf.js";import{C as te}from"./Card.86cb2364.js";import{T as ne}from"./TableContainer.07a91927.js";import{T as re,a as b,b as p,c as i}from"./TableRow.678d5f59.js";import{G as o}from"./Grid.f80372c7.js";import{D as ie,a as se}from"./DialogContent.417e0630.js";import{D as oe}from"./DialogContentText.57a6aef2.js";import{D as le}from"./DialogActions.1e9d9799.js";import{S as ce}from"./Search.03c71e18.js";import"./jsx-runtime_commonjs-proxy.92370fb9.js";function de(){H(),L();const[c,d]=N();s.exports.useState(null),$(P)(({theme:t})=>({textAlign:"left"}));function j(t){const a=s.exports.useRef(null),[r,m]=s.exports.useState(""),T=l=>{var y;const f=(y=l.target.value)!=null?y:"";m(f)},g=l=>{l.preventDefault(),t.onSearch(r)};return s.exports.useEffect(()=>{var l;m((l=c.get("search"))!=null?l:"")},[c]),e("form",{onSubmit:g,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(ce,{})}),placeholder:"Search"}})})}function A(t){return e(_,{direction:"row",spacing:2,sx:{p:2,justifyContent:"flex-end",alignItems:"center"},children:e(j,{onSearch:z})})}function F(t){var f;const{row:a}=t,[r,m]=D.useState(!1),[T,g]=D.useState(!1),l=y=>{w.delete(`/organizations/${a.id}`).then(C=>{v({...h,data:h.data.filter(x=>x.id!=a.id)}),R("Data berhasil dihapus",{variant:"success"})}).catch(C=>{var x,B;R((B=(x=C.response.data.message)!=null?x:C.message)!=null?B:"Failed Processing Request",{variant:"error"})})};return n(D.Fragment,{children:[n(p,{sx:{backgroundColor:r?"rgba(244, 246, 248, 0.5)":"#fff","& > *":{borderBottom:"unset"}},children:[e(i,{children:e(q,{"aria-label":"expand row",size:"small",onClick:()=>m(!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:(f=a.address)==null?void 0:f.text})]}),e(p,{children:e(i,{style:{paddingBottom:0,paddingTop:0,backgroundColor:"rgba(244, 246, 248, 0.5)"},colSpan:6,children:e(K,{in:r,timeout:"auto",unmountOnExit:!0,children:e(M,{sx:{margin:1,pb:2,pl:4},children:e(o,{container:!0,children:e(o,{item:!0,xs:6,sx:{padding:2},children:n(o,{container:!0,children:[e(o,{item:!0,xs:6,children:"Kode Rumah Sakit"}),n(o,{item:!0,xs:6,children:[": ",a.code?a.code:"-"]}),e(o,{item:!0,xs:6,children:"Longitude"}),n(o,{item:!0,xs:6,children:[": ",a.lng?a.lng:"-"]}),e(o,{item:!0,xs:6,children:"Latittude"}),n(o,{item:!0,xs:6,children:[": ",a.lat?a.lat:"-"]})]})})})})})})}),n(ie,{open:T,onClose:()=>{g(!1)},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[n(se,{sx:{p:5},children:[e(U,{icon:"eva:trash-2-outline",style:{width:"100px",height:"100px",color:"#FF0000",margin:"auto",display:"block",marginBottom:"20px",alignContent:"center"}}),e(oe,{sx:{fontWeight:"bold",pb:1},id:"alert-dialog-title",children:"Apakah anda yakin ingin menghapus"}),n(Y,{sx:{fontWeight:"bold"},id:"alert-dialog-title",children:[a.name,"?"]})]}),n(le,{children:[e(I,{onClick:()=>{g(!1)},color:"primary",variant:"outlined",children:"Batal"}),e(I,{onClick:()=>{l(a.id)},color:"primary",variant:"contained",autoFocus:!0,children:"Hapus"})]})]})]})}const u={fontWeight:"bold"},[O,k]=s.exports.useState(!0);s.exports.useState(0),s.exports.useState("idle");const[h,v]=s.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});s.exports.useState(5);const S=async(t=null)=>{k(!0);const a=t||Object.fromEntries([...c.entries()]),r=await w.get("/organizations",{params:a});console.log(r.data),k(!1),v(r.data)},z=async t=>{await S({search:t}),d({search:t})},E=(t,a)=>{const r=Object.fromEntries([...c.entries(),["page",a]]);S(r),d(r)};return s.exports.useEffect(()=>{S()},[]),e(_,{children:n(te,{sx:{marginTop:"30px"},children:[e(A,{sx:{marginTop:"100px"}}),e(ne,{component:P,children:n(re,{"aria-label":"collapsible table",children:[e(b,{children:n(p,{children:[e(i,{style:u,align:"left"}),e(i,{style:u,align:"left",children:"Rumah Sakit"}),e(i,{style:u,align:"left",children:"Nomor IGD"}),e(i,{style:u,align:"left",children:"Alamat"})]})}),O?e(b,{children:e(p,{children:e(i,{colSpan:8,align:"center",children:"Loading"})})}):h.data.length==0?e(b,{children:e(p,{children:e(i,{colSpan:8,align:"center",children:"No Data"})})}):e(b,{children:h.data.map(t=>e(F,{row:t},t.id))})]})}),e(ae,{paginationData:h,onPageChange:E})]})})}function ve(){const{themeStretch:c}=V();L();const d="Rumah Sakit";return e(G,{title:d,children:n(X,{maxWidth:c?!1:"xl",children:[e(W,{heading:d,links:[{name:"Master",href:"/master"},{name:"Rumah Sakit",href:"/master/organizations"}]}),e(de,{})]})})}export{ve as default};