import { FileText, Building2, Calendar, Clock, Hash, } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { Progress } from "@/components/ui/progress"; import { Project } from "@/types/project"; interface ProjectInfoProps { project: Project; } // Formatear moneda function formatCurrency(amount: number): string { return new Intl.NumberFormat("es-ES", { style: "currency", currency: "EUR", minimumFractionDigits: 2, }).format(amount); } // Formatear fecha function formatDate(dateString: string): string { return new Date(dateString).toLocaleDateString("es-ES", { day: "numeric", month: "long", year: "numeric", }); } // Calcular duración en días function getDuration(startDate: string, endDate: string): number { const start = new Date(startDate); const end = new Date(endDate); const diff = end.getTime() - start.getTime(); return Math.ceil(diff / (1000 * 60 * 60 * 24)); } export function ProjectInfo({ project }: ProjectInfoProps) { const duration = getDuration(project.startDate, project.endDate); const budgetUsed = project.budget > 0 ? (project.spent / project.budget) * 100 : 0; const budgetRemaining = project.budget - project.spent; return (
{/* Columna principal - 2/3 */}
{/* Descripción */} Descripción {project.description ? (

{project.description}

) : (

Sin descripción disponible

)}
{/* Información financiera */} Información Financiera {/* Barra de progreso del presupuesto */}
Uso del presupuesto 90 ? "text-red-500" : ""}`}> {budgetUsed.toFixed(1)}%
100 ? "[&>div]:bg-red-500" : ""}`} />
{/* Desglose */}

Presupuesto

{formatCurrency(project.budget)}

Gastado

{formatCurrency(project.spent)}

Restante

{formatCurrency(budgetRemaining)}

{/* Timeline */} Timeline del Proyecto
{/* Línea de progreso */}
{/* Puntos */}

Inicio

{formatDate(project.startDate)}

= 100 ? "bg-green-500" : "bg-gray-300 dark:bg-gray-600"}`} />

Fin previsto

{formatDate(project.endDate)}

Duración: {duration} días
Progreso: {project.progress}%
{/* Sidebar - 1/3 */}
{/* Detalles generales */} Detalles {/* Cliente */} {project.client !== "Sin cliente" && ( <>

Cliente

{project.client}

)} {/* Referencia */}

Referencia

{project.ref}

{/* ID */}

ID del proyecto

{project.id}

{/* Fechas */} Fechas

Fecha de inicio

{formatDate(project.startDate)}

Fecha de fin

{formatDate(project.endDate)}

Creado

{formatDate(project.createdAt)}

Última actualización

{formatDate(project.updatedAt)}

); }