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

86 lines
2.0 KiB
JavaScript
Raw Normal View History

import React, { PropTypes } from 'react';
2015-10-26 18:00:33 -07:00
import { Lifecycle } from 'react-router';
import { Panel, Button, Row, Col } from 'react-bootstrap';
2015-09-26 22:23:56 -07:00
import { contain } from 'thundercats-react';
2015-10-19 22:51:30 -07:00
2015-09-26 22:23:56 -07:00
import ShowJob from './ShowJob.jsx';
2015-10-19 22:51:30 -07:00
import JobNotFound from './JobNotFound.jsx';
2015-09-26 22:23:56 -07:00
export default contain(
{
2016-01-04 14:26:07 -08:00
store: 'appStore',
actions: [
'appActions',
'jobActions'
],
2016-01-05 12:46:54 -08:00
map({ jobsApp: { form: job = {} } }) {
2015-09-26 22:23:56 -07:00
return { job };
}
},
React.createClass({
displayName: 'Preview',
propTypes: {
appActions: PropTypes.object,
job: PropTypes.object,
jobActions: PropTypes.object
},
2015-10-26 18:00:33 -07:00
mixins: [Lifecycle],
2015-10-19 22:51:30 -07:00
componentDidMount() {
const { appActions, job } = this.props;
// redirect user in client
if (!job || !job.position || !job.description) {
2016-01-04 14:26:07 -08:00
appActions.goTo('/jobs/new');
2015-10-19 22:51:30 -07:00
}
},
2015-10-26 18:00:33 -07:00
routerWillLeave() {
const { jobActions } = this.props;
jobActions.clearPromo();
},
render() {
const { appActions, job, jobActions } = this.props;
2015-10-19 22:51:30 -07:00
2015-10-20 15:01:05 -07:00
if (!job || !job.position || !job.description) {
2015-10-19 22:51:30 -07:00
return <JobNotFound />;
}
return (
<div>
<ShowJob job={ job } />
<Row>
<Col
md={ 10 }
mdOffset={ 1 }
xs={ 12 }>
<Panel>
<Button
block={ true }
className='signup-btn'
onClick={ () => {
2015-10-26 18:02:55 -07:00
jobActions.clearSavedForm();
jobActions.saveJobToDb({
goTo: '/jobs/new/check-out',
job
});
}}>
Looks great! Let's Check Out
</Button>
<Button
block={ true }
onClick={ () => appActions.goBack() } >
Head back and make edits
</Button>
</Panel>
</Col>
</Row>
</div>
);
}
})
2015-09-26 22:23:56 -07:00
);