|
@@ -2,24 +2,7 @@
|
|
|
|
|
|
|
|
import { useSession } from "next-auth/react"
|
|
import { useSession } from "next-auth/react"
|
|
|
import AuthenticatedLayout from "@/components/AuthenticatedLayout"
|
|
import AuthenticatedLayout from "@/components/AuthenticatedLayout"
|
|
|
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
|
|
|
|
-import { Button } from "@/components/ui/button"
|
|
|
|
|
-import { Badge } from "@/components/ui/badge"
|
|
|
|
|
-import { Separator } from "@/components/ui/separator"
|
|
|
|
|
-import {
|
|
|
|
|
- MessageSquare,
|
|
|
|
|
- FileText,
|
|
|
|
|
- Users,
|
|
|
|
|
- Activity,
|
|
|
|
|
- Calendar,
|
|
|
|
|
- Shield,
|
|
|
|
|
- TrendingUp,
|
|
|
|
|
- ArrowRight,
|
|
|
|
|
- Clock,
|
|
|
|
|
- ChevronRight
|
|
|
|
|
-} from "lucide-react"
|
|
|
|
|
-import Link from "next/link"
|
|
|
|
|
-import { cn } from "@/lib/utils"
|
|
|
|
|
|
|
+import DashboardContent from "@/components/dashboard/DashboardContent"
|
|
|
|
|
|
|
|
export default function DashboardPage() {
|
|
export default function DashboardPage() {
|
|
|
const { data: session } = useSession()
|
|
const { data: session } = useSession()
|
|
@@ -28,313 +11,9 @@ export default function DashboardPage() {
|
|
|
return null
|
|
return null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const isDoctor = session.user.role === "DOCTOR"
|
|
|
|
|
- const isAdmin = session.user.role === "ADMIN"
|
|
|
|
|
- const isPatient = session.user.role === "PATIENT"
|
|
|
|
|
-
|
|
|
|
|
- const roleConfig = {
|
|
|
|
|
- ADMIN: {
|
|
|
|
|
- badge: "Admin",
|
|
|
|
|
- badgeVariant: "default" as const,
|
|
|
|
|
- description: "Gestión completa del sistema"
|
|
|
|
|
- },
|
|
|
|
|
- DOCTOR: {
|
|
|
|
|
- badge: "Doctor",
|
|
|
|
|
- badgeVariant: "secondary" as const,
|
|
|
|
|
- description: "Panel de gestión médica"
|
|
|
|
|
- },
|
|
|
|
|
- PATIENT: {
|
|
|
|
|
- badge: "Paciente",
|
|
|
|
|
- badgeVariant: "outline" as const,
|
|
|
|
|
- description: "Tu asistente médico personal"
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const config = roleConfig[session.user.role as keyof typeof roleConfig]
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<AuthenticatedLayout>
|
|
<AuthenticatedLayout>
|
|
|
- <div className="flex-1 space-y-6 p-8 pt-6">
|
|
|
|
|
- {/* Header Section */}
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardContent className="p-6">
|
|
|
|
|
- <div className="flex items-center justify-between">
|
|
|
|
|
- <div className="flex items-center gap-4">
|
|
|
|
|
- <div className="w-12 h-12 bg-primary rounded-lg flex items-center justify-center shadow-sm">
|
|
|
|
|
- <Activity className="w-6 h-6 text-primary-foreground" />
|
|
|
|
|
- </div>
|
|
|
|
|
- <div>
|
|
|
|
|
- <div className="flex items-center gap-3">
|
|
|
|
|
- <h2 className="text-2xl font-bold tracking-tight">Dashboard</h2>
|
|
|
|
|
- <Badge variant={config.badgeVariant}>{config.badge}</Badge>
|
|
|
|
|
- </div>
|
|
|
|
|
- <p className="text-sm text-muted-foreground mt-1">
|
|
|
|
|
- {config.description}
|
|
|
|
|
- </p>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
-
|
|
|
|
|
- {/* Stats Grid */}
|
|
|
|
|
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
|
- <CardTitle className="text-sm font-medium">
|
|
|
|
|
- Consultas
|
|
|
|
|
- </CardTitle>
|
|
|
|
|
- <MessageSquare className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
- </CardHeader>
|
|
|
|
|
- <CardContent>
|
|
|
|
|
- <div className="text-2xl font-bold">
|
|
|
|
|
- {isPatient ? "Disponible" : "24"}
|
|
|
|
|
- </div>
|
|
|
|
|
- <p className="text-xs text-muted-foreground">
|
|
|
|
|
- {isPatient ? "3 consultas por sesión" : "+12% desde el mes pasado"}
|
|
|
|
|
- </p>
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
-
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
|
- <CardTitle className="text-sm font-medium">
|
|
|
|
|
- Reportes
|
|
|
|
|
- </CardTitle>
|
|
|
|
|
- <FileText className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
- </CardHeader>
|
|
|
|
|
- <CardContent>
|
|
|
|
|
- <div className="text-2xl font-bold">
|
|
|
|
|
- {isPatient ? "15" : "128"}
|
|
|
|
|
- </div>
|
|
|
|
|
- <p className="text-xs text-muted-foreground">
|
|
|
|
|
- {isPatient ? "Reportes generados" : "+8 esta semana"}
|
|
|
|
|
- </p>
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
-
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
|
- <CardTitle className="text-sm font-medium">
|
|
|
|
|
- {isDoctor || isAdmin ? "Pacientes" : "Citas"}
|
|
|
|
|
- </CardTitle>
|
|
|
|
|
- {isDoctor || isAdmin ? (
|
|
|
|
|
- <Users className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
- ) : (
|
|
|
|
|
- <Calendar className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
- )}
|
|
|
|
|
- </CardHeader>
|
|
|
|
|
- <CardContent>
|
|
|
|
|
- <div className="text-2xl font-bold">
|
|
|
|
|
- {isDoctor || isAdmin ? "45" : "2"}
|
|
|
|
|
- </div>
|
|
|
|
|
- <p className="text-xs text-muted-foreground">
|
|
|
|
|
- {isDoctor || isAdmin ? "Activos en el sistema" : "Próximas citas"}
|
|
|
|
|
- </p>
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- {/* Main Content Grid */}
|
|
|
|
|
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
|
|
|
|
|
- {/* Quick Actions */}
|
|
|
|
|
- <Card className="col-span-4">
|
|
|
|
|
- <CardHeader>
|
|
|
|
|
- <CardTitle>Acciones Rápidas</CardTitle>
|
|
|
|
|
- <CardDescription>
|
|
|
|
|
- Accede a las funciones principales del sistema
|
|
|
|
|
- </CardDescription>
|
|
|
|
|
- </CardHeader>
|
|
|
|
|
- <CardContent className="space-y-4">
|
|
|
|
|
- {isAdmin ? (
|
|
|
|
|
- <>
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={Shield}
|
|
|
|
|
- title="Panel de Administración"
|
|
|
|
|
- description="Gestiona usuarios, doctores y configuración"
|
|
|
|
|
- href="/admin"
|
|
|
|
|
- iconBg="bg-violet-100 dark:bg-violet-900/20"
|
|
|
|
|
- iconColor="text-violet-600 dark:text-violet-400"
|
|
|
|
|
- />
|
|
|
|
|
- <Separator />
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={FileText}
|
|
|
|
|
- title="Todos los Reportes"
|
|
|
|
|
- description="Accede al historial completo del sistema"
|
|
|
|
|
- href="/records"
|
|
|
|
|
- iconBg="bg-emerald-100 dark:bg-emerald-900/20"
|
|
|
|
|
- iconColor="text-emerald-600 dark:text-emerald-400"
|
|
|
|
|
- />
|
|
|
|
|
- <Separator />
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={Users}
|
|
|
|
|
- title="Gestión de Usuarios"
|
|
|
|
|
- description="Administra pacientes y personal médico"
|
|
|
|
|
- href="/admin/patients"
|
|
|
|
|
- iconBg="bg-blue-100 dark:bg-blue-900/20"
|
|
|
|
|
- iconColor="text-blue-600 dark:text-blue-400"
|
|
|
|
|
- />
|
|
|
|
|
- </>
|
|
|
|
|
- ) : isDoctor ? (
|
|
|
|
|
- <>
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={Users}
|
|
|
|
|
- title="Mis Pacientes"
|
|
|
|
|
- description="Revisa y gestiona tus pacientes asignados"
|
|
|
|
|
- href="/admin"
|
|
|
|
|
- iconBg="bg-blue-100 dark:bg-blue-900/20"
|
|
|
|
|
- iconColor="text-blue-600 dark:text-blue-400"
|
|
|
|
|
- />
|
|
|
|
|
- <Separator />
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={FileText}
|
|
|
|
|
- title="Reportes Médicos"
|
|
|
|
|
- description="Historial de consultas y diagnósticos"
|
|
|
|
|
- href="/records"
|
|
|
|
|
- iconBg="bg-emerald-100 dark:bg-emerald-900/20"
|
|
|
|
|
- iconColor="text-emerald-600 dark:text-emerald-400"
|
|
|
|
|
- />
|
|
|
|
|
- <Separator />
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={Calendar}
|
|
|
|
|
- title="Agenda de Citas"
|
|
|
|
|
- description="Visualiza tu calendario de consultas"
|
|
|
|
|
- href="/appointments/doctor"
|
|
|
|
|
- iconBg="bg-amber-100 dark:bg-amber-900/20"
|
|
|
|
|
- iconColor="text-amber-600 dark:text-amber-400"
|
|
|
|
|
- />
|
|
|
|
|
- </>
|
|
|
|
|
- ) : (
|
|
|
|
|
- <>
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={MessageSquare}
|
|
|
|
|
- title="Chat Médico"
|
|
|
|
|
- description="Consulta con el asistente virtual"
|
|
|
|
|
- href="/chat"
|
|
|
|
|
- iconBg="bg-blue-100 dark:bg-blue-900/20"
|
|
|
|
|
- iconColor="text-blue-600 dark:text-blue-400"
|
|
|
|
|
- badge="3 disponibles"
|
|
|
|
|
- />
|
|
|
|
|
- <Separator />
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={FileText}
|
|
|
|
|
- title="Mis Reportes"
|
|
|
|
|
- description="Historial de reportes médicos"
|
|
|
|
|
- href="/records"
|
|
|
|
|
- iconBg="bg-emerald-100 dark:bg-emerald-900/20"
|
|
|
|
|
- iconColor="text-emerald-600 dark:text-emerald-400"
|
|
|
|
|
- />
|
|
|
|
|
- <Separator />
|
|
|
|
|
- <QuickActionItem
|
|
|
|
|
- icon={Calendar}
|
|
|
|
|
- title="Mis Citas"
|
|
|
|
|
- description="Próximas consultas programadas"
|
|
|
|
|
- href="/appointments"
|
|
|
|
|
- iconBg="bg-amber-100 dark:bg-amber-900/20"
|
|
|
|
|
- iconColor="text-amber-600 dark:text-amber-400"
|
|
|
|
|
- />
|
|
|
|
|
- </>
|
|
|
|
|
- )}
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- {/* Additional Information */}
|
|
|
|
|
- {(isDoctor || isAdmin) && (
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardHeader>
|
|
|
|
|
- <CardTitle>Resumen de Actividad</CardTitle>
|
|
|
|
|
- <CardDescription>
|
|
|
|
|
- Estadísticas del sistema en tiempo real
|
|
|
|
|
- </CardDescription>
|
|
|
|
|
- </CardHeader>
|
|
|
|
|
- <CardContent>
|
|
|
|
|
- <div className="grid gap-4 md:grid-cols-3">
|
|
|
|
|
- <div className="flex items-center gap-4">
|
|
|
|
|
- <div className="rounded-full bg-blue-100 dark:bg-blue-900/20 p-3">
|
|
|
|
|
- <TrendingUp className="h-5 w-5 text-blue-600 dark:text-blue-400" />
|
|
|
|
|
- </div>
|
|
|
|
|
- <div>
|
|
|
|
|
- <p className="text-sm font-medium text-muted-foreground">
|
|
|
|
|
- Consultas Hoy
|
|
|
|
|
- </p>
|
|
|
|
|
- <p className="text-2xl font-bold">12</p>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="flex items-center gap-4">
|
|
|
|
|
- <div className="rounded-full bg-emerald-100 dark:bg-emerald-900/20 p-3">
|
|
|
|
|
- <FileText className="h-5 w-5 text-emerald-600 dark:text-emerald-400" />
|
|
|
|
|
- </div>
|
|
|
|
|
- <div>
|
|
|
|
|
- <p className="text-sm font-medium text-muted-foreground">
|
|
|
|
|
- Reportes Generados
|
|
|
|
|
- </p>
|
|
|
|
|
- <p className="text-2xl font-bold">8</p>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="flex items-center gap-4">
|
|
|
|
|
- <div className="rounded-full bg-amber-100 dark:bg-amber-900/20 p-3">
|
|
|
|
|
- <Users className="h-5 w-5 text-amber-600 dark:text-amber-400" />
|
|
|
|
|
- </div>
|
|
|
|
|
- <div>
|
|
|
|
|
- <p className="text-sm font-medium text-muted-foreground">
|
|
|
|
|
- Pacientes Activos
|
|
|
|
|
- </p>
|
|
|
|
|
- <p className="text-2xl font-bold">45</p>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
- )}
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <DashboardContent role={session.user.role} />
|
|
|
</AuthenticatedLayout>
|
|
</AuthenticatedLayout>
|
|
|
)
|
|
)
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-interface QuickActionItemProps {
|
|
|
|
|
- icon: React.ElementType
|
|
|
|
|
- title: string
|
|
|
|
|
- description: string
|
|
|
|
|
- href: string
|
|
|
|
|
- iconBg: string
|
|
|
|
|
- iconColor: string
|
|
|
|
|
- badge?: string
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-function QuickActionItem({
|
|
|
|
|
- icon: Icon,
|
|
|
|
|
- title,
|
|
|
|
|
- description,
|
|
|
|
|
- href,
|
|
|
|
|
- iconBg,
|
|
|
|
|
- iconColor,
|
|
|
|
|
- badge
|
|
|
|
|
-}: QuickActionItemProps) {
|
|
|
|
|
- return (
|
|
|
|
|
- <Link
|
|
|
|
|
- href={href}
|
|
|
|
|
- className="group flex items-center justify-between rounded-lg transition-colors hover:bg-accent"
|
|
|
|
|
- >
|
|
|
|
|
- <div className="flex items-center gap-4 flex-1 py-2">
|
|
|
|
|
- <div className={cn("rounded-lg p-2.5", iconBg)}>
|
|
|
|
|
- <Icon className={cn("h-5 w-5", iconColor)} />
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="flex-1 space-y-1">
|
|
|
|
|
- <div className="flex items-center gap-2">
|
|
|
|
|
- <p className="text-sm font-medium leading-none">{title}</p>
|
|
|
|
|
- {badge && (
|
|
|
|
|
- <Badge variant="secondary" className="text-xs">
|
|
|
|
|
- {badge}
|
|
|
|
|
- </Badge>
|
|
|
|
|
- )}
|
|
|
|
|
- </div>
|
|
|
|
|
- <p className="text-sm text-muted-foreground line-clamp-1">
|
|
|
|
|
- {description}
|
|
|
|
|
- </p>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <ChevronRight className="h-5 w-5 text-muted-foreground transition-transform group-hover:translate-x-1" />
|
|
|
|
|
- </Link>
|
|
|
|
|
- )
|
|
|
|
|
}
|
|
}
|