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

89 lines
2.0 KiB
JavaScript
Raw Normal View History

2015-08-25 14:36:07 -07:00
import React, { PropTypes } from 'react';
2015-08-29 01:00:52 -07:00
import { contain } from 'thundercats-react';
import { Row, Thumbnail, Panel, Well } from 'react-bootstrap';
2015-08-25 14:36:07 -07:00
import moment from 'moment';
2015-08-26 11:13:58 -07:00
const thumbnailStyle = {
backgroundColor: 'white',
maxHeight: '100px',
maxWidth: '100px'
};
2015-08-25 14:36:07 -07:00
2015-08-29 01:00:52 -07:00
export default contain(
{
store: 'jobsStore',
fetchAction: 'jobActions.getJob',
2015-08-31 14:32:31 -07:00
map({ currentJob }) {
return { job: currentJob };
},
getPayload({ params: { id }, job = {} }) {
2015-08-31 14:32:31 -07:00
return {
id,
isPrimed: job.id === id
2015-08-31 14:32:31 -07:00
};
},
// using es6 destructuring
shouldContainerFetch({ job = {} }, { params: { id } }
) {
return job.id !== id;
2015-08-29 01:00:52 -07:00
}
2015-08-25 14:36:07 -07:00
},
2015-08-29 01:00:52 -07:00
React.createClass({
displayName: 'ShowJob',
propTypes: {
job: PropTypes.object,
params: PropTypes.object
},
renderHeader({ company, position }) {
return (
<div>
<h4 style={{ display: 'inline-block' }}>{ company }</h4>
<h5
className='pull-right hidden-xs hidden-md'
style={{ display: 'inline-block' }}>
{ position }
</h5>
</div>
);
},
2015-08-25 14:36:07 -07:00
2015-08-29 01:00:52 -07:00
render() {
const { job = {} } = this.props;
2015-08-29 01:00:52 -07:00
const {
logo,
position,
city,
company,
state,
email,
phone,
postedOn,
description
} = job;
2015-08-25 14:36:07 -07:00
2015-08-29 01:00:52 -07:00
return (
<div>
<Row>
<Well>
<Thumbnail
alt={ company + 'company logo' }
src={ logo }
style={ thumbnailStyle } />
<Panel>
Position: { position }
Location: { city }, { state }
<br />
Contact: { email || phone || 'N/A' }
<br />
Posted On: { moment(postedOn).format('MMMM Do, YYYY') }
</Panel>
<p>{ description }</p>
</Well>
</Row>
</div>
);
}
})
);