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

78 lines
1.8 KiB
JavaScript
Raw Normal View History

import React, { PropTypes } from 'react';
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(
{
store: 'JobsStore',
actions: [
'appActions',
'jobActions'
],
2015-09-26 22:23:56 -07:00
map({ form: job = {} }) {
return { job };
}
},
React.createClass({
displayName: 'Preview',
propTypes: {
appActions: PropTypes.object,
job: PropTypes.object,
jobActions: PropTypes.object
},
2015-10-19 22:51:30 -07:00
componentDidMount() {
const { appActions, job } = this.props;
// redirect user in client
if (!job || !job.position || !job.description) {
appActions.goTo('/jobs/new');
}
},
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-19 15:38:48 -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
);