import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { AppointmentStatusBadge } from "./AppointmentStatusBadge"; import { Calendar, Clock, User, FileText } from "lucide-react"; import { format } from "date-fns"; import { es } from "date-fns/locale"; import Link from "next/link"; import type { Appointment } from "@/types/appointments"; interface AppointmentCardProps { appointment: Appointment; userRole: "PATIENT" | "DOCTOR" | "ADMIN"; onApprove?: (id: string) => void; onReject?: (id: string) => void; onCancel?: (id: string) => void; } export const AppointmentCard = ({ appointment, userRole, onApprove, onReject, onCancel, }: AppointmentCardProps) => { const fecha = new Date(appointment.fechaSolicitada); const otherUser = userRole === "PATIENT" ? appointment.medico : appointment.paciente; return (
{otherUser && ( {otherUser.name[0]}{otherUser.lastname[0]} )}

{otherUser ? `${otherUser.name} ${otherUser.lastname}` : userRole === "DOCTOR" ? "Sin asignar" : "Médico por asignar"}

{format(fecha, "PPP", { locale: es })} {format(fecha, "p", { locale: es })}

Motivo de consulta:

{appointment.motivoConsulta}

{appointment.motivoRechazo && (

Motivo de rechazo:

{appointment.motivoRechazo}

)}
{userRole === "DOCTOR" && appointment.estado === "PENDIENTE" && ( <> )} {userRole === "PATIENT" && appointment.estado === "PENDIENTE" && ( )} {appointment.estado === "APROBADA" && ( )}
); };