| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/index-Dua5zWc6.js |
import{Q as oe,r as l,w as ie,C as j,j as e,R as ce,B as f,x as Y,F as le,y as S,J as de}from"./index-f5FVPPWf.js";import{e as me}from"./index-D-rZ_zLU.js";import{u as ue}from"./SettingData-HUsgVeqA.js";import{u as pe,N as he,S as D,i as ge,C as xe,b as n,R as je,D as fe,P as _e,g as Ce}from"./Dashboard-QYea_GjR.js";import{g as Se}from"./CancellationReqBadge-kpviUzow.js";import{A as De}from"./AddNewAppointment-BJ7pZqHM.js";import{u as k}from"./HasPermission-D75jcuOi.js";import{g as be}from"./configs-CSMPbroZ.js";import{u as ye}from"./index.esm-CxKpqEdJ.js";import{F as r,I as Pe}from"./input-aKY8cD2r.js";import{u as ve,I as Ie}from"./index-B8iLT9XL.js";import{B as h}from"./visually-hidden.style-BrEqndXz.js";import"./index-NjlW3JBs.js";import"./image-DDwLQVjO.js";import"./tr-SHTCPR9-.js";import"./use-clickable-DJbYv-Vn.js";import"./UsePatientsData-2jGB5q0K.js";import"./UsersComboBox-BR1MkjhI.js";import"./popover-BeKqgCqh.js";import"./useMutation-DWP0Ot2c.js";import"./swiper-react-CbcsGzjN.js";import"./grid-CY4MOgwY.js";import"./AddPatients-BLpTyXQl.js";import"./IsdModal-7Szgl44l.js";import"./input-group-BHnguFbm.js";import"./today-D_vLUvRX.js";import"./select-Dt5dI57S.js";import"./split-CzYrjwZo.js";import"./card-body-U833268K.js";import"./menu-list-UQBnhbZh.js";const $e=(d,t)=>{const o=(d-1)*t;let m=o+t-1;return{startIndex:o,endIndex:m}};function it(){const d=oe(),{isOpen:t,onOpen:o,onClose:m}=ve(),b=ye(),y="Errortoast",[u,N]=l.useState(1),_=l.useRef(null),[P,M]=l.useState(""),g=pe(P,1e3),[p,B]=l.useState([]),{startIndex:v,endIndex:I}=$e(u,50),{hasPermission:$}=k(),F=ie(),[i,z]=l.useState({startDate:null,endDate:null}),A=i.startDate?j(i.startDate).format("YYYY-MM-DD"):"",R=i.endDate?j(i.endDate).format("YYYY-MM-DD"):"",Q=s=>{B(s)},O=async()=>{const s=S.role.name==="Doctor"?`get_appointments/doctor_id/page?start=${v}&end=${I}&doctor_id=${S.id}&search=${g}&start_date=${A}&end_date=${R}&status=${p.join(", ")}`:`get_appointments/page?start=${v}&end=${I}&search=${g}&start_date=${A}&end_date=${R}&status=${p.join(", ")}`;await be();const c=await de(S.token,s);return{data:c==null?void 0:c.data.map(W=>{const{id:J,patient_id:K,status:E,date:U,time_slots:X,type:C,payment_status:x,current_cancel_req_status:T,patient_f_name:Z,patient_l_name:ee,patient_phone:te,doct_f_name:se,doct_l_name:ae,doct_image:ne,source:re}=W;return{id:J,image:ne,Doctor:`${se} ${ae}`,Patient:`${Z} ${ee} - #${K}`,phone:te,Status:Ce(E),Date:j(U).format("DD MMM YYYY"),"Time Slots":j(X,"HH:mm:ss").format("hh:mm A"),Type:C==="Emergency"?e.jsx(h,{colorScheme:"red",children:C}):e.jsx(h,{colorScheme:"green",children:C}),"Payment Status":x==="Paid"?e.jsx(h,{colorScheme:"green",children:x}):x==="Refunded"?e.jsx(h,{colorScheme:"blue",children:x}):e.jsx(h,{colorScheme:"red",children:"Not Paid"}),"Cancellation Status":Se(T),source:re,filterStatus:E,current_cancel_req_status:T}}),total_record:c.total_record}},{isLoading:q,data:a,error:w,isFetching:V,isRefetching:H}=ue({queryKey:["appointments",u,g,p,i],queryFn:O}),G=s=>{N(s)},L=Math.ceil((a==null?void 0:a.total_record)/50);return l.useEffect(()=>{_.current&&_.current.scrollIntoView({behavior:"smooth",block:"start"})},[u]),w?(b.isActive(y)||b({id:y,title:"Oops!",description:"Something bad happened.",status:"error",duration:2e3,isClosable:!0,position:"top"}),e.jsx(ce,{errorCode:w.name})):$("APPOINTMENT_VIEW")?e.jsxs(f,{ref:_,children:[q||!a?e.jsxs(f,{children:[e.jsxs(r,{mb:5,justify:"space-between",children:[e.jsx(D,{w:400,h:8}),e.jsx(D,{w:200,h:8})]}),[...Array(10)].map((s,c)=>e.jsx(D,{h:10,w:"100%",mt:2},c))]}):e.jsxs(f,{children:[e.jsxs(r,{mb:5,justify:"space-between",align:"center",children:[e.jsxs(r,{align:"center",gap:4,children:[e.jsx(Pe,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:s=>M(s.target.value),value:P}),e.jsx(ge,{dateRange:i,setDateRange:z,size:"md"})]}),e.jsx(f,{children:e.jsx(Y,{size:"sm",colorScheme:"blue",onClick:()=>{o()},isDisabled:!$("APPOINTMENT_ADD"),children:"Add New"})})]}),e.jsxs(r,{alignItems:"top",justifyContent:"space-between",children:[" ",e.jsx(xe,{colorScheme:"blue",onChange:Q,value:p,children:e.jsxs(r,{mb:5,gap:4,alignItems:"center",children:[e.jsx(n,{value:"Confirmed",children:"Confirmed"}),e.jsx(n,{value:"Visited",children:"Visited"}),e.jsx(n,{value:"Completed",children:"Completed"}),e.jsx(n,{value:"Pending",children:"Pending"}),e.jsx(n,{value:"Cancelled",children:"Cancelled"}),e.jsx(n,{value:"Rejected",children:"Rejected"}),e.jsx(n,{value:"Cancellation",children:"Cancellation Initiated"})]})})," ",e.jsx(Y,{isLoading:V||H,size:"sm",colorScheme:"blue",onClick:()=>{F.invalidateQueries(["appointments",u,g,p],{refetchInactive:!0})},rightIcon:e.jsx(je,{size:14}),children:"Refresh Table"})]}),e.jsx(fe,{minPad:"1px 10px",data:a==null?void 0:a.data,onActionClick:e.jsx(Ae,{onClick:()=>{},navigate:d})})]}),e.jsx(r,{justify:"center",mt:4,children:e.jsx(_e,{currentPage:u,onPageChange:G,totalPages:L})}),t&&e.jsx(De,{isOpen:t,onClose:m})]}):e.jsx(he,{})}const Ae=({onClick:d,rowData:t,navigate:o})=>{const{hasPermission:m}=k();return e.jsx(r,{justify:"center",children:m("APPOINTMENT_UPDATE")&&e.jsx(Ie,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{d(t),o(`/appointment/${t.id}`)},icon:e.jsx(me,{fontSize:18,color:le.colors.blue[500]})})})};export{it as default};