-
Notifications
You must be signed in to change notification settings - Fork 4
/
ClassificationsTable.tsx
50 lines (47 loc) · 1.36 KB
/
ClassificationsTable.tsx
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
49
50
import * as React from "react";
import { ClassificationData } from "../interfaces";
export interface ClassificationsTableProps {
classifications: ClassificationData[];
}
/** Shows a table of a book's current classifications on the classifications tab of the
book detail page. */
export default class ClassificationsTable extends React.Component<
ClassificationsTableProps,
{}
> {
render(): JSX.Element {
return (
<div className="classifications-table">
<h3>Related Classifications</h3>
<table className="table">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Source</th>
<th>Weight</th>
</tr>
</thead>
<tbody>
{this.props.classifications.map((classification, idx) => (
<tr
key={`${classification.source}:${classification.name || idx}`}
>
<td>{this.readableType(classification.type)}</td>
<td>{classification.name}</td>
<td>{classification.source}</td>
<td>{classification.weight}</td>
</tr>
))}
</tbody>
</table>
</div>
);
}
readableType(type) {
return type.replace(
/http:\/\/librarysimplified\.org\/terms\/genres\/([^\/]+)\//,
"$1"
);
}
}