-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathRemodelTable.tsx
More file actions
63 lines (56 loc) · 1.52 KB
/
RemodelTable.tsx
File metadata and controls
63 lines (56 loc) · 1.52 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { useAtomValue } from "jotai";
import { MainTable, TablePagination } from "@canonical/react-components";
import { format } from "date-fns";
import { remodelsListState } from "../../state/remodelsState";
import type { Remodel } from "../../types/shared";
function RemodelTable(): React.JSX.Element {
const remodels = useAtomValue(remodelsListState);
const headers = [
{
content: "Target model",
style: { width: "250px" },
},
{
content: "Original model",
style: { width: "250px" },
},
{ content: "Serial" },
{
content: "Created date",
className: "u-align--right",
style: { width: "130px" },
},
{ content: "Note" },
];
const rows = remodels.map((remodel: Remodel) => {
return {
columns: [
{ content: remodel["to-model"], className: "u-truncate" },
{ content: remodel["from-model"], className: "u-truncate" },
{
content: remodel["from-serial"] || "All serial policies",
className: "u-truncate",
},
{
content: format(new Date(remodel["created-at"]), "dd/MM/yyyy"),
className: "u-align--right",
},
{ content: remodel["description"] },
],
};
});
return (
<TablePagination
data={rows}
pageLimits={[25, 50, 100, 200]}
position="below"
>
<MainTable
data-testid="remodel-table"
emptyStateMsg="No remodels found"
headers={headers}
/>
</TablePagination>
);
}
export default RemodelTable;