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

src/containers/FeedContainer.js   A

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 26
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 26
rs 10
wmc 5
mnd 0
bc 0
fnc 5
bpm 0
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A FeedContainer.js ➔ ??? 0 1 1
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