Completed
Push — master ( 822908...45ea40 )
by Junior
25s
created

FeedContainer.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 1
rs 10
1
import { compose, branch, renderComponent, renderNothing } from 'recompose';
2
import { graphql } from 'react-apollo';
3
import { getGithubActivity } from 'services/graphQLQuery';
4
import MainFeedComponent from 'components/MainFeedComponent';
5
import SpinnerComponent from 'components/SpinnerComponent';
6
import ErrorComponent from 'components/ErrorComponent';
7
8
const isLoading = ({ activity }) => activity.loading;
9
const hasError = ({ activity }) => activity.error;
10
const hasNoData = ({ activity }) => !activity;
11
12
const nonOptimalStates = states =>
13
  compose(
14
    ...states.map(state => branch(state.when, renderComponent(state.render)))
15
  );
16
17
export default compose(
18
  graphql(getGithubActivity, {
19
    name: 'activity'
20
  }),
21
  nonOptimalStates([
22
    { when: hasNoData, render: renderNothing() },
23
    { when: hasError, render: ErrorComponent },
24
    { when: isLoading, render: SpinnerComponent }
25
  ])
26
)(MainFeedComponent);
27