All files / client/src/components stats-cards.tsx

100% Statements 9/9
100% Branches 2/2
100% Functions 4/4
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                  9x 19x 19x 9x   9x                                                             9x     36x                                      
import { Card, CardContent } from "@/components/ui/card";
import { Target, CheckCircle2, PlayCircle, TrendingUp } from "lucide-react";
import type { Resolution } from "@shared/schema";
 
interface StatsCardsProps {
  resolutions: Resolution[];
}
 
export function StatsCards({ resolutions }: StatsCardsProps) {
  const total = resolutions.length;
  const completed = resolutions.filter((r) => r.status === "completed").length;
  const inProgress = resolutions.filter((r) => r.status === "in_progress").length;
  const completionRate = total > 0 ? Math.round((completed / total) * 100) : 0;
 
  const stats = [
    {
      label: "Total Resolutions",
      value: total,
      icon: Target,
      iconBg: "bg-primary/10",
      iconColor: "text-primary",
    },
    {
      label: "Completed",
      value: completed,
      icon: CheckCircle2,
      iconBg: "bg-emerald-100 dark:bg-emerald-900/30",
      iconColor: "text-emerald-600 dark:text-emerald-400",
    },
    {
      label: "In Progress",
      value: inProgress,
      icon: PlayCircle,
      iconBg: "bg-blue-100 dark:bg-blue-900/30",
      iconColor: "text-blue-600 dark:text-blue-400",
    },
    {
      label: "Completion Rate",
      value: `${completionRate}%`,
      icon: TrendingUp,
      iconBg: "bg-amber-100 dark:bg-amber-900/30",
      iconColor: "text-amber-600 dark:text-amber-400",
    },
  ];
 
  return (
    <div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
      {stats.map((stat) => (
        <Card key={stat.label} className="border-card-border">
          <CardContent className="p-4">
            <div className="flex items-center gap-3">
              <div className={`p-2.5 rounded-md ${stat.iconBg}`}>
                <stat.icon className={`h-5 w-5 ${stat.iconColor}`} />
              </div>
              <div>
                <p className="text-2xl font-semibold" data-testid={`text-stat-${stat.label.toLowerCase().replace(/\s+/g, '-')}`}>
                  {stat.value}
                </p>
                <p className="text-sm text-muted-foreground">{stat.label}</p>
              </div>
            </div>
          </CardContent>
        </Card>
      ))}
    </div>
  );
}