1import{f as W,r as a,j as e,P as te,n as I,L as se,G as ae,H as ne,bM as B,bP as R,cC as oe,hD as le,s as S,e as N,ii as re,ij as ie,hF as de}from"./index-BiR4tHPa.js";import{s as d}from"./treatmentPrescriptionManage.module-BDv7gB7r.js";import{d as ce}from"./delete-icon-DAB442O7.js";import{A as z}from"./AddEditPrescriptionTreatmentModal-DBt6v4th.js";import{D as he}from"./DeleteConfirmationModal-DM5KwsxY.js";const je=()=>{const{t:s}=W("testManagement");W("common");let u=window.location.pathname;u=u.split("/"),u=u[u.length-1];const H=(t,n=10)=>typeof t=="string"&&t.length>n?`${t.slice(0,n)}...`:t,[f,D]=a.useState([]),[C,M]=a.useState(!1),[T,_]=a.useState(!1),[V,F]=a.useState(!1),[L,y]=a.useState({show:!1,id:""}),[G,w]=a.useState(!1),[b,me]=a.useState(window.innerWidth),[o,x]=a.useState({database_name:"yb_db",collection_name:"test_details",new_data:{test:"",status:"enabled"}}),[g,k]=a.useState(""),[h,U]=a.useState(""),[$,X]=a.useState(""),[i,E]=a.useState(0),[r,P]=a.useState(10),[A,m]=a.useState(),c=async()=>{F(!0);try{const t=await oe(r,i);console.log(t,"get dose response"),D([...t.data.document]),U(t.data.count),X(Math.ceil(t.data.count/r)),F(!1)}catch(t){console.log(t,"get dose error")}},Y=async t=>{t.preventDefault(),m(!0);try{const n=await le(o);console.log(n,"post dose response"),x({...o,new_data:{dose:"",status:"enabled"}}),S("new entry created"),c(),m(!1),j()}catch(n){console.log(n,"post dose error"),N("Something went wrong !"),m(!1)}},q=async t=>{var n;t.preventDefault(),m(!0);try{const l=await re((n=o==null?void 0:o.new_data)==null?void 0:n._id,o==null?void 0:o.new_data);console.log(l,"edit dose response"),S(l.data.message),c(),m(!1),v()}catch(l){console.log(l,"edit dose error"),N("Something went wrong !"),m(!1)}},J=async t=>{y({show:!0,id:t})},K=async()=>{var t,n;w(!0);try{w(!0),await ie(L.id),S("Test Deleted Successfully!"),c()}catch(l){N((n=(t=l==null?void 0:l.response)==null?void 0:t.data)==null?void 0:n.detail),console.log(l)}finally{w(!1),y({show:!1,id:""})}},O=async()=>{try{const t=await de("test_details",g);console.log(t,"search data response"),D([...t.data.data])}catch(t){console.log(t,"search data error")}},j=()=>{M(!C)},v=(t,n)=>{T?(_(!1),x({...o,new_data:{test:"",status:"enabled"}})):(x({...o,new_data:{_id:t,test:n,status:"enabled"}}),_(!0))},Q=()=>{y({show:!1,name:""})};a.useEffect(()=>{c()},[i,r]),a.useEffect(()=>{g.length>0?O():c()},[g]);const[Z,ee]=a.useState(!1);return a.useEffect(()=>{const t=()=>ee(window.innerWidth<=576);return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),console.log(o,"dose data"),e.jsxs("div",{children:[e.jsx(te,{activeMenu:s("title"),motherMenu:s("title"),rightActionIcon:b<576?s("add"):void 0,onRightSecondaryClick:b<576?c:void 0,onRightActionClick:b<576?j:void 0}),e.jsx("div",{className:"d-block d-sm-none mt-2",children:e.jsx("div",{className:"d-flex align-items-center justify-content-between gap-2",children:e.jsx("div",{className:"flex-fill",children:e.jsx("input",{type:"text",className:"form-control input-default",placeholder:s("searchhere"),value:g,onChange:t=>k(t.target.value),style:{height:"37px",backgroundColor:"#F6F5F5"}})})})}),e.jsxs("div",{className:"d-none d-sm-flex flex-column flex-sm-row flex-sm-nowrap justify-content-between align-items-start align-items-sm-center gap-2 my-2 ",children:[e.jsxs("div",{className:`form-group w-100 w-sm-auto ${d.searchWrap}`,children:[e.jsx("label",{htmlFor:"",style:{fontWeight:"bold"},className:`${d["search-label"]} mb-2 text-dark `,children:s("search")}),e.jsx("div",{className:`${d.searchInputWrap} ${d.searchRow}`,children:e.jsx("input",{type:"text",className:`form-control input-default ${d.searchInput}`,placeholder:s("searchhere"),value:g,onChange:t=>k(t.target.value),style:{height:"37px",marginBottom:"0.2rem",backgroundColor:"#F6F5F5"}})})]}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsx(I,{variant:"primary",onClick:j,className:`${d["btn-row"]}`,style:{marginTop:"0.5rem"},children:s("addTest")}),e.jsx(I,{variant:"primary",onClick:c,className:`${d["btn-row"]}`,style:{marginTop:"0.5rem",marginLeft:"5px"},children:s("refresh")})]})]}),V?e.jsx(se,{}):e.jsx("div",{children:e.jsx(ae,{children:e.jsx(ne,{children:e.jsx("div",{className:"table-scroll",style:{maxHeight:"55vh",overflowY:"auto",overscrollBehavior:"contain"},children:e.jsxs("table",{className:`${B.table} ${d.mobileTable}`,children:[f.length>0&&e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:"4rem"},children:e.jsx("strong",{children:s("sno")})}),e.jsx("th",{className:"width80",style:{minWidth:"12rem"},children:e.jsx("strong",{children:s("test")})}),e.jsx("th",{className:"d-none d-sm-table-cell",style:{minWidth:"8rem",textAlign:"center"},children:e.jsx("strong",{children:s("status")})}),e.jsx("th",{style:{width:"6rem",textAlign:"center"},children:e.jsx("strong",{children:s("action")})})]})}),e.jsx("tbody",{children:f.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:Z?3:4,className:"text-center",style:{padding:"5rem 0",color:"#333",fontWeight:600,fontSize:"1.5rem",border:"none"},children:s("testNotAvailable")})}):f.map((t,n)=>e.jsxs("tr",{className:`${B["table-row"]}`,children:[e.jsxs("td",{children:[i*r+n+1,"."]}
1),e.jsx("td",{children:e.jsx("strong",{onClick:()=>{v(t._id,t.test)},className:`${d["prescription-name"]} text-primary`,style:{cursor:"pointer"},children:e.jsx("span",{title:t.test,children:H(t.test,10)})})}),e.jsx("td",{className:"d-none d-sm-table-cell text-center",children:t.status}),e.jsxs("td",{className:"text-center",style:{position:"relative"},children:[e.jsx("img",{src:ce,alt:"",style:{width:"1.5rem",cursor:"pointer"},onClick:()=>J(t._id),onMouseEnter:l=>{const p=l.target.nextSibling;p.style.opacity="1",p.style.visibility="visible"},onMouseLeave:l=>{const p=l.target.nextSibling;p.style.opacity="0",p.style.visibility="hidden"}}),e.jsx("div",{style:{position:"absolute",top:"120%",left:"50%",transform:"translateX(-50%)",backgroundColor:"#000",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"0.75rem",opacity:"0",visibility:"hidden",transition:"opacity 0.2s ease, visibility 0.2s ease",whiteSpace:"nowrap",zIndex:10,pointerEvents:"none"},children:s("delete")})]})]},t._id))})]})})})})}),e.jsx(z,{modalHide:j,modalShow:C,data:o,setData:x,handleSubmit:Y,type:s("common:addtest"),btnLoader:A}),e.jsx(z,{modalHide:v,modalShow:T,data:o,setData:x,handleSubmit:q,type:s("common:edittest"),btnLoader:A}),e.jsx(he,{show:L.show,handleDeleteCancel:Q,handleDeleteConfirmation:K,loading:G}),f.length===0?"":e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"d-block d-sm-none mt-2",children:e.jsxs("div",{className:`${d.mobileFooterBox}`,children:[e.jsx("div",{className:"dataTables_info ",children:s("paginationInfo",{from:i*r+1,to:h>(i+1)*r?(i+1)*r:h,total:h})}),e.jsx("div",{className:"mt-2",children:e.jsx(R,{pageCount:$,pageValue:i,setPage:E,limit:r,setLimit:P})})]})}),e.jsx("div",{className:"card-footer clearfix mt-2 d-none d-sm-block",children:e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-2 justify-content-between align-items-center",children:[e.jsx("div",{className:"dataTables_info ",children:s("paginationInfo",{from:i*r+1,to:h>(i+1)*r?(i+1)*r:h,total:h})}),e.jsx(R,{pageCount:$,pageValue:i,setPage:E,limit:r,setLimit:P})]})})]})]})};export{je as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.