PageSourceSearch

https://medler.ai/assets/analytics-dashboard-DxJNejcD.js

js medler.ai collected 2026-10-05 16:49:22 UTC 8,819 bytes, 1 lines download raw bytes

1import{e as h,j as e,C as i,h as n,i as j,k as T,a2 as u,aw as f,aE as A,aL as D,a_ as S,t as o,a7 as d,a8 as c}from"./index-b7ahOnPe.js";import{S as N}from"./skeleton-Cb-VBKAb.js";import{C as L}from"./clock-DKUWO_sL.js";import{C as R}from"./circle-check-big-CtXWvbqc.js";import{C as _}from"./circle-x-BuhwF5WA.js";import{T as $}from"./trending-up-BA6wwyrK.js";import{A as I}from"./activity-Su9kKUkj.js";function K(){var x,p,m;const{data:r,isLoading:b,error:k}=h({queryKey:["/api/analytics/dashboard"]}),{data:a}=h({queryKey:["/api/analytics/recent-activity"]});if(b)return e.jsxs("div",{className:"container mx-auto py-6 px-4",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-page-title",children:"Analytics Dashboard"}),e.jsx("p",{className:"text-muted-foreground","data-testid":"text-page-description",children:"Track your practice performance"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(8)].map((s,l)=>e.jsx(i,{children:e.jsxs(n,{className:"p-6",children:[e.jsx(N,{className:"h-4 w-24 mb-2"}),e.jsx(N,{className:"h-8 w-16"})]})},l))})]});if(k)return e.jsx("div",{className:"container mx-auto py-6 px-4",children:e.jsx(i,{children:e.jsx(n,{className:"p-6 text-center",children:e.jsx("p",{className:"text-destructive","data-testid":"text-error",children:"Failed to load analytics data"})})})});const t=r==null?void 0:r.summary,v=[{title:"Total Appointments",value:(t==null?void 0:t.totalAppointments)||0,icon:j,color:"text-blue-600 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950"},{title:"Today's Appointments",value:(t==null?void 0:t.todayAppointments)||0,icon:L,color:"text-orange-600 dark:text-orange-400",bgColor:"bg-orange-50 dark:bg-orange-950"},{title:"Completed",value:(t==null?void 0:t.completedAppointments)||0,icon:R,color:"text-green-600 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950"},{title:"Pending",value:(t==null?void 0:t.pendingAppointments)||0,icon:_,color:"text-yellow-600 dark:text-yellow-400",bgColor:"bg-yellow-50 dark:bg-yellow-950"},{title:"Total Patients",value:(t==null?void 0:t.totalPatients)||0,icon:T,color:"text-purple-600 dark:text-purple-400",bgColor:"bg-purple-50 dark:bg-purple-950"},{title:"Prescriptions",value:(t==null?void 0:t.totalPrescriptions)||0,icon:u,color:"text-teal-600 dark:text-teal-400",bgColor:"bg-teal-50 dark:bg-teal-950"},{title:"AI Consultations",value:(t==null?void 0:t.aiSessions)||0,icon:f,color:"text-indigo-600 dark:text-indigo-400",bgColor:"bg-indigo-50 dark:bg-indigo-950"},{title:"Credits Used",value:(t==null?void 0:t.tokensUsed)!=null?A(D(t.tokensUsed)):0,icon:S,color:"text-pink-600 dark:text-pink-400",bgColor:"bg-pink-50 dark:bg-pink-950"}];return e.jsxs("div",{className:"container mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-page-title",children:"Analytics Dashboard"}),e.jsx("p",{className:"text-muted-foreground","data-testid":"text-page-description",children:"Track your practice performance and insights"})]}),e.jsx(o,{variant:"outline","data-testid":"badge-live",children:"Live Data"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:v.map((s,l)=>e.jsx(i,{"data-testid":`card-stat-${s.title.toLowerCase().replace(/\s+/g,"-")}`,children:e.jsx(n,{className:"p-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.title}),e.jsx("p",{className:"text-2xl font-bold","data-testid":`text-value-${s.title.toLowerCase().replace(/\s+/g,"-")}`,children:s.value})]}),e.jsx("div",{className:`p-3 rounded-full ${s.bgColor}`,children:e.jsx(s.icon,{className:`w-5 h-5 ${s.color}`})})]})})},l))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[e.jsxs(i,{children:[e.jsx(d,{children:e.jsxs(c,{className:"flex flex-wrap items-center gap-2",children:[e.jsx($,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),"Completion Rate"]})}),e.jsx(n,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{className:"w-32 h-32",children:[e.jsx("circle",{className:"text-muted",strokeWidth:"10",stroke:"currentColor",fill:"transparent",r:"56",cx:"64",cy:"64"}),e.jsx("circle",{className:"text-green-500 dark:text-green-400",strokeWidth:"10",strokeDasharray:`${((t==null?void 0:t.completionRate)||0)*3.52} 352`,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:"56",cx:"64",cy:"64",style:{transform:"rotate(-90deg)",transformOrigin:"64px 64px"}})]}),e.jsxs("span",{className:"absolute text-3xl font-bold","data-testid":"text-completion-rate",children:[(t==null?void 0:t.completionRate)||0,"%"]})]}),e.jsx("p",{className:"text-muted-foreground mt-4",children:"Appointment Completion Rate"})]})})]}),e.jsxs(i,{children:[e.jsx(d,{children:e.jsxs(c,{className:"flex flex-wrap items-center gap-2",children:[e.jsx(I,{className:"w-5 h-5 text-blue-600 dar
1k:text-blue-400"}),"Weekly Trend"]})}),e.jsx(n,{children:e.jsx("div",{className:"h-48 flex items-end gap-2",children:r!=null&&r.weeklyTrend&&r.weeklyTrend.length>0?r.weeklyTrend.map((s,l)=>{const g=Math.max(...r.weeklyTrend.map(y=>parseInt(y.count)||0)),w=g>0?parseInt(s.count)/g*100:0,C=new Date(s.date).toLocaleDateString("en-US",{weekday:"short"});return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1",children:[e.jsx("div",{className:"w-full bg-blue-500 rounded-t transition-all",style:{height:`${Math.max(w,5)}%`},"data-testid":`bar-day-${l}`}),e.jsx("span",{className:"text-xs text-muted-foreground",children:C}),e.jsx("span",{className:"text-xs font-medium",children:s.count})]},l)}):e.jsx("div",{className:"w-full text-center text-muted-foreground py-12",children:"No appointment data for the past week"})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(i,{children:[e.jsx(d,{children:e.jsxs(c,{className:"flex flex-wrap items-center gap-2",children:[e.jsx(j,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),"Recent Appointments"]})}),e.jsx(n,{children:e.jsx("div",{className:"space-y-3",children:((x=a==null?void 0:a.appointments)==null?void 0:x.length)>0?a.appointments.slice(0,5).map((s,l)=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2 border-b last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.patient_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.scheduled_time).toLocaleDateString()})]}),e.jsx(o,{variant:s.status==="completed"?"default":"secondary",className:"text-xs",children:s.status})]},l)):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No recent appointments"})})})]}),e.jsxs(i,{children:[e.jsx(d,{children:e.jsxs(c,{className:"flex flex-wrap items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5 text-teal-600 dark:text-teal-400"}),"Recent Prescriptions"]})}),e.jsx(n,{children:e.jsx("div",{className:"space-y-3",children:((p=a==null?void 0:a.prescriptions)==null?void 0:p.length)>0?a.prescriptions.slice(0,5).map((s,l)=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2 border-b last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.patient_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.scheduled_time).toLocaleDateString()})]}),e.jsx(o,{variant:"outline",className:"text-xs",children:s.status})]},l)):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No recent prescriptions"})})})]}),e.jsxs(i,{children:[e.jsx(d,{children:e.jsxs(c,{className:"flex flex-wrap items-center gap-2",children:[e.jsx(f,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),"Recent AI Sessions"]})}),e.jsx(n,{children:e.jsx("div",{className:"space-y-3",children:((m=a==null?void 0:a.sessions)==null?void 0:m.length)>0?a.sessions.slice(0,5).map((s,l)=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2 border-b last:border-0",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["AI Session #",s.id]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.scheduled_time).toLocaleDateString()})]}),e.jsx(o,{variant:"secondary",className:"text-xs",children:"Session"})]},l)):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No recent AI sessions"})})})]})]})]})}export{K 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.