-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableCard.tsx
74 lines (69 loc) · 2 KB
/
TableCard.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Card, Col, Row } from "antd";
import { ProTable } from '@ant-design/pro-components';
import { Building } from "../../types";
interface TableCard {
buildings: Array<Building>
}
const columns = [
{
title: '#',
width: 50,
dataIndex: 'index',
render: (_: any) => <a>{_}</a>,
},
{
title: 'Building Name',
dataIndex: 'name',
},
{
title: 'Owner',
dataIndex: 'contact',
},
{
title: 'Address',
dataIndex: 'address',
},
{
title: 'Size',
dataIndex: 'sqft',
},
{
title: 'Type',
dataIndex: 'type',
},
{
title: 'Created At',
dataIndex: 'date',
render: (_: any) => <span>{new Date(_).toDateString()}</span>
},
];
const TableCard = ({ buildings }: TableCard) => {
if (!Array.isArray(buildings) || buildings.length === 0) return <></>
return (
<Col span={24}>
<Card bordered style={{ borderRadius: "10px" }}>
<Row justify="space-between" align="middle" >
<Col span={24}>
<ProTable
headerTitle="Building Portfolio"
dataSource={
buildings.map((el: Building, i: number) =>
({
key: el._id,
index: i + 1,
...el
}))
}
rowKey="key"
pagination={{ hideOnSinglePage: true, }}
columns={columns}
search={false}
dateFormatter="string"
/>
</Col>
</Row>
</Card>
</Col>
)
};
export default TableCard