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

114 lines
2.8 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-10-15 21:10:06 -07:00
import { Button, Panel, Row, Col } from 'react-bootstrap';
2015-09-14 13:06:27 -07:00
import ListJobs from './List.jsx';
2015-10-19 14:19:04 -07:00
import TwitterBtn from './TwitterBtn.jsx';
2015-06-17 21:04:28 -07:00
export default contain(
{
store: 'jobsStore',
fetchAction: 'jobActions.getJobs',
2015-10-16 20:05:22 -07:00
actions: [
'appActions',
'jobActions'
]
},
React.createClass({
displayName: 'Jobs',
propTypes: {
2015-07-25 21:32:18 -07:00
children: PropTypes.element,
2015-10-19 14:19:04 -07:00
numOfFollowers: PropTypes.number,
2015-10-16 20:05:22 -07:00
appActions: PropTypes.object,
jobActions: PropTypes.object,
2015-09-14 13:06:27 -07:00
jobs: PropTypes.array,
showModal: PropTypes.bool
},
2015-10-19 14:19:04 -07:00
componentDidMount() {
const { jobActions } = this.props;
jobActions.getFollowers();
},
handleJobClick(id) {
2015-10-16 20:05:22 -07:00
const { appActions, jobActions } = this.props;
if (!id) {
return null;
}
jobActions.findJob(id);
2015-10-16 20:05:22 -07:00
appActions.goTo(`/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,
2015-10-19 14:19:04 -07:00
numOfFollowers,
2015-09-14 13:06:27 -07:00
jobs,
2015-10-16 20:05:22 -07:00
appActions
2015-09-14 13:06:27 -07:00
} = 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 }>
2015-10-16 16:12:01 -07:00
<h1 className='text-center'>Job Opportunities</h1>
<Row className='text-center'>
2015-10-15 21:10:06 -07:00
<Col
2015-10-16 16:12:01 -07:00
xs={ 12 }
xsOffset={ 0 }>
<p className='text-center large-p'>
Talented web developers with strong portfolios are eager
to work for your company.
2015-10-15 21:10:06 -07:00
</p>
2015-10-16 16:12:01 -07:00
</Col>
<Col
sm={ 8 }
2015-10-16 20:05:22 -07:00
smOffset={ 2 }
xs={ 12 }>
2015-10-15 21:10:06 -07:00
<Button
bsSize='large'
2015-10-16 16:12:01 -07:00
className='signup-btn btn-block'
2015-10-16 20:05:22 -07:00
onClick={ ()=> {
appActions.goTo('/jobs/new');
}}>
2015-10-16 16:12:01 -07:00
Post a job: $200 for 30 days + weekly tweets
2015-10-15 21:10:06 -07:00
</Button>
2015-10-16 16:12:01 -07:00
<div className='button-spacer' />
2015-10-19 14:19:04 -07:00
<TwitterBtn count={ numOfFollowers || 0 } />
2015-10-15 21:10:06 -07:00
<div className='spacer' />
</Col>
</Row>
<Row>
{ this.renderChild(children, jobs) ||
this.renderList(this.handleJobClick, jobs) }
</Row>
</Col>
</Row>
</Panel>
);
}
})
);