MedicalAlert.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use client";
  2. import { AlertTriangle, Info, Clock, Calendar } from "lucide-react";
  3. import { MedicalAlert as MedicalAlertType } from "./types";
  4. import { cn } from "@/lib/utils";
  5. import { Button } from "@/components/ui/button";
  6. import Link from "next/link";
  7. interface MedicalAlertProps {
  8. alert: MedicalAlertType;
  9. className?: string;
  10. showAppointmentButton?: boolean;
  11. }
  12. const alertConfig = {
  13. NO_AGENDAR: {
  14. icon: Info,
  15. text: "Información general",
  16. description: "No requiere cita médica inmediata",
  17. className: "bg-muted border-muted-foreground/20 text-muted-foreground",
  18. iconClassName: "text-muted-foreground"
  19. },
  20. RECOMENDADO: {
  21. icon: Clock,
  22. text: "Consulta recomendada",
  23. description: "Se recomienda agendar una cita médica",
  24. className: "bg-yellow-50 border-yellow-200 text-yellow-800",
  25. iconClassName: "text-yellow-600"
  26. },
  27. URGENTE: {
  28. icon: AlertTriangle,
  29. text: "Atención urgente",
  30. description: "Requiere atención médica inmediata",
  31. className: "bg-red-500 border-red-600 text-white",
  32. iconClassName: "text-white"
  33. }
  34. };
  35. export const MedicalAlert = ({ alert, className, showAppointmentButton = true }: MedicalAlertProps) => {
  36. const config = alertConfig[alert];
  37. const Icon = config.icon;
  38. const shouldShowButton = showAppointmentButton && (alert === "RECOMENDADO" || alert === "URGENTE");
  39. return (
  40. <div className={cn(
  41. "flex items-center justify-between gap-3 px-4 py-3 rounded-lg border",
  42. config.className,
  43. className
  44. )}>
  45. <div className="flex items-center gap-3 flex-1">
  46. <Icon className={cn("h-5 w-5 flex-shrink-0", config.iconClassName)} />
  47. <div className="flex-1">
  48. <div className="font-semibold text-sm">{config.text}</div>
  49. <div className="text-xs opacity-80 mt-0.5">{config.description}</div>
  50. </div>
  51. </div>
  52. {shouldShowButton && (
  53. <Button
  54. asChild
  55. size="sm"
  56. variant={alert === "URGENTE" ? "destructive" : "default"}
  57. className="flex-shrink-0"
  58. >
  59. <Link href="/appointments">
  60. <Calendar className="h-4 w-4 mr-2" />
  61. Agendar Cita
  62. </Link>
  63. </Button>
  64. )}
  65. </div>
  66. );
  67. };