import React from 'react';
import { useNavigate } from 'react-router-dom';
import { motion } from 'framer-motion';
import { useJobPostings, useApplications } from '@/lib/krowHooks';
import KROWCandidateLeaderboardReal from '@/components/krow/KROWCandidateLeaderboard';
import { Briefcase, Users, Brain, Clock, TrendingUp, Award, ChevronRight } from 'lucide-react';
const METRICS = [
{ icon: Briefcase, label: 'Open Positions', bg: 'bg-[#0838E0]', glow: 'shadow-blue-600/20' },
{ icon: Users, label: 'Total Candidates', bg: 'bg-[#333F48]', glow: 'shadow-slate-600/20' },
{ icon: Brain, label: 'AI Screened', bg: 'bg-[#0838E0]', glow: 'shadow-blue-600/20' },
{ icon: Clock, label: 'Pending Screen', bg: 'bg-[#F9E547]', glow: 'shadow-yellow-400/30' },
{ icon: TrendingUp, label: 'Avg AI Score', bg: 'bg-[#333F48]', glow: 'shadow-slate-600/20' },
{ icon: Award, label: 'Hired', bg: 'bg-[#0838E0]', glow: 'shadow-blue-600/20' },
];
function MetricCard({ icon: Icon, value, label, bg, glow, index }) {
const isYellow = bg === 'bg-[#F9E547]';
return (
{value}
{label}
);
}
export default function Overview() {
const navigate = useNavigate();
const { data: postings = [] } = useJobPostings();
const { data: applications = [] } = useApplications();
const values = [
postings.filter(p => p.status === 'active').length,
applications.length,
applications.filter(a => ['ai_screened', 'interview', 'hired', 'shortlisted'].includes(a.status)).length,
applications.filter(a => a.status === 'applied').length,
(() => { const s = applications.filter(a => a.ai_score > 0); return s.length ? Math.round(s.reduce((sum, a) => sum + a.ai_score, 0) / s.length) : 0; })(),
applications.filter(a => a.status === 'hired').length,
];
const topCandidates = [...applications.filter(a => a.ai_score > 0)].sort((a, b) => b.ai_score - a.ai_score).slice(0, 5);
const activePostings = postings.filter(p => p.status === 'active').slice(0, 5);
const statsForPosting = (postingId) => {
const apps = applications.filter(a => a.job_posting_id === postingId);
return {
applied: apps.length,
screened: apps.filter(a => a.status !== 'applied').length,
};
};
return (
{/* Hero greeting */}
Good day. Let's hire smarter.
AI-powered hiring · No quizzes · Real readiness
{/* Metrics Grid */}
{METRICS.map((m, i) => (
))}
{/* Top Candidates + Open Positions */}
{/* Top Candidates */}
Top Candidates
{topCandidates.length === 0 && (
No screened candidates yet
)}
{topCandidates.map((app, idx) => (
navigate('/candidates')}
>
{idx + 1}
{app.applicant_name?.split(' ').map(w => w[0]).slice(0, 2).join('').toUpperCase()}
{app.applicant_name}
{app.job_title || 'Applicant'}
))}
{/* Open Positions */}
Open Positions
{activePostings.length === 0 && (
)}
{activePostings.map((posting, idx) => {
const stats = statsForPosting(posting.id);
return (
navigate(`/positions/${posting.id}`)}
className="flex items-center gap-3 p-2.5 rounded-xl hover:bg-white/50 transition-colors cursor-pointer group"
>
{idx + 1}
{posting.title}
{stats.applied} applicants · {stats.screened} screened
);
})}
{/* Candidate Pipeline */}
);
}