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

86 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-07-25 21:32:18 -07:00
import React, { PropTypes } from 'react';
2015-08-13 12:33:53 -07:00
import { PanelGroup, Thumbnail, Panel, Well } from 'react-bootstrap';
import moment from 'moment';
2015-07-25 21:32:18 -07:00
2015-09-07 23:52:21 -07:00
export default React.createClass({
displayName: 'ListJobs',
2015-07-25 21:32:18 -07:00
2015-09-07 23:52:21 -07:00
propTypes: {
handleClick: PropTypes.func,
2015-09-07 23:52:21 -07:00
jobs: PropTypes.array
},
2015-07-25 21:32:18 -07:00
renderJobs(handleClick, jobs =[]) {
2015-09-07 23:52:21 -07:00
const thumbnailStyle = {
backgroundColor: 'white',
maxHeight: '100px',
maxWidth: '100px'
};
2015-09-07 23:52:21 -07:00
return jobs.map((
{
id,
company,
position,
2015-09-14 12:12:31 -07:00
isHighlighted,
2015-09-07 23:52:21 -07:00
description,
logo,
city,
state,
email,
phone,
postedOn
},
index
) => {
const header = (
<div>
<h4 style={{ display: 'inline-block' }}>{ company }</h4>
<h5
className='pull-right hidden-xs hidden-md'
style={{ display: 'inline-block' }}>
{ position }
</h5>
</div>
);
2015-07-25 21:32:18 -07:00
return (
2015-09-07 23:52:21 -07:00
<Panel
2015-09-14 12:12:31 -07:00
bsStyle={ isHighlighted ? 'warning' : 'default' }
2015-09-07 23:52:21 -07:00
collapsible={ true }
eventKey={ index }
header={ header }
key={ id }>
<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 onClick={ () => handleClick(id) }>{ description }</p>
</Well>
2015-09-07 23:52:21 -07:00
</Panel>
2015-07-25 21:32:18 -07:00
);
2015-09-07 23:52:21 -07:00
});
},
render() {
const {
handleClick,
jobs
} = this.props;
2015-09-07 23:52:21 -07:00
return (
<PanelGroup>
{ this.renderJobs(handleClick, jobs) }
2015-09-07 23:52:21 -07:00
</PanelGroup>
);
}
});