This repository was archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
82 lines (80 loc) · 2.56 KB
/
index.tsx
File metadata and controls
82 lines (80 loc) · 2.56 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
81
82
import { h } from 'preact'
import { getEvent } from '../../api'
import Button from '../../components/button'
import Header from '../../components/header'
import Icon from '../../components/icon'
import List from '../../components/list'
import Spinner from '../../components/spinner'
import Resolver from '../../resolver'
import {
compareMatchKey,
formatMatchKey,
formatTime,
parseMatchKey
} from '../../utils'
import style from './style.css'
const Event = ({ eventId }: { eventId: string }) => (
<Resolver
data={{ event: getEvent(eventId) }}
render={({ event }) => (
<div class={style.event}>
<Header
title={(event && event.shortName) || `Event ${eventId}`}
back="/"
/>
<div>
<Button href={`/events/${eventId}/analysis`}>View Analysis</Button>
<Button href={`/events/${eventId}/compare?back=/events/${eventId}`}>
Compare Teams
</Button>
</div>
{typeof event === 'undefined' ? (
<Spinner />
) : event.matches === null || event.matches.length === 0 ? (
<p>No Matches</p>
) : (
<List>
{event.matches
.map(m => {
m.time = new Date(m.actualTime || m.predictedTime)
return m
})
.sort((a, b) => compareMatchKey(a.key, b.key))
.map(m => {
const { matchKey } = parseMatchKey(m.key)
return (
<li key={m.key}>
<a
class={style.match}
href={`/events/${event.key}/${matchKey}`}
>
<div>
<span>{formatMatchKey(matchKey)}</span>
<span>{formatTime(m.time)}</span>
</div>
</a>
{m.youtubeURL !== '' ? (
<a
href={m.youtubeURL}
target="_blank"
rel="noopener noreferrer"
aria-label="Watch on YouTube"
>
<Icon icon="youtube" fill="red" />
</a>
) : (
// eslint-disable-next-line caleb/jsx-a11y/anchor-is-valid
<a>
<Icon icon="youtube" fill="grey" />
</a>
)}
</li>
)
})}
</List>
)}
</div>
)}
/>
)
export default Event