trello_fake/components/dashboard/stats-overview.tsx

70 lines
3.0 KiB
TypeScript

"use client";
import { LayoutGrid, TrendingUp, DollarSign, Clock } from 'lucide-react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Project } from '@/types/project'; // o la ruta donde pongas types.ts
interface StatsOverviewProps {
projects: Project[];
}
export default function StatsOverview({ projects }: StatsOverviewProps) {
const stats = {
total: projects.length,
activos: projects.filter(p => p.progress < 100 && p.status !== "2").length,
totalBudget: projects.reduce((acc, p) => acc + p.budget, 0),
avgProgress: projects.length > 0
? Math.round(projects.reduce((acc, p) => acc + p.progress, 0) / projects.length)
: 0
};
return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<Card className="border hover:shadow-md transition-shadow">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">Total Proyectos</CardTitle>
<LayoutGrid className="w-4 h-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-3xl font-bold text-foreground">{stats.total}</div>
<p className="text-xs text-muted-foreground mt-1">Todos los proyectos</p>
</CardContent>
</Card>
<Card className="border hover:shadow-md transition-shadow">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">Activos</CardTitle>
<TrendingUp className="w-4 h-4 text-blue-500" />
</CardHeader>
<CardContent>
<div className="text-3xl font-bold text-foreground">{stats.activos}</div>
<p className="text-xs text-muted-foreground mt-1">En progreso ahora</p>
</CardContent>
</Card>
<Card className="border hover:shadow-md transition-shadow">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">Presupuesto Total</CardTitle>
<DollarSign className="w-4 h-4 text-green-500" />
</CardHeader>
<CardContent>
<div className="text-3xl font-bold text-foreground">
€{(stats.totalBudget / 1000).toFixed(0)}k
</div>
<p className="text-xs text-muted-foreground mt-1">Suma de presupuestos</p>
</CardContent>
</Card>
<Card className="border hover:shadow-md transition-shadow">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">Progreso Medio</CardTitle>
<Clock className="w-4 h-4 text-purple-500" />
</CardHeader>
<CardContent>
<div className="text-3xl font-bold text-foreground">{stats.avgProgress}%</div>
<p className="text-xs text-muted-foreground mt-1">De todos los proyectos</p>
</CardContent>
</Card>
</div>
);
}