forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
42 lines (36 loc) · 980 Bytes
/
index.tsx
File metadata and controls
42 lines (36 loc) · 980 Bytes
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
import * as React from 'react'
import { Wrapper, Video } from './elements'
import VideoPlayer from '../VideoPlayer'
import { TVideo } from '../App'
type Props = {
currentPath: string
videos: TVideo[]
isLoading: boolean
}
class Videos extends React.Component<Props> {
getVideo() {
const paths = this.props.currentPath.split('/')
const videoShortName = paths.length > 2 ? paths[2] : null
if (videoShortName && this.props.videos.length) {
return this.props.videos.find(
(video) => video.shortName === videoShortName
)
}
return null
}
render() {
const video = this.getVideo()
return (
<Wrapper>
{this.props.videos.map((video) => (
<Video key={video.url} href={`/videos/${video.shortName}`}>
{video.title}
<span>{video.type}</span>
</Video>
))}
{video ? <VideoPlayer url={video.url} /> : null}
</Wrapper>
)
}
}
export default Videos