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

2 lines
5.7 KiB
JavaScript

import{H as Z}from"./HeaderBreadcrumbs.da67f38c.js";import{P as ee}from"./Page.4c1db0aa.js";import{al as $,bi as O,aQ as te,r as i,j as l,S,f as e,P as ae,ar as B,aq as m,bn as ne,ax as z,B as F,g as re,ay as le,T as oe,az as M,as as ie,aR as W}from"./index.8f299a7d.js";import{d as se,a as ce}from"./KeyboardArrowRight.3ee3e2fb.js";import{d as de}from"./Add.06de942b.js";import{d as ue}from"./Upload.e0210d35.js";import{B as pe,d as he}from"./Cancel.e6e714f4.js";import{B as me}from"./BasePagination.56fc59df.js";import{C as A}from"./Card.1ec83a31.js";import{T as fe}from"./TableContainer.b8d5000e.js";import{T as ge,a as y,b as f,c as t}from"./TableRow.d2ef76cd.js";import"./jsx-runtime_commonjs-proxy.e03e6edd.js";function be(){$();const{corporate_id:g}=O(),[b,D]=te(),[v,q]=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 U(a){var P,R,E,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)},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}))},X=p=>{p.target.files[0]?s(p.target.files[0].name):s(null)},Y=()=>{var p,N;if((p=o.current)!=null&&p.files.length){const j=new FormData;j.append("file",(N=o.current)==null?void 0:N.files[0]),M.post(`corporates/${g}/import-plan-benefit`,j).then(_=>{I(),x(),q(_.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:X,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(z,{onClick:k,children:"Import"}),e(z,{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(m,{onClick:k,fullWidth:!0,children:u!=null?u:"No File Selected"}),e(m,{onClick:I,size:"small",fullWidth:!1,sx:{p:1.8},children:e(he,{color:"error"})})]}),e(m,{id:"upload-button",variant:"outlined",startIcon:e(ue,{}),sx:{p:1.8},onClick:Y,children:"Upload"})]}),v&&e(S,{direction:"row",sx:{px:2,pb:2},children:l(F,{sx:{color:"text.secondary"},children:["Last Import Result Report : ",e("a",{href:(R=(P=v.result_file)==null?void 0:P.url)!=null?R:"#",children:(L=(E=v.result_file)==null?void 0:E.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[Q,w]=i.exports.useState(!0);i.exports.useState(0),i.exports.useState("idle");const[C,V]=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),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 i.exports.useEffect(()=>{x()},[]),l(S,{children:[e(U,{}),l(A,{children:[e(fe,{component:ae,children:l(ge,{"aria-label":"collapsible table",children:[e(y,{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"})]})}),Q?e(y,{children:e(f,{children:e(t,{colSpan:8,align:"center",children:"Loading"})})}):C.data.length==0?e(y,{children:e(f,{children:e(t,{colSpan:8,align:"center",children:"No Data"})})}):e(y,{children:C.data.map(a=>e(G,{row:a},a.id))})]})}),e(me,{paginationData:C,onPageChange:K})]})]})}function Pe(){$(),O();const g="Diagnosis";return l(ee,{title:g,children:[e(Z,{heading:g,links:[{name:"Master",href:"/master"},{name:"Diagnosis",href:"/master/diagnosis"}]}),e(A,{children:e(be,{})})]})}export{Pe as default};