import React from 'react'; import { useWorkerProfile } from '@/lib/krowHooks'; import { getTalentScore, getScoreBand, getGrowth } from '@/lib/talentHome'; import { ShieldCheck, Smartphone, Image as ImageIcon, QrCode, Sparkles } from 'lucide-react'; import { toast } from 'react-hot-toast'; import { Image } from '@/components/ui/image'; const clamp = (n, min = 0, max = 100) => Math.max(min, Math.min(max, Math.round(Number(n) || 0))); const toFICO = (s) => 300 + Math.round((clamp(s) / 100) * 550); function buildVCard(profile) { const name = profile.full_name || 'KROW Talent'; const [first, ...rest] = name.split(' '); const last = rest.join(' '); const lines = [ 'BEGIN:VCARD', 'VERSION:3.0', `N:${last};${first};;;`, `FN:${name}`, profile.current_position ? `TITLE:${profile.current_position}` : '', profile.phone ? `TEL;TYPE=CELL:${profile.phone}` : '', profile.email ? `EMAIL:${profile.email}` : '', `URL:https://krow.app/me`, `NOTE:KROW ID ${(profile.id || '').slice(-6).toUpperCase()}`, 'END:VCARD', ].filter(Boolean); return lines.join('\n'); } function download(filename, content, type) { const blob = new Blob([content], { type }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; a.click(); URL.revokeObjectURL(url); } export default function KrowIdPreview() { const { data: profile, isLoading } = useWorkerProfile(); if (isLoading || !profile) { return
KROW ID · {shortId}
{title}
{fico}
↑ +{growth} mo