import { IconType } from 'react-icons'; import { formatLocalDate } from '../utils/date'; import { FaGithub, FaGitlab, FaStackOverflow, FaAtlassian, FaLinkedin, FaGoogle } from 'react-icons/fa'; import { SiFiverr, SiCredly, SiKaggle } from 'react-icons/si'; import { TopContributingRule } from '../types'; interface Platform { name: string; handle?: string | null; url?: string | null; observedAt?: string; } interface ProviderInsightsProps { platforms: Platform[]; topContributingRules: TopContributingRule[]; } const providerIcons: { [key: string]: IconType } = { GitHub: FaGithub, GitLab: FaGitlab, 'Stack Overflow': FaStackOverflow, Atlassian: FaAtlassian, Fiverr: SiFiverr, LinkedIn: FaLinkedin, Credly: SiCredly, Kaggle: SiKaggle, 'Google Scholar': FaGoogle, }; const providerDisplayMap: { [key: string]: string } = { github: 'GitHub', gitlab: 'GitLab', stackoverflow: 'Stack Overflow', atlassian: 'Atlassian', fiverr: 'Fiverr', linkedin: 'LinkedIn', credly: 'Credly', kaggle: 'Kaggle', gscholar: 'Google Scholar', }; export default function ProviderInsights({ platforms, topContributingRules }: ProviderInsightsProps) { if (!platforms || platforms.length === 0) { return null; } return (
{platforms.map(platform => { const normalizedName = platform.name || ''; const Icon = normalizedName ? (providerIcons[normalizedName] || null) : null; // Group top contributing rules by provider display name const rulesForProvider = (topContributingRules || []).filter(r => { const display = providerDisplayMap[(r.provider || '').toLowerCase()] || r.provider; return display === normalizedName; }); const observedDate = platform.observedAt ? formatLocalDate(platform.observedAt, { year: 'numeric', month: 'short', day: 'numeric', }) : null; return (
{/* Header */}
{Icon && }

{platform.name}

{platform.url && ( Profile:{' '} {platform.handle || 'View Profile'} )} {observedDate && ( Observed: {observedDate} )}
{/* Top Contributing Rules */} {rulesForProvider && rulesForProvider.length > 0 && (
{rulesForProvider.map((r, idx) => (
{r.rule_label}
{r.why && (
{r.why}
)}
))}
)}
); })}
); }