/** * Bot Analytics summary table (extracted unchanged from * dashboard-analytics.tsx — P2-2.1). Pure presentational component. */ import { getDefaultBotLogo } from './constants'; import type { BotStat, BotSummary } from './constants'; import { __, sprintf } from '../../lib/i18n'; interface BotSummaryTableProps { botSummaries: BotSummary[]; botStats: BotStat[]; showFullStatsLink: boolean; } export function BotSummaryTable({ botSummaries, botStats, showFullStatsLink }: BotSummaryTableProps) { return (
{/* Table Header */}

{__('Bot Analytics', 'llmagnet-llm-txt-generator')}

{showFullStatsLink && ( {__('View Full Statistics →', 'llmagnet-llm-txt-generator')} )}
{/* Table */}
{botSummaries.map((bot) => { // Find corresponding bot stats for clicks data const botStat = botStats.find(stat => stat.bot_name === bot.bot_name); // Calculate trend value - use botStat trend or percentage_change from bot const trendValue = botStat?.trend ?? bot.percentage_change ?? 0; return ( ); })}
{__('Bot', 'llmagnet-llm-txt-generator')} {__('Total Visits', 'llmagnet-llm-txt-generator')} {__('Clicks', 'llmagnet-llm-txt-generator')} {__('CTR', 'llmagnet-llm-txt-generator')} {__('Trend', 'llmagnet-llm-txt-generator')}
{sprintf( { (e.target as HTMLImageElement).src = getDefaultBotLogo(); console.log(`Failed to load logo for ${bot.bot_name}, using default`); }} loading="lazy" /> {bot.bot_name}
{Number(bot.total_visits).toLocaleString()} {(botStat?.clicks || 0).toLocaleString()} {(botStat?.ctr ?? 0).toFixed(0)}% 0 ? { backgroundColor: '#BEF3CC', color: '#209067' } : trendValue < 0 ? { backgroundColor: '#F3C0BE', color: '#902F20' } : { backgroundColor: '#E5E7EB', color: '#6B7280' } } > {trendValue > 0 ? '+' : ''}{Math.abs(trendValue).toFixed(0)}%
); }