import React, { cloneElement, PropTypes } from 'react'; import { connect, compose } from 'redux'; import { createSelector } from 'reselect'; import { push } from 'react-router-redux'; import PureComponent from 'react-pure-render/component'; import { Button, Row, Col } from 'react-bootstrap'; import contain from '../../../utils/professor-x'; import ListJobs from './List.jsx'; import { findJob, fetchJobs } from '../redux/actions'; const mapSateToProps = createSelector( state => state.jobsApp.jobs.entities, state => state.jobsApp.jobs.results, state => state.jobsApp, (jobsMap, jobsById) => { return jobsById.map(id => jobsMap[id]); } ); const bindableActions = { findJob, fetchJobs, push }; const fetchOptions = { fetchAction: 'fetchJobs', isPrimed({ jobs }) { return !!jobs.results.length; } }; export class Jobs extends PureComponent { static displayName = 'Jobs'; static propTypes = { push: PropTypes.func, findJob: PropTypes.func, fetchJobs: PropTypes.func, children: PropTypes.element, jobs: PropTypes.array, showModal: PropTypes.bool }; createJobClickHandler(id) { const { findJob, push } = this.props; if (!id) { return null; } return id => { findJob(id); push(`/jobs/${id}`); }; } renderList(handleJobClick, jobs) { return ( ); } renderChild(child, jobs) { if (!child) { return null; } return cloneElement( child, { jobs } ); } render() { const { children, jobs } = this.props; return (

Hire a JavaScript engineer who's experienced in HTML5, Node.js, MongoDB, and Agile Development.

{`

We hired our last developer out of Free Code Camp and couldn't be happier. Free Code Camp is now our go-to way to bring on pre-screened candidates who are enthusiastic about learning quickly and becoming immediately productive in their new career.

Michael Gai, CEO at CoNarrative
{ this.renderChild(children, jobs) || this.renderList(this.createJobClickHandler(), jobs) } ); } } export default compose( connect(mapSateToProps, bindableActions), contain(fetchOptions) )(Jobs);