Files
aso/public/dashboard/assets/Index.3108f9c7.js
2023-02-15 10:47:39 +07:00

2 lines
5.7 KiB
JavaScript

import{H as Z}from"./HeaderBreadcrumbs.91259cd4.js";import{P as ee}from"./Page.c2cde06d.js";import{ap as z,aT as A,a0 as te,r as i,j as l,S,f as e,P as ae,au as B,$ as m,bI as ne,aA as j,B as F,g as re,aB as le,T as oe,Y as M,av as ie,aU as W}from"./index.eaf14aef.js";import{d as se,a as ce}from"./KeyboardArrowRight.f797f999.js";import{d as de}from"./Add.abe475ec.js";import{d as ue}from"./Upload.3b9ac474.js";import{d as pe}from"./Cancel.f9f3a05e.js";import{B as he}from"./BasePagination.48b4da63.js";import{C as O}from"./Card.4687a3ba.js";import{T as me}from"./TableContainer.cdb185b9.js";import{T as fe,a as v,b as f,c as t}from"./TableRow.9c0fd6dd.js";import{B as ge}from"./ButtonGroup.227d2582.js";import"./jsx-runtime_commonjs-proxy.20d2a437.js";function be(){z();const{corporate_id:g}=A(),[b,D]=te(),[y,U]=i.exports.useState(null);function H(a){const n=i.exports.useRef(null),[r,c]=i.exports.useState(""),o=s=>{var h;const T=(h=s.target.value)!=null?h:"";c(T)},u=s=>{s.preventDefault(),a.onSearch(r)};return i.exports.useEffect(()=>{var s;c((s=b.get("search"))!=null?s:"")},[b]),e("form",{onSubmit:u,style:{width:"100%"},children:e(ie,{id:"search-input",ref:n,label:"Search",variant:"outlined",fullWidth:!0,onChange:o,value:r})})}function q(a){var P,E,R,L;const[n,r]=B.useState(null),c=Boolean(n),o=i.exports.useRef(null),[u,s]=i.exports.useState(null),T=p=>{r(p.currentTarget)},h=()=>{r(null)},I=()=>{o!=null&&o.current?(h(),o.current?o.current.click():console.log("No File selected")):alert("No file selected")},k=()=>{o.current.value="",o.current.dispatchEvent(new Event("change",{bubbles:!0}))},Q=p=>{p.target.files[0]?s(p.target.files[0].name):s(null)},X=()=>{var p,N;if((p=o.current)!=null&&p.files.length){const $=new FormData;$.append("file",(N=o.current)==null?void 0:N.files[0]),M.post(`corporates/${g}/import-plan-benefit`,$).then(_=>{k(),x(),U(_.data)}).catch(_=>{W("Looks like something went wrong. Please check your data and try again. "+_.message,{variant:"error"})})}else W("No File Selected",{variant:"warning"})};return l("div",{children:[e("input",{type:"file",id:"file",ref:o,style:{display:"none"},onChange:Q,accept:".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"}),!u&&l(S,{direction:"row",spacing:2,sx:{p:2},children:[e(H,{onSearch:J}),e(m,{id:"import-button",variant:"outlined",startIcon:e(de,{}),sx:{p:1.8},"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:T,children:"Import"}),l(ne,{id:"import-button",anchorEl:n,open:c,onClose:h,MenuListProps:{"aria-labelledby":"basic-button"},children:[e(j,{onClick:I,children:"Import"}),e(j,{onClick:h,children:"Download Template"})]})]}),u&&l(S,{direction:"row",spacing:2,sx:{p:2},children:[l(ge,{variant:"outlined","aria-label":"outlined button group",fullWidth:!0,children:[e(m,{onClick:I,fullWidth:!0,children:u!=null?u:"No File Selected"}),e(m,{onClick:k,size:"small",fullWidth:!1,sx:{p:1.8},children:e(pe,{color:"error"})})]}),e(m,{id:"upload-button",variant:"outlined",startIcon:e(ue,{}),sx:{p:1.8},onClick:X,children:"Upload"})]}),y&&e(S,{direction:"row",sx:{px:2,pb:2},children:l(F,{sx:{color:"text.secondary"},children:["Last Import Result Report : ",e("a",{href:(E=(P=y.result_file)==null?void 0:P.url)!=null?E:"#",children:(L=(R=y.result_file)==null?void 0:R.name)!=null?L:"-"})]})})]})}function G(a){const{row:n}=a,[r,c]=B.useState(!1);return l(B.Fragment,{children:[l(f,{sx:{"& > *":{borderBottom:"unset"}},children:[e(t,{children:e(re,{"aria-label":"expand row",size:"small",onClick:()=>c(!r),children:r?e(se,{}):e(ce,{})})}),e(t,{align:"left",children:n.type}),e(t,{align:"left",children:n.code}),e(t,{align:"left",children:n.name}),e(t,{align:"left",children:n.version}),e(t,{align:"right",children:e(m,{variant:"outlined",color:"success",size:"small",children:"Active"})}),e(t,{align:"right",children:e(m,{variant:"outlined",color:"error",size:"small",children:"Disable"})})]}),e(f,{children:e(t,{style:{paddingBottom:0,paddingTop:0},colSpan:99,children:e(le,{in:r,timeout:"auto",unmountOnExit:!0,children:e(F,{sx:{borderBottom:1},children:l(oe,{variant:"body2",gutterBottom:!0,component:"div",children:["Description : ",n.description]})})})})})]})}const[V,w]=i.exports.useState(!0);i.exports.useState(0),i.exports.useState("idle");const[C,Y]=i.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});i.exports.useState(5);const x=async(a=null)=>{w(!0);const n=a||Object.fromEntries([...b.entries()]),r=await M.get("/master/diagnosis",{params:n});w(!1),Y(r.data)},d={fontWeight:"bold"},J=async a=>{await x({search:a}),D({search:a})},K=(a,n)=>{const r=Object.fromEntries([...b.entries(),["page",n]]);x(r),D(r)};return i.exports.useEffect(()=>{x()},[]),l(S,{children:[e(q,{}),l(O,{children:[e(me,{component:ae,children:l(fe,{"aria-label":"collapsible table",children:[e(v,{children:l(f,{children:[e(t,{style:d,align:"left"}),e(t,{style:d,align:"left",children:"Type"}),e(t,{style:d,align:"left",children:"Code"}),e(t,{style:d,align:"left",children:"Name"}),e(t,{style:d,align:"left",children:"Version"}),e(t,{style:d,align:"right",children:"Status"}),e(t,{style:d,align:"right",children:"Action"})]})}),V?e(v,{children:e(f,{children:e(t,{colSpan:8,align:"center",children:"Loading"})})}):C.data.length==0?e(v,{children:e(f,{children:e(t,{colSpan:8,align:"center",children:"No Data"})})}):e(v,{children:C.data.map(a=>e(G,{row:a},a.id))})]})}),e(he,{paginationData:C,onPageChange:K})]})]})}function Ee(){z(),A();const g="Diagnosis";return l(ee,{title:g,children:[e(Z,{heading:g,links:[{name:"Master",href:"/master"},{name:"Diagnosis",href:"/master/diagnosis"}]}),e(O,{children:e(be,{})})]})}export{Ee as default};