"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { TeamReviewData } from "@/lib/team-review-types"; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pie, Cell, } from "recharts"; interface TeamStatsProps { stats: TeamReviewData["stats"]; members: TeamReviewData["members"]; skillGaps: TeamReviewData["skillGaps"]; categoryCoverage: TeamReviewData["categoryCoverage"]; } export function TeamStats({ stats, members, skillGaps, categoryCoverage, }: TeamStatsProps) { // Calcul des statistiques avancées const totalEvaluations = members.reduce( (acc, member) => acc + member.skills.length, 0 ); const avgSkillsPerMember = totalEvaluations / (stats.totalMembers || 1); // Distribution des niveaux const levelDistribution = members.reduce((acc, member) => { member.skills.forEach((skill) => { acc[skill.level] = (acc[skill.level] || 0) + 1; }); return acc; }, {} as Record); const levelData = [ { name: "Expert", value: levelDistribution.expert || 0, color: "#4f46e5" }, { name: "Autonome", value: levelDistribution.autonomous || 0, color: "#10b981", }, { name: "En apprentissage", value: levelDistribution["not-autonomous"] || 0, color: "#f59e0b", }, { name: "Jamais pratiqué", value: levelDistribution.never || 0, color: "#6b7280", }, ]; // Top catégories par expertise const sortedCategories = [...categoryCoverage].sort( (a, b) => b.experts - a.experts ); const topCategories = sortedCategories.slice(0, 3); // Statistiques de mentorat const mentorCount = members.filter((m) => m.mentorSkills > 0).length; const learnerCount = members.filter((m) => m.learningSkills > 0).length; const mentorshipRatio = (mentorCount / (stats.totalMembers || 1)) * 100; // Gaps critiques par catégorie const criticalGapsByCategory = skillGaps .filter((gap) => gap.risk === "high") .reduce((acc, gap) => { acc[gap.category] = (acc[gap.category] || 0) + 1; return acc; }, {} as Record); const gapData = Object.entries(criticalGapsByCategory).map( ([category, count]) => ({ name: category, value: count, fill: "#ef4444", }) ); return ( Statistiques de l'équipe {/* Vue d'ensemble */}

Membres

{stats.totalMembers}

Compétences/membre

{avgSkillsPerMember.toFixed(1)}

Ratio mentors

{mentorshipRatio.toFixed(0)}%

Gaps critiques

{stats.learningNeeds}

{/* Distribution des niveaux */}

Distribution des niveaux

`${entry.name} (${entry.value})`} labelLine={{ stroke: "#64748b" }} > {levelData.map((entry, index) => ( ))}
{/* Top catégories */}

Top catégories par expertise

{topCategories.map((cat) => (

{cat.category}

{cat.experts} experts {cat.mentors} mentors

{cat.coverage.toFixed(0)}%

couverture

))}
{/* Gaps critiques par catégorie */} {gapData.length > 0 && (

Gaps critiques par catégorie

)} {/* Statistiques de mentorat */}

Mentorat

Mentors

{mentorCount}

Apprenants

{learnerCount}

Opportunités

{stats.mentorshipOpportunities}

Couverture globale

Compétences

{stats.totalSkills}

Niveau moyen

{((stats.averageTeamLevel * 100) / 3).toFixed(0)}%

); }