Files
aso/public/dashboard/assets/Index.97b9e69e.js
2022-08-04 08:45:27 +07:00

2 lines
6.3 KiB
JavaScript

import{H as Z}from"./HeaderBreadcrumbs.4d7b190c.js";import{P as ee}from"./Page.2c1cad43.js";import{ak as M,bg as $,bj as te,r as i,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.8dfdc9ed.js";import{C as se}from"./CorporateTabNavigations.56023eb5.js";import{T as ie,a as ce,b as C,d as v,e as n,f as de,g as ue}from"./KeyboardArrowRight.800c6a53.js";import{d as he}from"./Add.87c13906.js";import{B as pe,d as ge,a as me}from"./Cancel.ae8e2a32.js";import{B as fe}from"./BasePagination.6533cd11.js";import{C as z}from"./Card.57605f6f.js";function be(){M();const{corporate_id:x}=$(),[h,w]=te(),[_,G]=i.exports.useState(null);function H(l){const t=i.exports.useRef(null),[o,u]=i.exports.useState(""),r=s=>{var d;const m=(d=s.target.value)!=null?d:"";u(m)},c=s=>{s.preventDefault(),l.onSearch(o)};return i.exports.useEffect(()=>{var s;u((s=h.get("search"))!=null?s:"")},[h]),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=i.exports.useRef(null),[c,s]=i.exports.useState(null),m=g=>{o(g.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=g=>{g.target.files[0]?s(g.target.files[0].name):s(null)},Y=()=>{var g,L;if((g=r.current)!=null&&g.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(he,{}),sx:{p:1.8},"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,onClick:m,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(ge,{color:"error"})})]}),e(f,{id:"upload-button",variant:"outlined",startIcon:e(me,{}),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,s,m,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(de,{}):e(ue,{})})}),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 : ",(s=t.rules.min_age)!=null?s:"-"," - ",(m=t.rules.max_age)!=null?m:"-"]}),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]=i.exports.useState(!0);i.exports.useState(0),i.exports.useState("idle");const[T,K]=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}),y=async(l=null)=>{D(!0);const t=l||Object.fromEntries([...h.entries()]),o=await F.get("/corporates/"+x+"/diagnosis-exclusions",{params:t});D(!1),K(o.data)},p={fontWeight:"bold"},Q=async l=>{await y({search:l}),w({search:l})},V=(l,t)=>{const o=Object.fromEntries([...h.entries(),["page",t]]);y(o),w(o)};return i.exports.useEffect(()=>{y()},[]),a(S,{children:[e(U,{}),a(z,{children:[e(ie,{component:ae,children:a(ce,{"aria-label":"collapsible table",children:[e(C,{children:a(v,{children:[e(n,{style:p,align:"left"}),e(n,{style:p,align:"left",children:"Service"}),e(n,{style:p,align:"left",children:"Code"}),e(n,{style:p,align:"left",children:"Name"}),e(n,{style:p,align:"left",children:"Rules"}),e(n,{style:p,align:"right",children:"Status"}),e(n,{style:p,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(fe,{paginationData:T,onPageChange:V})]})]})}function we(){M();const{corporate_id:x}=$(),h="Diagnosis Exclusion";return a(ee,{title:h,children:[e(Z,{heading:h,links:[{name:"Corporates",href:"/corporates"},{name:"Corporate Name",href:"/corporates/"+x},{name:"Diagnosis Exclusion",href:"/corporates/"+x+"/diagnosis-exclusions"}]}),e(se,{position:"diagnosis-exclusions"}),e(z,{children:e(be,{})})]})}export{we as default};