-
Notifications
You must be signed in to change notification settings - Fork 4
/
after.js
52 lines (44 loc) · 1.14 KB
/
after.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
import React from 'react'
import { ScrollView, Text, View } from 'react-native'
import { pure, compose, branch, renderComponent } from 'recompose'
import Loading from 'components/loading'
import Video from 'components/video'
import API from 'services/api'
import withModel from 'lib/with-model'
let SeriesPage = ({ data }) =>
<ScrollView>
<View>
<Text>{data.title}</Text>
{ data.description ? <Text>{data.description}</Text> : null }
</View>
<View>
<VideoListWithEmptyState videos={data.videos} />
</View>
</ScrollView>
let VideoList = ({ videos }) =>
<View>
{ videos.map(video =>
<Video key={video.id} data={video} />
) }
</View>
let NoVideosFound = () =>
<View>
<Text>No videos found</Text>
</View>
let VideoListWithEmptyState = branch(
({ videos }) => videos.length === 0,
renderComponent(NoVideosFound)
)(VideoList)
let model = async ({ id }) => {
let res = await API.getSeries(id)
let json = await res.json()
return json.series
}
let enhance = compose(
withModel(model, null),
branch(
({ data }) => !data,
renderComponent(Loading)
)
)
export default enhance(SeriesPage)