Files
aso/public/dashboard/assets/Index.f44e6ea6.js
2023-02-15 10:47:39 +07:00

2 lines
5.7 KiB
JavaScript

import{H as X}from"./HeaderBreadcrumbs.91259cd4.js";import{P as Z}from"./Page.c2cde06d.js";import{ap as W,aT as z,a0 as ee,r as i,j as l,S,f as e,P as te,au as B,$ as m,bI as ae,aA as j,B as F,g as ne,aB as re,T as le,Y as M,av as oe}from"./index.eaf14aef.js";import{d as ie,a as se}from"./KeyboardArrowRight.f797f999.js";import{d as ce}from"./Add.abe475ec.js";import{d as de}from"./Upload.3b9ac474.js";import{d as ue}from"./Cancel.f9f3a05e.js";import{B as pe}from"./BasePagination.48b4da63.js";import{C as A}from"./Card.4687a3ba.js";import{T as he}from"./TableContainer.cdb185b9.js";import{T as me,a as v,b as f,c as t}from"./TableRow.9c0fd6dd.js";import{B as fe}from"./ButtonGroup.227d2582.js";import"./jsx-runtime_commonjs-proxy.20d2a437.js";function ge(){W();const{corporate_id:g}=z(),[b,D]=ee(),[y,O]=i.exports.useState(null);function q(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(oe,{id:"search-input",ref:n,label:"Search",variant:"outlined",fullWidth:!0,onChange:o,value:r})})}function H(a){var P,E,R,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)},w=()=>{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}))},K=p=>{p.target.files[0]?s(p.target.files[0].name):s(null)},Q=()=>{var p,N;if((p=o.current)!=null&&p.files.length){const $=new FormData;$.append("file",(N=o.current)==null?void 0:N.files[0]),M.post(`corporates/${g}/import-plan-benefit`,$).then(_=>{I(),x(),O(_.data)}).catch(_=>{enqueueSnackbar("Looks like something went wrong. Please check your data and try again. "+_.message,{variant:"error"})})}else enqueueSnackbar("No File Selected",{variant:"warning"})};return l("div",{children:[e("input",{type:"file",id:"file",ref:o,style:{display:"none"},onChange:K,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(q,{onSearch:Y}),e(m,{id:"import-button",variant:"outlined",startIcon:e(ce,{}),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(j,{onClick:w,children:"Import"}),e(j,{onClick:h,children:"Download Template"})]})]}),u&&l(S,{direction:"row",spacing:2,sx:{p:2},children:[l(fe,{variant:"outlined","aria-label":"outlined button group",fullWidth:!0,children:[e(m,{onClick:w,fullWidth:!0,children:u!=null?u:"No File Selected"}),e(m,{onClick:I,size:"small",fullWidth:!1,sx:{p:1.8},children:e(ue,{color:"error"})})]}),e(m,{id:"upload-button",variant:"outlined",startIcon:e(de,{}),sx:{p:1.8},onClick:Q,children:"Upload"})]}),y&&e(S,{direction:"row",sx:{px:2,pb:2},children:l(F,{sx:{color:"text.secondary"},children:["Last Import Result Report : ",e("a",{href:(E=(P=y.result_file)==null?void 0:P.url)!=null?E:"#",children:(L=(R=y.result_file)==null?void 0:R.name)!=null?L:"-"})]})})]})}function U(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(ne,{"aria-label":"expand row",size:"small",onClick:()=>c(!r),children:r?e(ie,{}):e(se,{})})}),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(re,{in:r,timeout:"auto",unmountOnExit:!0,children:e(F,{sx:{borderBottom:1},children:l(le,{variant:"body2",gutterBottom:!0,component:"div",children:["Description : ",n.description]})})})})})]})}const[G,k]=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)=>{k(!0);const n=a||Object.fromEntries([...b.entries()]),r=await M.get("/master/drugs",{params:n});k(!1),V(r.data)},d={fontWeight:"bold"},Y=async a=>{await x({search:a}),D({search:a})},J=(a,n)=>{const r=Object.fromEntries([...b.entries(),["page",n]]);x(r),D(r)};return i.exports.useEffect(()=>{x()},[]),l(S,{children:[e(H,{}),l(A,{children:[e(he,{component:te,children:l(me,{"aria-label":"collapsible table",children:[e(v,{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"})]})}),G?e(v,{children:e(f,{children:e(t,{colSpan:8,align:"center",children:"Loading"})})}):C.data.length==0?e(v,{children:e(f,{children:e(t,{colSpan:8,align:"center",children:"No Data"})})}):e(v,{children:C.data.map(a=>e(U,{row:a},a.id))})]})}),e(pe,{paginationData:C,onPageChange:J})]})]})}function Pe(){W(),z();const g="Drug";return l(Z,{title:g,children:[e(X,{heading:g,links:[{name:"Master",href:"/master"},{name:"Drug",href:"/master/drugs"}]}),e(A,{children:e(ge,{})})]})}export{Pe as default};