import React, { useMemo } from 'react'; import { ResponsiveContainer, BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Cell } from 'recharts'; const TIER_COLORS = { Skilled: '#0A39DF', 'Cross-Trained': '#333F48', Beginner: '#D1E0D7' }; export default function HiringAnalytics({ applications, staff }) { const byTier = useMemo(() => { const tiers = ['Skilled', 'Cross-Trained', 'Beginner']; return tiers.map(tier => ({ label: tier, count: staff.filter(s => s.profile_tier === tier).length, color: TIER_COLORS[tier], })); }, [staff]); const byRole = useMemo(() => { const counts = {}; staff.forEach(s => { const role = s.role || 'Unassigned'; counts[role] = (counts[role] || 0) + 1; }); return Object.entries(counts) .map(([role, count]) => ({ role, count })) .sort((a, b) => b.count - a.count) .slice(0, 6); }, [staff]); const hiredApps = applications.filter(a => a.status === 'hired'); const totalApps = applications.length; const hireRate = totalApps ? Math.round((hiredApps.length / totalApps) * 100) : 0; const avgHireScore = hiredApps.length ? Math.round(hiredApps.reduce((s, a) => s + (a.ai_score || 0), 0) / hiredApps.length) : 0; const sevenDaysAgo = new Date(); sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7); const recentHires = staff.filter(s => new Date(s.hire_date) >= sevenDaysAgo).length; return (

Hiring Analytics

{staff.length} total hires ยท {recentHires} in last 7 days

{hireRate}%
HIRE RATE
{avgHireScore}
AVG SCORE
{recentHires}
LAST 7 DAYS

Hires by Tier

{byTier.map((entry, i) => ( ))}

Hires by Role

); }