| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/index-WsLdq1K6.js |
import{r as o,w as F,j as t,R as A,B as d,x as M,C as T,y as l,J as Y}from"./index-f5FVPPWf.js";import{u as q}from"./SettingData-HUsgVeqA.js";import{u as v,S as $,i as z,R as L,D as N,P as G}from"./Dashboard-QYea_GjR.js";import{u as J}from"./index.esm-CxKpqEdJ.js";import{F as m,I as K}from"./input-aKY8cD2r.js";import{B as V}from"./visually-hidden.style-BrEqndXz.js";import"./HasPermission-D75jcuOi.js";import"./index-B8iLT9XL.js";import"./index-NjlW3JBs.js";import"./image-DDwLQVjO.js";import"./tr-SHTCPR9-.js";import"./use-clickable-DJbYv-Vn.js";const ne=()=>{var D;const u=J(),h="ErrorToast",[r,R]=o.useState(1),n=o.useRef(null),[p,C]=o.useState(""),i=v(p,1e3),I=F(),[c,b]=o.useState({startDate:"",endDate:""}),{startDate:g,endDate:x}=c,P=(e,s)=>{const y=(e-1)*s,B=y+s-1;return{startIndex:y,endIndex:B}},{startIndex:f,endIndex:_}=P(r,50),S=async()=>{const e=l.role.name==="Doctor"?`get_doctor_review_page?start=${f}&end=${_}&start_date=${g}&end_date=${x}&search=${i}&doctor_id=${l.id}`:`get_doctor_review_page?start=${f}&end=${_}&start_date=${g}&end_date=${x}&search=${i}`,s=await Y(l.token,e);return{data:s.data,totalRecord:s.total_record}},{data:a,error:j,isLoading:E,isFetching:w}=q({queryKey:["reviews",r,i,c],queryFn:S}),Q=e=>{R(e)},k=Math.ceil(((a==null?void 0:a.totalRecord)||0)/50);return o.useEffect(()=>{n.current&&n.current.scrollIntoView({behavior:"smooth",block:"start"})},[r]),j?(u.isActive(h)||u({id:h,title:"Error",description:"Failed to fetch reviews.",status:"error",duration:3e3,isClosable:!0,position:"top"}),t.jsx(A,{errorCode:j.name})):t.jsx(d,{ref:n,children:E?t.jsxs(d,{children:[t.jsx($,{height:8,width:400,mb:4}),[...Array(10)].map((e,s)=>t.jsx($,{height:8,width:"100%",mb:2},s))]}):t.jsxs(d,{children:[t.jsxs(m,{justifyContent:"space-between",mb:4,children:[t.jsxs(m,{gap:4,children:[t.jsx(K,{placeholder:"Search reviews",value:p,onChange:e=>C(e.target.value)}),t.jsx(z,{dateRange:c,setDateRange:b,size:"md"})]}),t.jsx(M,{isLoading:w,onClick:()=>I.invalidateQueries(["reviews"]),rightIcon:t.jsx(L,{size:16}),size:"sm",colorScheme:"blue",children:"Refresh"})]}),t.jsx(N,{minPad:3,data:(D=a==null?void 0:a.data)==null?void 0:D.map(e=>({ID:e.id,"Doctor Name":`${e.doct_f_name} ${e.doct_l_name}`,"patinent Name":`${e.f_name} ${e.l_name}`,"Appointment ID":e.appointment_id,Points:t.jsx(V,{colorScheme:e.points>=4?"green":e.points>=2?"yellow":"red",children:e.points}),Description:e.description,Date:T(e.created_at).format("DD MMM YYYY, hh:mm A")}))}),t.jsx(m,{justifyContent:"center",mt:4,children:t.jsx(G,{currentPage:r,onPageChange:Q,totalPages:k})})]})})};export{ne as default};