Files
aso/public/dashboard/assets/Index.adc87f81.js
2022-12-13 13:34:27 +07:00

2 lines
6.5 KiB
JavaScript

import{H as ee}from"./HeaderBreadcrumbs.da67f38c.js";import{P as te}from"./Page.4c1db0aa.js";import{al as M,bi as $,aQ as ae,r as s,j as a,S as y,f as e,P as ne,ar as B,aq as f,bn as re,ax as W,B as A,g as le,ay as oe,T as b,az as z,as as ie,aR as F}from"./index.8f299a7d.js";import{C as se}from"./CorporateTabNavigations.42a351a3.js";import{d as ce,a as de}from"./KeyboardArrowRight.3ee3e2fb.js";import{d as ue}from"./Add.06de942b.js";import{d as pe}from"./Upload.e0210d35.js";import{B as he,d as me}from"./Cancel.e6e714f4.js";import{B as ge}from"./BasePagination.56fc59df.js";import{C as q}from"./Card.1ec83a31.js";import{T as fe}from"./TableContainer.b8d5000e.js";import{T as be,a as C,b as v,c as n}from"./TableRow.d2ef76cd.js";import"./jsx-runtime_commonjs-proxy.e03e6edd.js";function xe(){M();const{corporate_id:x}=$(),[p,w]=ae(),[_,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(ie,{id:"search-input",ref:t,label:"Search",variant:"outlined",fullWidth:!0,onChange:r,value:o})})}function U(l){var E,R,j,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}))},Y=m=>{m.target.files[0]?i(m.target.files[0].name):i(null)},Z=()=>{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]),z.post(`corporates/${x}/diagnosis-exclusions/import`,O).then(k=>{P(),S(),G(k.data)}).catch(k=>{F("Looks like something went wrong. Please check your data and try again. "+k.message,{variant:"error"})})}else F("No File Selected",{variant:"warning"})};return a("div",{children:[e("input",{type:"file",id:"file",ref:r,style:{display:"none"},onChange:Y,accept:".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"}),!c&&a(y,{direction:"row",spacing:2,sx:{p:2},children:[e(H,{onSearch:V}),e(f,{id:"import-button",variant:"outlined",startIcon:e(ue,{}),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(re,{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(y,{direction:"row",spacing:2,sx:{p:2},children:[a(he,{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(me,{color:"error"})})]}),e(f,{id:"upload-button",variant:"outlined",startIcon:e(pe,{}),sx:{p:1.8},onClick:Z,children:"Upload"})]}),_&&e(y,{direction:"row",sx:{px:2,pb:2},children:a(A,{sx:{color:"text.secondary"},children:["Last Import Result Report : ",e("a",{href:(R=(E=_.result_file)==null?void 0:E.url)!=null?R:"#",children:(N=(j=_.result_file)==null?void 0:j.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(le,{"aria-label":"expand row",size:"small",onClick:()=>u(!o),children:o?e(ce,{}):e(de,{})})}),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(oe,{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}),S=async(l=null)=>{D(!0);const t=l||Object.fromEntries([...p.entries()]),o=await z.get("/corporates/"+x+"/diagnosis-exclusions",{params:t});D(!1),K(o.data)},h={fontWeight:"bold"},V=async l=>{await S({search:l}),w({search:l})},X=(l,t)=>{const o=Object.fromEntries([...p.entries(),["page",t]]);S(o),w(o)};return s.exports.useEffect(()=>{S()},[]),a(y,{children:[e(U,{}),a(q,{children:[e(fe,{component:ne,children:a(be,{"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(ge,{paginationData:T,onPageChange:X})]})]})}function Re(){M();const{corporate_id:x}=$(),p="Diagnosis Exclusion";return a(te,{title:p,children:[e(ee,{heading:p,links:[{name:"Corporates",href:"/corporates"},{name:"Corporate Name",href:"/corporates/"+x},{name:"Diagnosis Exclusion",href:"/corporates/"+x+"/diagnosis-exclusions"}]}),a(q,{children:[e(se,{position:"diagnosis-exclusions"}),e(xe,{})]})]})}export{Re as default};