-
Notifications
You must be signed in to change notification settings - Fork 19
/
SiteManifests.tsx
120 lines (114 loc) · 3.21 KB
/
SiteManifests.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import React, { useEffect, useState } from 'react';
import { Link, useParams } from 'react-router-dom';
import api from 'services';
import { Button, Row, Col, Container, Table } from 'react-bootstrap';
import HtCard from 'components/HtCard';
import HtTooltip from 'components/Tooltip';
interface SiteManifest {
generator: string[];
transporter: string[];
tsd: string[];
}
function manifestTable(manifest: string[], title: string): JSX.Element | null {
if (manifest.length === 0) {
return null;
}
return (
<HtCard>
<HtCard.Header title={title} />
<HtCard.Body>
<Table hover>
<thead>
<tr>
<th>Manifest Tracking Number</th>
<th>Status</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{manifest.map((mtn, i) => {
return (
<tr key={i}>
<td>{mtn}</td>
<td>status</td>
<td>
<HtTooltip text={`View: ${mtn}`}>
<Link to={`/manifest/${mtn}/view`}>
<i className="fa-solid fa-eye"></i>
</Link>
</HtTooltip>
</td>
<td>
<HtTooltip text={`Edit ${mtn}`}>
<Link to={`/manifest/${mtn}/edit`}>
<i className="fa-solid fa-file-lines"></i>
</Link>
</HtTooltip>
</td>
</tr>
);
})}
</tbody>
</Table>
</HtCard.Body>
</HtCard>
);
}
function SiteManifests(): JSX.Element {
let params = useParams();
const [loading, setLoading] = useState(false);
const [siteManifest, setSiteManifest] = useState<SiteManifest | undefined>(
undefined
);
useEffect(() => {
setLoading(true);
api
.get(`trak/site/${params.siteId}/manifest`, null)
.then((response) => {
setSiteManifest(response as SiteManifest);
})
.then(() => setLoading(false));
}, [params.siteId]);
return (
<>
<Container className="py-2">
<Row className="d-flex justify-content-between">
<Col className="d-flex justify-content-start">
<h2>{params.siteId}</h2>
</Col>
<Col className="d-flex justify-content-end">
<Button variant="success">
<Link
className="text-decoration-none text-white"
to={`/manifest/new/edit`}
>
New Manifest
</Link>
</Button>
</Col>
</Row>
</Container>
<Container>
<Col>
{siteManifest ? (
manifestTable(siteManifest.tsd, 'Designated Receiving Facility')
) : (
<></>
)}
{siteManifest ? (
manifestTable(siteManifest.generator, 'Generator')
) : (
<></>
)}
{siteManifest ? (
manifestTable(siteManifest.transporter, 'Transporter')
) : (
<></>
)}
</Col>
</Container>
</>
);
}
export default SiteManifests;