-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUploadValidationStatus.tsx
61 lines (52 loc) · 1.29 KB
/
UploadValidationStatus.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
import { timeTag } from 'src/lib/formatters'
const UploadValidationStatus = ({ latestValidation }) => {
const getValidationIcon = (passed: boolean) => {
const iconClass = passed ? 'bi bi-check-lg' : 'bi bi-x-circle-fill'
return <i className={iconClass} />
}
const getValidationStatus = () => {
const {
passed,
isManual,
createdAt,
results,
initiatedBy: { name },
} = latestValidation
if (results === null) {
return (
<span className="text-warning fst-italic">
Validation in progress...
</span>
)
}
const valueClassName = !passed ? 'text-danger' : 'text-success'
const time = timeTag(createdAt)
let statusOutcome
if (isManual) {
statusOutcome = 'Invalidated'
} else {
statusOutcome = passed ? 'Validated' : 'Did not pass validation'
}
const statusText = (
<>
{statusOutcome}
{' on '}
{time}
{' by '}
{name}
</>
)
return (
<span className={valueClassName}>
{getValidationIcon(passed)} {statusText}
</span>
)
}
return (
<li className="list-group-item">
<span className="fw-bold">Validation: </span>
{getValidationStatus()}
</li>
)
}
export default UploadValidationStatus