2015-07-25 21:32:18 -07:00
|
|
|
import React, { cloneElement, PropTypes } from 'react';
|
2015-07-25 15:15:59 -07:00
|
|
|
import { contain } from 'thundercats-react';
|
2015-09-13 18:12:22 -07:00
|
|
|
import { History } from 'react-router';
|
2015-10-15 21:10:06 -07:00
|
|
|
import { Button, Panel, Row, Col } from 'react-bootstrap';
|
2015-09-14 13:06:27 -07:00
|
|
|
|
|
|
|
import CreateJobModal from './CreateJobModal.jsx';
|
2015-08-25 12:25:30 -07:00
|
|
|
import ListJobs from './List.jsx';
|
2015-06-17 21:04:28 -07:00
|
|
|
|
2015-07-25 13:58:26 -07:00
|
|
|
export default contain(
|
|
|
|
{
|
|
|
|
store: 'jobsStore',
|
2015-09-10 16:26:41 -07:00
|
|
|
fetchAction: 'jobActions.getJobs',
|
|
|
|
actions: 'jobActions'
|
2015-07-25 13:58:26 -07:00
|
|
|
},
|
|
|
|
React.createClass({
|
|
|
|
displayName: 'Jobs',
|
2015-09-10 16:26:41 -07:00
|
|
|
|
2015-09-14 13:06:27 -07:00
|
|
|
mixins: [History],
|
|
|
|
|
2015-07-25 13:58:26 -07:00
|
|
|
propTypes: {
|
2015-07-25 21:32:18 -07:00
|
|
|
children: PropTypes.element,
|
2015-09-10 16:26:41 -07:00
|
|
|
jobActions: PropTypes.object,
|
2015-09-14 13:06:27 -07:00
|
|
|
jobs: PropTypes.array,
|
|
|
|
showModal: PropTypes.bool
|
2015-07-25 13:58:26 -07:00
|
|
|
},
|
2015-09-10 16:26:41 -07:00
|
|
|
|
|
|
|
handleJobClick(id) {
|
|
|
|
const { jobActions } = this.props;
|
|
|
|
if (!id) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
jobActions.findJob(id);
|
2015-09-13 18:12:22 -07:00
|
|
|
this.history.pushState(null, `/jobs/${id}`);
|
2015-09-10 16:26:41 -07:00
|
|
|
},
|
2015-06-17 21:04:28 -07:00
|
|
|
|
2015-09-10 16:26:41 -07:00
|
|
|
renderList(handleJobClick, jobs) {
|
2015-07-25 21:32:18 -07:00
|
|
|
return (
|
2015-09-10 16:26:41 -07:00
|
|
|
<ListJobs
|
|
|
|
handleClick={ handleJobClick }
|
|
|
|
jobs={ jobs }/>
|
2015-07-25 21:32:18 -07:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
renderChild(child, jobs) {
|
|
|
|
if (!child) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return cloneElement(
|
|
|
|
child,
|
|
|
|
{ jobs }
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2015-07-25 13:58:26 -07:00
|
|
|
render() {
|
2015-09-14 13:06:27 -07:00
|
|
|
const {
|
|
|
|
children,
|
|
|
|
jobs,
|
|
|
|
showModal,
|
|
|
|
jobActions
|
|
|
|
} = this.props;
|
2015-07-25 21:32:18 -07:00
|
|
|
|
2015-07-25 13:58:26 -07:00
|
|
|
return (
|
2015-10-15 20:03:07 -07:00
|
|
|
<Panel>
|
2015-07-25 13:58:26 -07:00
|
|
|
<Row>
|
2015-10-15 21:10:06 -07:00
|
|
|
<Col
|
|
|
|
md={ 10 }
|
|
|
|
mdOffset= { 1 }
|
|
|
|
xs={ 12 }>
|
|
|
|
<h1 className='text-center'>Free Code Camps' Job Board</h1>
|
|
|
|
<Row>
|
|
|
|
<Col
|
|
|
|
xs={ 10 }
|
|
|
|
xsOffset={ 1 }>
|
|
|
|
<p>
|
|
|
|
Need to find the best junior developers?
|
|
|
|
Post your job today!
|
|
|
|
</p>
|
|
|
|
<Button
|
|
|
|
block={ true }
|
|
|
|
bsSize='large'
|
|
|
|
className='signup-btn'
|
|
|
|
onClick={ jobActions.openModal }>
|
|
|
|
Post a job: $200 for 60 days.
|
|
|
|
</Button>
|
|
|
|
<div className='spacer' />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
<Row>
|
|
|
|
{ this.renderChild(children, jobs) ||
|
|
|
|
this.renderList(this.handleJobClick, jobs) }
|
|
|
|
</Row>
|
|
|
|
<CreateJobModal
|
|
|
|
onHide={ jobActions.closeModal }
|
|
|
|
showModal={ showModal } />
|
|
|
|
</Col>
|
2015-07-25 13:58:26 -07:00
|
|
|
</Row>
|
2015-10-15 20:03:07 -07:00
|
|
|
</Panel>
|
2015-07-25 13:58:26 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|