Files
freeCodeCamp/common/app/routes/Jobs/components/Jobs.jsx

102 lines
2.4 KiB
JavaScript
Raw Normal View History

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';
import ListJobs from './List.jsx';
2015-06-17 21:04:28 -07:00
export default contain(
{
store: 'jobsStore',
fetchAction: 'jobActions.getJobs',
actions: 'jobActions'
},
React.createClass({
displayName: 'Jobs',
2015-09-14 13:06:27 -07:00
mixins: [History],
propTypes: {
2015-07-25 21:32:18 -07:00
children: PropTypes.element,
jobActions: PropTypes.object,
2015-09-14 13:06:27 -07:00
jobs: PropTypes.array,
showModal: PropTypes.bool
},
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-06-17 21:04:28 -07:00
renderList(handleJobClick, jobs) {
2015-07-25 21:32:18 -07:00
return (
<ListJobs
handleClick={ handleJobClick }
jobs={ jobs }/>
2015-07-25 21:32:18 -07:00
);
},
renderChild(child, jobs) {
if (!child) {
return null;
}
return cloneElement(
child,
{ jobs }
);
},
render() {
2015-09-14 13:06:27 -07:00
const {
children,
jobs,
showModal,
jobActions
} = this.props;
2015-07-25 21:32:18 -07:00
return (
<Panel>
<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>
</Row>
</Panel>
);
}
})
);