trello_fake/components/dashboard/project-card.tsx

121 lines
4.8 KiB
TypeScript
Raw Normal View History

"use client";
2026-01-28 10:44:49 +00:00
import Link from 'next/link';
2026-01-09 17:39:19 +00:00
import { Calendar, DollarSign, TrendingUp, FileText } from 'lucide-react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { ProjectStatusBadge } from '@/components/ui/project-status-badge';
import { Project } from '@/types/project';
interface ProjectCardProps {
project: Project;
}
2026-01-09 17:39:19 +00:00
// Función para generar iniciales
function getInitials(name: string): string {
return name
.split(' ')
.map(word => word[0])
.join('')
.toUpperCase()
.slice(0, 2);
}
export default function ProjectCard({ project }: ProjectCardProps) {
2026-01-09 17:39:19 +00:00
const initials = getInitials(project.name);
return (
2026-01-28 10:44:49 +00:00
<Link href={`/proyectos/${project.id}`}>
<Card className="hover:shadow-lg transition-all duration-300 hover:-translate-y-1 cursor-pointer h-full">
2026-01-28 10:44:49 +00:00
<CardHeader>
<div className="flex items-start justify-between">
<div className="flex items-center gap-3">
<Avatar className="w-12 h-12">
<AvatarFallback className="bg-gradient-to-br from-blue-500 to-purple-600 text-white font-semibold">
{initials}
</AvatarFallback>
</Avatar>
<div>
<CardTitle className="text-lg">{project.name}</CardTitle>
2026-01-28 10:44:49 +00:00
<CardDescription className="text-sm">{project.ref}</CardDescription>
</div>
</div>
</div>
<ProjectStatusBadge status={project.status} className="mt-3 w-fit" />
2026-01-28 10:44:49 +00:00
</CardHeader>
<CardContent>
{/* Description */}
{project.description && (
<div className="mb-4">
<div className="flex items-center gap-1 text-muted-foreground mb-1">
2026-01-28 10:44:49 +00:00
<FileText className="w-3 h-3" />
<span className="text-xs">Descripción</span>
</div>
<p className="text-sm text-muted-foreground line-clamp-2">{project.description}</p>
2026-01-09 17:39:19 +00:00
</div>
2026-01-28 10:44:49 +00:00
)}
2026-01-09 17:39:19 +00:00
2026-01-28 10:44:49 +00:00
{/* Progress Bar */}
<div className="mb-4">
<div className="flex items-center justify-between mb-2">
<span className="text-xs font-medium text-muted-foreground">Progreso</span>
<span className="text-xs font-semibold">{project.progress}%</span>
2026-01-28 10:44:49 +00:00
</div>
<div className="w-full bg-muted rounded-full h-2">
2026-01-28 10:44:49 +00:00
<div
className="bg-gradient-to-r from-blue-500 to-purple-600 h-2 rounded-full transition-all duration-500"
style={{ width: `${project.progress}%` }}
/>
</div>
</div>
2026-01-28 10:44:49 +00:00
{/* Budget Info */}
<div className="grid grid-cols-2 gap-4 mb-4">
<div>
<div className="flex items-center gap-1 text-muted-foreground mb-1">
2026-01-28 10:44:49 +00:00
<DollarSign className="w-3 h-3" />
<span className="text-xs">Presupuesto</span>
</div>
<p className="text-sm font-semibold">
2026-01-28 10:44:49 +00:00
€{project.budget.toLocaleString('es-ES', { minimumFractionDigits: 0, maximumFractionDigits: 0 })}
</p>
</div>
2026-01-28 10:44:49 +00:00
<div>
<div className="flex items-center gap-1 text-muted-foreground mb-1">
2026-01-28 10:44:49 +00:00
<TrendingUp className="w-3 h-3" />
<span className="text-xs">Estimado</span>
</div>
<p className="text-sm font-semibold">
2026-01-28 10:44:49 +00:00
€{project.spent.toLocaleString('es-ES', { minimumFractionDigits: 0, maximumFractionDigits: 0 })}
</p>
</div>
</div>
2026-01-28 10:44:49 +00:00
{/* Footer Info */}
<div className="pt-4 border-t flex items-center justify-between">
<div className="flex items-center gap-1 text-muted-foreground">
2026-01-28 10:44:49 +00:00
<Calendar className="w-4 h-4" />
<span className="text-xs">
{new Date(project.startDate).toLocaleDateString('es-ES', { day: '2-digit', month: 'short', year: 'numeric' })}
</span>
</div>
<div className="flex items-center gap-1 text-muted-foreground">
2026-01-28 10:44:49 +00:00
<Calendar className="w-4 h-4" />
<span className="text-xs">
{new Date(project.endDate).toLocaleDateString('es-ES', { day: '2-digit', month: 'short', year: 'numeric' })}
</span>
</div>
</div>
2026-01-09 17:39:19 +00:00
2026-01-28 10:44:49 +00:00
{/* Cliente */}
{project.client !== 'Sin cliente' && (
<div className="mt-3 pt-3 border-t">
<span className="text-xs text-muted-foreground">Cliente: </span>
<span className="text-xs font-medium">{project.client}</span>
2026-01-28 10:44:49 +00:00
</div>
)}
</CardContent>
</Card>
</Link>
);
}