import React, { useState } from 'react';
import { cn } from '@/lib/utils';
import { Mail, Briefcase, MapPin, Star, BadgeCheck, Award, ChevronDown } from 'lucide-react';
import { Image } from '@/components/ui/image';
import EmployerInsights from '@/components/krow/talent/EmployerInsights';
import { getScoreBand, toFICO } from '@/lib/talentHome';
const PORTRAIT_PHOTOS = [
'photo-1500648767731-7d3514ad8b31',
'photo-1531123897727-8f129e1688ce',
'photo-1573496359142-b8d87734a5a2',
'photo-1487412720507-e7ab37603c6f',
'photo-1502685104226-ee3a97a2f2c8',
'photo-1544005313-94ddf0286df2',
'photo-1494790108377-be9c29b29330',
'photo-1438761681033-6461ffad8d80',
'photo-1517841905240-472988babdf9',
'photo-1463453091185-61582044d556',
];
function getPortraitSeed(name) {
let h = 0;
for (let i = 0; i < (name || '').length; i++) h = (h * 31 + name.charCodeAt(i)) >>> 0;
return PORTRAIT_PHOTOS[h % PORTRAIT_PHOTOS.length];
}
function CareerGauge({ fico }) {
const MIN = 300;
const MAX = 850;
const value = Math.max(MIN, Math.min(MAX, fico || MIN));
const frac = (value - MIN) / (MAX - MIN);
const cx = 55;
const cy = 58;
const r = 46;
const theta = (180 - frac * 180) * (Math.PI / 180);
const xv = cx + r * Math.cos(theta);
const yv = cy - r * Math.sin(theta);
const color = value > MIN ? '#0838E0' : '#CBD5E1';
return (
CAREER SCORE
);
}
const BADGE_LEVEL_STYLES = {
bronze: 'bg-[#FEF3C7] text-[#92400E]',
silver: 'bg-[#F3F4F6] text-[#4B5563]',
gold: 'bg-[#FEF9E7] text-[#92400E]',
platinum: 'bg-[#EEF3FE] text-[#1E40AF]',
};
export default function TalentPoolCard({ profile, onContact, onView }) {
const [expanded, setExpanded] = useState(false);
const score = profile.krow_score || 0;
const band = getScoreBand(score);
const fico = toFICO(score);
const hasScore = score > 0;
const skills = (profile.skills || []).slice(0, 4);
const extraSkills = (profile.skills || []).length - skills.length;
const badges = (profile.earned_badges || []).slice(0, 3);
const extraBadges = (profile.earned_badges || []).length - badges.length;
const capabilities = profile.capabilities || [];
const endorsements = capabilities.filter((c) => c.status === 'verified' || c.status === 'pending').slice(0, 3);
const extraEndorsements = capabilities.length - endorsements.length;
const toggle = (e) => {
e.stopPropagation();
setExpanded((v) => !v);
};
return (
{/* Clickable header → opens full profile modal */}
onView?.(profile)}
>
{/* Avatar */}
{/* Info */}
{profile.full_name}
{hasScore ? band.label : 'No score yet'}
{/* Career Score gauge */}
{/* Expanded details */}
{expanded && (
{/* Quick meta line */}
{profile.desired_position && (
{profile.desired_position}
)}
{profile.experience_years > 0 && (
{profile.experience_years}yr exp
)}
{profile.location && (
{profile.location}
)}
{(profile.client_rating > 0 || profile.supervisor_rating > 0) && (
{((profile.client_rating + profile.supervisor_rating) / 2).toFixed(1)}
)}
{skills.length > 0 && (
{skills.map((s) => (
{s}
))}
{extraSkills > 0 && (
+{extraSkills}
)}
)}
{(profile.availability || []).length > 0 && (
{(profile.availability || []).slice(0, 3).map((a) => (
{a}
))}
)}
{/* Badges */}
{badges.length > 0 && (
BADGES
{badges.map((b, i) => (
{b.name}
))}
{extraBadges > 0 && (
+{extraBadges}
)}
)}
{/* Endorsements */}
{endorsements.length > 0 && (
ENDORSEMENTS
({capabilities.length})
{endorsements.map((e, i) => (
{e.skill}
{e.level && · {e.level}}
))}
{extraEndorsements > 0 && (
+{extraEndorsements}
)}
)}
{/* Employer insights */}
)}
{/* Footer: email + contact + expand toggle */}
{profile.email || 'No email'}
{onContact && (
)}
);
}