import React from 'react'; import { LuTrash2 } from 'react-icons/lu'; import EmptyState from '../agent-analytics/EmptyState'; import { cn } from '../copilot/cn'; import { ARTICLE_STATUS } from '../../service/visibility/visibility.constants'; import type { ArticleSummary } from '../../service/visibility/visibility.interface'; import { DataGrid, DataGridHead, DataGridRow } from './DataGrid'; import { contentTypeLabel, contentTypeTone, countLanguageSiblings, profilePlatformLabel, scoreTone, } from './helpers'; import Pill from './Pill'; const COLUMNS = 'minmax(220px,2.6fr) 128px 116px 76px minmax(150px,0.9fr) 108px 44px'; const COLUMNS_SM = '1fr auto'; const NO_VALUE = '–'; interface ArticlesTableProps { articles: ArticleSummary[]; allArticles: ArticleSummary[]; onOpen: (articleId: string) => void; onDelete?: (article: ArticleSummary) => void; deleting?: Record; scheduledByArticle?: Record; emptyMessage?: string; } const statusTone = ( status: string ): 'success' | 'attention' | 'warning' | 'critical' | 'info' => { if (status === ARTICLE_STATUS.PUBLISHED) return 'success'; if (status === ARTICLE_STATUS.READY) return 'info'; if (status === ARTICLE_STATUS.FAILED) return 'critical'; return 'attention'; }; function ArticlesTable({ articles, allArticles, onOpen, onDelete, deleting = {}, scheduledByArticle = {}, emptyMessage = 'No contents to show', }: ArticlesTableProps): JSX.Element { if (articles.length === 0) { return ; } return (
Title
Type
Status
Words
Quality
Languages
{articles.map(article => { const languageCount = countLanguageSiblings( allArticles, article.translation_group_id ); const scheduledFor = scheduledByArticle[article.article_id]; const isReady = article.status === ARTICLE_STATUS.READY || article.status === ARTICLE_STATUS.PUBLISHED; return (
{article.slug && (

/{article.slug}

)}
{article.content_type ? ( {contentTypeLabel(article.content_type)} ) : ( {NO_VALUE} )} {article.content_type === 'profile' && article.profile_platform && ( {profilePlatformLabel(article.profile_platform)} )}
{article.status} {scheduledFor && ( {`Publishes ${new Date(scheduledFor).toLocaleDateString( undefined, { day: 'numeric', month: 'short' } )}`} )}
{article.word_count > 0 ? article.word_count : NO_VALUE}
{/* One cell, not three near-empty columns of two-digit numbers. */}
{isReady && (article.seo_score ?? 0) > 0 ? ( <> {`SEO ${article.seo_score}`} {(article.aeo_score ?? 0) > 0 && ( {`AEO ${article.aeo_score}`} )} ) : ( {NO_VALUE} )}
{/* The card view's "Available in N languages" wraps to two lines in this column, so the sentence moves to the tooltip. */}
{languageCount > 1 ? ( {`${languageCount} languages`} ) : ( {NO_VALUE} )}
{onDelete && ( )}
); })} ); } export default ArticlesTable;