-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPassovers.jsx
More file actions
executable file
·80 lines (71 loc) · 2.22 KB
/
Passovers.jsx
File metadata and controls
executable file
·80 lines (71 loc) · 2.22 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React from 'react'
import LinearProgress from '@material-ui/core/LinearProgress';
import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';
import { makeStyles } from '@material-ui/core/styles';
import Paper from '@material-ui/core/Paper';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableRow from '@material-ui/core/TableRow';
import {formatDateToUTCString} from '../helpers.js'
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
},
title: {
marginLeft: theme.spacing(2),
flex: 1,
},
paper: {
marginTop: theme.spacing(3),
width: '100%',
overflowX: 'auto',
marginBottom: theme.spacing(2),
},
}));
function calculateProgessBar(startTime, currentTime, endTime) {
let maxDifference = endTime - startTime;
let progress = currentTime - startTime;
let progressPercent = Math.min((progress / maxDifference) * 100, 100);
return progressPercent.toString();
}
const Passovers = (props) => {
if (props.isLoading) {
return (
<div>
<LinearProgress />
</div>
)
}
if (props.empty && !props.isLoading) {
return (
<div>
<ErrorOutlineIcon /> There is currently no upcoming passovers!
</div>
)
}
const classes = useStyles();
return (
<div className={classes.root}>
<Paper className={classes.paper}>
{props.passovers.map(passover => (
<Table aria-label="simple table">
<TableBody>
<TableRow key={passover.passover_id} id={"passover-" + passover.passover_id}>
<div>
<TableCell width="15%" component="th" scope="row">
{formatDateToUTCString(new Date(passover.aos_timestamp + 'Z'))}
</TableCell>
</div>
<div>
<LinearProgress color="secondary" variant="determinate" value={calculateProgessBar(new Date(props.mostRecentPass.aos_timestamp + 'Z'), new Date(), new Date(passover.aos_timestamp + 'Z'))} />
</div>
</TableRow>
</TableBody>
</Table>
))}
</Paper>
</div>
)
}
export default Passovers;