-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PassedEvents.js
62 lines (58 loc) · 2.15 KB
/
PassedEvents.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
import React from 'react'
import Grid from '@material-ui/core/Grid'
import { useStateValue } from '../../../state/state'
import Event from './Event'
import {
selectPassedEvents,
selectUpcomingEvents,
} from '../../../state/selectors'
import Typography from '@material-ui/core/Typography'
import Button from '@material-ui/core/Button'
import { Link as RouterLink } from 'react-router-dom'
import { RoutingMap } from '../../../UseRoutingMap'
import CircularProgress from '@material-ui/core/CircularProgress'
import Box from '@material-ui/core/Box'
const PassedEvents = ({ token }) => {
const [
{
selectedOrganization: { id, events, eventsLoading },
},
] = useStateValue()
const upcomingEvents = selectUpcomingEvents(events)
const passedEvents = selectPassedEvents(events)
const routing = RoutingMap(id).orgs.org.upcomingEvents
const upcomingUrl = token ? `${routing.url}?token=${token}` : routing.url
return (
<Grid container spacing={4}>
{id && (
<Grid item xs={12} style={{ textAlign: 'right' }}>
<Button
to={upcomingUrl}
component={RouterLink}
variant="outlined"
color="primary">
See {routing.name}{' '}
{upcomingEvents && `(${upcomingEvents.length})`}
</Button>
</Grid>
)}
{passedEvents.map(event => (
<Event key={event.id} event={event} />
))}
{passedEvents.length === 0 && (
<Grid item>
{eventsLoading && (
<Box display="flex" alignItems="center">
<CircularProgress style={{ marginRight: 16 }} />
<Typography>Events loading...</Typography>
</Box>
)}
{!eventsLoading && (
<Typography>No passed events</Typography>
)}
</Grid>
)}
</Grid>
)
}
export default PassedEvents