import type { ProfileView } from '../types'; import React from 'react'; import { Link } from 'react-router-dom'; import { ArrowRight } from 'lucide-react'; import { getTalentScore, getMarketValue, getFactors } from '@/lib/talentHome'; import CareerScoreGauge from '@/components/krow/talent/CareerScoreGauge'; function greeting() { const h = new Date().getHours(); if (h < 12) return 'Good morning'; if (h < 18) return 'Good afternoon'; return 'Good evening'; } const TIERS = ['Beginner', 'Cross-Trained', 'Skilled']; function currentTierIndex(profile: Partial = {}) { const badges = (profile.earned_badges || []).length; const shifts = profile.shifts_completed || 0; if (badges >= 5 || shifts >= 50) return 2; if (badges >= 1 || shifts >= 10) return 1; return 0; } function nextPromotion(profile = {}) { const idx = currentTierIndex(profile); return TIERS[Math.min(idx + 1, TIERS.length - 1)]; } function marketRange(profile = {}) { const uplift = getMarketValue(profile); const low = 20 + uplift; return `$${low}-$${low + 4}/hr`; } /** Props for the local `Field` helper in this file. Optional throughout: the JavaScript validated none of them and callers omit freely. */ interface FieldProps { label?: any; value?: any; sub?: any; accent?: any; } function Field({ label, value, sub = '', accent = false }: FieldProps) { return (

{label}

{value}

{sub && {sub}}
); } function statusFor(v) { if (v >= 80) return { txt: 'Excellent', color: 'text-[#16A34A]', dot: 'bg-[#16A34A]' }; if (v >= 60) return { txt: 'Good', color: 'text-[#0838E0]', dot: 'bg-[#0838E0]' }; if (v >= 40) return { txt: 'Fair', color: 'text-[#D97706]', dot: 'bg-[#D97706]' }; if (v > 0) return { txt: 'Poor', color: 'text-[#DC2626]', dot: 'bg-[#DC2626]' }; return { txt: 'No data', color: 'text-[#9CA3AF]', dot: 'bg-[#D1D5DB]' }; } /** Props for the local `Factor` helper in this file. Optional throughout: the JavaScript validated none of them and callers omit freely. */ interface FactorProps { label?: any; value?: any; weight?: any; } function Factor({ label, value, weight }: FactorProps) { const s = statusFor(value); return (
{label} {weight}% weight
{s.txt}
); } interface TalentHeroProps { profile: ProfileView; /** * Passed by `EmployeeDashboard`, ignored by this component. * * The signature destructures `_jobRecs` — the underscore marking it * deliberately unused — so the prop the caller sends never binds to anything. * Declared here because the caller does send it, and an excess-property error * would be TypeScript objecting to a prop JavaScript simply dropped. */ jobRecs?: any; _jobRecs?: any; nextCourse?: any; openOwliver?: any; } export default function TalentHero({ profile, _jobRecs = [], nextCourse = null, openOwliver = null }: TalentHeroProps) { const score = getTalentScore(profile); const factors = getFactors(profile); const first = (profile.full_name || 'there').split(' ')[0]; const incomplete = score === 0 && !(profile.skills || []).length; const missionGain = nextCourse ? Math.max(1, Math.round((nextCourse.xp || 100) / 20)) : 0; const mission = nextCourse ? { label: nextCourse.title, sub: `+${missionGain} Score`, to: `/university/${nextCourse.id}` } : incomplete ? { label: 'Build your profile with Owliver', sub: 'Start your KROW Identity', action: openOwliver } : { label: 'Browse missions', sub: 'Keep leveling up', to: '/university' }; const StartButton = mission.to ? ( START NOW ) : ( ); return (

{greeting()}, {first}

What's Driving Your Score

Updated this month
{factors.map((f) => )}
{StartButton}
); }