Last active
January 16, 2018 10:54
-
-
Save abhiaiyer91/389c528ce756ecaec5a48f7cd9af7544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { get } from 'lodash'; | |
import { withRouter } from 'react-router'; | |
import { graphql } from 'react-apollo'; | |
import { compose, mapProps } from 'recompose'; | |
import jobListQuery from './jobList.graphql'; | |
function SomeBaseComponent() { | |
{/*... some component...*/} | |
} | |
export default compose( | |
withRouter, | |
graphql(jobListQuery, { | |
options: ({ match, jobFilter, offset }) => { | |
const vanityUrl = match.params.id; | |
return { | |
variables: { | |
vanityUrl, | |
jobFilter, | |
offset, | |
}, | |
}; | |
}, | |
}), | |
mapProps(({ data, ...rest }) => { | |
const jobs = get(data, 'jobsByEmployerId.jobs'); | |
const total = get(data, 'jobsByEmployerId.total'); | |
return { | |
ready: !data.loading, | |
listData: jobs, | |
pageCount: Math.ceil(total / 20), | |
...rest, | |
}; | |
}) | |
)(SomeBaseComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment