2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
import{H as Y}from"./HeaderBreadcrumbs.4d7b190c.js";import{P as Z}from"./Page.2c1cad43.js";import{ak as $,bg as z,bj as ee,r as s,j as l,S,f as e,P as te,aq as B,ap as f,bl as ae,aw as F,B as M,g as ne,ax as re,T as le,ay as W,ar as oe}from"./index.8dfdc9ed.js";import{T as se,a as ie,b as y,d as g,e as t,f as ce,g as de}from"./KeyboardArrowRight.800c6a53.js";import{d as ue}from"./Add.87c13906.js";import{B as pe,d as he,a as fe}from"./Cancel.ae8e2a32.js";import{B as ge}from"./BasePagination.6533cd11.js";import{C as O}from"./Card.57605f6f.js";function me(){$();const{corporate_id:m}=z(),[b,D]=ee(),[v,A]=s.exports.useState(null);function H(a){const n=s.exports.useRef(null),[r,c]=s.exports.useState(""),o=i=>{var h;const T=(h=i.target.value)!=null?h:"";c(T)},u=i=>{i.preventDefault(),a.onSearch(r)};return s.exports.useEffect(()=>{var i;c((i=b.get("search"))!=null?i:"")},[b]),e("form",{onSubmit:u,style:{width:"100%"},children:e(oe,{id:"search-input",ref:n,label:"Search",variant:"outlined",fullWidth:!0,onChange:o,value:r})})}function U(a){var P,E,R,L;const[n,r]=B.useState(null),c=Boolean(n),o=s.exports.useRef(null),[u,i]=s.exports.useState(null),T=p=>{r(p.currentTarget)},h=()=>{r(null)},k=()=>{o!=null&&o.current?(h(),o.current?o.current.click():console.log("No File selected")):alert("No file selected")},I=()=>{o.current.value="",o.current.dispatchEvent(new Event("change",{bubbles:!0}))},Q=p=>{p.target.files[0]?i(p.target.files[0].name):i(null)},X=()=>{var p,j;if((p=o.current)!=null&&p.files.length){const N=new FormData;N.append("file",(j=o.current)==null?void 0:j.files[0]),W.post(`corporates/${m}/import-plan-benefit`,N).then(_=>{I(),x(),A(_.data)}).catch(_=>{alert("Looks like something went wrong. Please check your data and try again. "+_.message)})}else alert("No File Selected")};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(f,{id:"import-button",variant:"outlined",startIcon:e(ue,{}),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(ae,{id:"import-button",anchorEl:n,open:c,onClose:h,MenuListProps:{"aria-labelledby":"basic-button"},children:[e(F,{onClick:k,children:"Import"}),e(F,{onClick:h,children:"Download Template"})]})]}),u&&l(S,{direction:"row",spacing:2,sx:{p:2},children:[l(pe,{variant:"outlined","aria-label":"outlined button group",fullWidth:!0,children:[e(f,{onClick:k,fullWidth:!0,children:u!=null?u:"No File Selected"}),e(f,{onClick:I,size:"small",fullWidth:!1,sx:{p:1.8},children:e(he,{color:"error"})})]}),e(f,{id:"upload-button",variant:"outlined",startIcon:e(fe,{}),sx:{p:1.8},onClick:X,children:"Upload"})]}),v&&e(S,{direction:"row",sx:{px:2,pb:2},children:l(M,{sx:{color:"text.secondary"},children:["Last Import Result Report : ",e("a",{href:(E=(P=v.result_file)==null?void 0:P.url)!=null?E:"#",children:(L=(R=v.result_file)==null?void 0:R.name)!=null?L:"-"})]})})]})}function q(a){const{row:n}=a,[r,c]=B.useState(!1);return l(B.Fragment,{children:[l(g,{sx:{"& > *":{borderBottom:"unset"}},children:[e(t,{children:e(ne,{"aria-label":"expand row",size:"small",onClick:()=>c(!r),children:r?e(ce,{}):e(de,{})})}),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(f,{variant:"outlined",color:"success",size:"small",children:"Active"})}),e(t,{align:"right",children:e(f,{variant:"outlined",color:"error",size:"small",children:"Disable"})})]}),e(g,{children:e(t,{style:{paddingBottom:0,paddingTop:0},colSpan:99,children:e(re,{in:r,timeout:"auto",unmountOnExit:!0,children:e(M,{sx:{borderBottom:1},children:l(le,{variant:"body2",gutterBottom:!0,component:"div",children:["Description : ",n.description]})})})})})]})}const[G,w]=s.exports.useState(!0);s.exports.useState(0),s.exports.useState("idle");const[C,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 x=async(a=null)=>{w(!0);const n=a||Object.fromEntries([...b.entries()]),r=await W.get("/master/diagnosis",{params:n});w(!1),V(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 s.exports.useEffect(()=>{x()},[]),l(S,{children:[e(U,{}),l(O,{children:[e(se,{component:te,children:l(ie,{"aria-label":"collapsible table",children:[e(y,{children:l(g,{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"})]})}),G?e(y,{children:e(g,{children:e(t,{colSpan:8,align:"center",children:"Loading"})})}):C.data.length==0?e(y,{children:e(g,{children:e(t,{colSpan:8,align:"center",children:"No Data"})})}):e(y,{children:C.data.map(a=>e(q,{row:a},a.id))})]})}),e(ge,{paginationData:C,onPageChange:K})]})]})}function Be(){$(),z();const m="Diagnosis";return l(Z,{title:m,children:[e(Y,{heading:m,links:[{name:"Master",href:"/master"},{name:"Diagnosis",href:"/master/diagnosis"}]}),e(O,{children:e(me,{})})]})}export{Be as default};
|