Files
aso/public/dashboard/assets/Index.91130f5d.js
2022-08-15 12:44:36 +07:00

2 lines
6.4 KiB
JavaScript

import{H as Z}from"./HeaderBreadcrumbs.c55c2afa.js";import{P as ee}from"./Page.08a3a680.js";import{ak as M,bg as $,bj as te,r as s,j as a,S,f as e,P as ae,aq as B,ap as f,bl as ne,aw as W,B as A,g as re,ax as le,T as b,ay as F,ar as oe}from"./index.cfad77cc.js";import{C as ie}from"./CorporateTabNavigations.d32970e1.js";import{d as se,a as ce}from"./KeyboardArrowRight.e1fc3789.js";import{d as de}from"./Add.30b0a8ee.js";import{d as ue}from"./Upload.b5418407.js";import{B as pe,d as he}from"./Cancel.134495b9.js";import{B as me}from"./BasePagination.095754c1.js";import{C as z}from"./Card.3fda610a.js";import{T as ge,a as fe,b as C,c as v,d as n}from"./TableRow.8f9db011.js";import"./jsx-runtime_commonjs-proxy.a46fd57f.js";function be(){M();const{corporate_id:x}=$(),[p,w]=te(),[_,G]=s.exports.useState(null);function H(l){const t=s.exports.useRef(null),[o,u]=s.exports.useState(""),r=i=>{var d;const g=(d=i.target.value)!=null?d:"";u(g)},c=i=>{i.preventDefault(),l.onSearch(o)};return s.exports.useEffect(()=>{var i;u((i=p.get("search"))!=null?i:"")},[p]),e("form",{onSubmit:c,style:{width:"100%"},children:e(oe,{id:"search-input",ref:t,label:"Search",variant:"outlined",fullWidth:!0,onChange:r,value:o})})}function U(l){var E,j,R,N;const[t,o]=B.useState(null),u=Boolean(t),r=s.exports.useRef(null),[c,i]=s.exports.useState(null),g=m=>{o(m.currentTarget)},d=()=>{o(null)},I=()=>{r!=null&&r.current?(d(),r.current?r.current.click():console.log("No File selected")):alert("No file selected")},P=()=>{r.current.value="",r.current.dispatchEvent(new Event("change",{bubbles:!0}))},X=m=>{m.target.files[0]?i(m.target.files[0].name):i(null)},Y=()=>{var m,L;if((m=r.current)!=null&&m.files.length){const O=new FormData;O.append("file",(L=r.current)==null?void 0:L.files[0]),F.post(`corporates/${x}/diagnosis-exclusions/import`,O).then(k=>{P(),y(),G(k.data)}).catch(k=>{alert("Looks like something went wrong. Please check your data and try again. "+k.message)})}else alert("No File Selected")};return a("div",{children:[e("input",{type:"file",id:"file",ref:r,style:{display:"none"},onChange:X,accept:".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"}),!c&&a(S,{direction:"row",spacing:2,sx:{p:2},children:[e(H,{onSearch:Q}),e(f,{id:"import-button",variant:"outlined",startIcon:e(de,{}),sx:{p:1.8},"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,onClick:g,children:"Import"}),a(ne,{id:"import-button",anchorEl:t,open:u,onClose:d,MenuListProps:{"aria-labelledby":"basic-button"},children:[e(W,{onClick:I,children:"Import"}),e(W,{onClick:d,children:"Download Template"})]})]}),c&&a(S,{direction:"row",spacing:2,sx:{p:2},children:[a(pe,{variant:"outlined","aria-label":"outlined button group",fullWidth:!0,children:[e(f,{onClick:I,fullWidth:!0,children:c!=null?c:"No File Selected"}),e(f,{onClick:P,size:"small",fullWidth:!1,sx:{p:1.8},children:e(he,{color:"error"})})]}),e(f,{id:"upload-button",variant:"outlined",startIcon:e(ue,{}),sx:{p:1.8},onClick:Y,children:"Upload"})]}),_&&e(S,{direction:"row",sx:{px:2,pb:2},children:a(A,{sx:{color:"text.secondary"},children:["Last Import Result Report : ",e("a",{href:(j=(E=_.result_file)==null?void 0:E.url)!=null?j:"#",children:(N=(R=_.result_file)==null?void 0:R.name)!=null?N:"-"})]})})]})}function q(l){var r,c,i,g,d;const{row:t}=l,[o,u]=B.useState(!1);return a(B.Fragment,{children:[a(v,{sx:{"& > *":{borderBottom:"unset"}},children:[e(n,{children:e(re,{"aria-label":"expand row",size:"small",onClick:()=>u(!o),children:o?e(se,{}):e(ce,{})})}),e(n,{align:"left",children:t.service_code}),e(n,{align:"left",children:t.code}),e(n,{align:"left",children:t.name}),e(n,{align:"left",children:Object.keys(t.rules).length?"With Rules":"All"}),e(n,{align:"right",children:e(f,{variant:"outlined",color:"success",size:"small",children:"Active"})}),e(n,{align:"right",children:e(f,{variant:"outlined",color:"error",size:"small",children:"Disable"})})]}),e(v,{children:e(n,{style:{paddingBottom:0,paddingTop:0},colSpan:99,children:e(le,{in:o,timeout:"auto",unmountOnExit:!0,children:e(A,{sx:{borderBottom:1},children:Object.keys(t.rules).length?a("div",{children:[e(b,{variant:"body",sx:{fontWeight:"bold"},children:"Excluded Only for :"}),t.rules.msc&&a(b,{variant:"body",component:"div",children:["MSC : ",(r=t.rules.msc.join(", "))!=null?r:"-"]}),t.rules.gender&&a(b,{variant:"body",component:"div",children:["Gender : ",(c=t.rules.gender.join(", "))!=null?c:"-"]}),(t.rules.min_age||t.rules.max_age)&&a(b,{variant:"body",component:"div",children:["Age : ",(i=t.rules.min_age)!=null?i:"-"," - ",(g=t.rules.max_age)!=null?g:"-"]}),t.rules.plan&&a(b,{variant:"body",component:"div",children:["Plan : ",(d=t.rules.plan.join(", "))!=null?d:"-"]})]}):e(b,{variant:"body2",gutterBottom:!0,component:"div",children:"Excluded for All"})})})})})]})}const[J,D]=s.exports.useState(!0);s.exports.useState(0),s.exports.useState("idle");const[T,K]=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}),y=async(l=null)=>{D(!0);const t=l||Object.fromEntries([...p.entries()]),o=await F.get("/corporates/"+x+"/diagnosis-exclusions",{params:t});D(!1),K(o.data)},h={fontWeight:"bold"},Q=async l=>{await y({search:l}),w({search:l})},V=(l,t)=>{const o=Object.fromEntries([...p.entries(),["page",t]]);y(o),w(o)};return s.exports.useEffect(()=>{y()},[]),a(S,{children:[e(U,{}),a(z,{children:[e(ge,{component:ae,children:a(fe,{"aria-label":"collapsible table",children:[e(C,{children:a(v,{children:[e(n,{style:h,align:"left"}),e(n,{style:h,align:"left",children:"Service"}),e(n,{style:h,align:"left",children:"Code"}),e(n,{style:h,align:"left",children:"Name"}),e(n,{style:h,align:"left",children:"Rules"}),e(n,{style:h,align:"right",children:"Status"}),e(n,{style:h,align:"right",children:"Action"})]})}),J?e(C,{children:e(v,{children:e(n,{colSpan:8,align:"center",children:"Loading"})})}):T.data.length==0?e(C,{children:e(v,{children:e(n,{colSpan:8,align:"center",children:"No Data"})})}):e(C,{children:T.data.map(l=>e(q,{row:l},l.id))})]})}),e(me,{paginationData:T,onPageChange:V})]})]})}function Pe(){M();const{corporate_id:x}=$(),p="Diagnosis Exclusion";return a(ee,{title:p,children:[e(Z,{heading:p,links:[{name:"Corporates",href:"/corporates"},{name:"Corporate Name",href:"/corporates/"+x},{name:"Diagnosis Exclusion",href:"/corporates/"+x+"/diagnosis-exclusions"}]}),e(ie,{position:"diagnosis-exclusions"}),e(z,{children:e(be,{})})]})}export{Pe as default};