-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDashboardTable.js
64 lines (59 loc) · 1.87 KB
/
DashboardTable.js
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
import React from "react";
import axios from "axios";
import { Table, Loader, Dimmer } from "semantic-ui-react";
import "./DashboardTable.css";
const GET_PROJECTS_URL =
"https://postgres-dashboard-7fc.can.canonic.dev/api/projects";
function DashboardTable() {
const [loading, setLoading] = React.useState(false);
const [projects, setProjects] = React.useState([]);
React.useEffect(() => {
setLoading(true);
axios(GET_PROJECTS_URL).then(({ data }) => {
setProjects(data.data || []);
setLoading(false);
});
}, []);
return (
<div className="dashboardTable-wrapper">
<Dimmer active={loading} inverted>
<Loader />
</Dimmer>
<Table textAlign="left" celled padded>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Description</Table.HeaderCell>
<Table.HeaderCell>Owner</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{projects.map((item, i) => (
<Table.Row>
<Table.Cell width={2} className="dashboardTable-cell-name">
<div>{item.name}</div>
</Table.Cell>
<Table.Cell width={5}>
<div>{item.description}</div>
</Table.Cell>
<Table.Cell width={1}>
<div>{item.users.name}</div>
</Table.Cell>
<Table.Cell width={1}>
<div
className={`dashboardTable-status ${
item.status === "completed" && "green-row"
}`}
>
{item.status}
</div>
</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
</div>
);
}
export default DashboardTable;