{keywords.map(keyword => {
const latestRank = latest.find((r: any) => r.keyword === keyword)
const keywordHistory = historyByKeyword[keyword] || []
// Sort history by date asc for sparkline
const rankHistory = keywordHistory
.sort((a: any, b: any) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime())
.map((item: any) => item.rank || 101) // Use 101 for unranked
return (
{keyword}
{latestRank?.rank ? (
#{latestRank.rank}
) : (
Not found
)}
{rankHistory.length > 1 && (
{/* Simple visualization if Sparkline component accepts array */}
)}
Last checked: {latestRank ? new Date(latestRank.createdAt).toLocaleDateString() : 'Never'}
)
})}
)
}