-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKbUsageTable.tsx
More file actions
48 lines (46 loc) · 1.35 KB
/
Copy pathKbUsageTable.tsx
File metadata and controls
48 lines (46 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { ArticleUsage } from "../../hooks/useAnalytics";
export function KbUsageTable({
articles,
onArticleClick,
}: {
articles: ArticleUsage[];
onArticleClick?: (id: string) => void;
}) {
if (articles.length === 0) {
return (
<div className="kb-usage-table">
<div className="kb-usage-header">
<div>Article</div>
<div style={{ textAlign: "right" }}>Uses</div>
</div>
<div className="analytics-empty">
<div className="analytics-empty-description">
No article usage data yet
</div>
</div>
</div>
);
}
return (
<div className="kb-usage-table">
<div className="kb-usage-header">
<div>Article</div>
<div style={{ textAlign: "right" }}>Uses</div>
</div>
{articles.map((article) => (
<div
key={article.document_id}
className={`kb-usage-row ${onArticleClick ? "kb-usage-row-clickable" : ""}`}
onClick={() => onArticleClick?.(article.document_id)}
role={onArticleClick ? "button" : undefined}
tabIndex={onArticleClick ? 0 : undefined}
>
<div className="kb-usage-title" title={article.title}>
{article.title}
</div>
<div className="kb-usage-count">{article.usage_count}</div>
</div>
))}
</div>
);
}