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

81 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-07-25 21:32:18 -07:00
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { ListGroup, ListGroupItem } from 'react-bootstrap';
2016-02-05 20:48:59 -08:00
import PureComponent from 'react-pure-render/component';
2015-07-25 21:32:18 -07:00
2016-02-05 20:48:59 -08:00
export default class ListJobs extends PureComponent {
static displayName = 'ListJobs';
2015-07-25 21:32:18 -07:00
2016-02-05 20:48:59 -08:00
static propTypes = {
handleClick: PropTypes.func,
2015-09-07 23:52:21 -07:00
jobs: PropTypes.array
2016-02-05 20:48:59 -08:00
};
2015-07-25 21:32:18 -07:00
2015-10-16 20:05:22 -07:00
addLocation(locale) {
if (!locale) {
return null;
}
return (
<span className='hidden-xs hidden-sm'>
2015-11-30 19:04:05 -08:00
{ locale }
2015-10-16 20:05:22 -07:00
</span>
);
2016-02-05 20:48:59 -08:00
}
2015-10-16 20:05:22 -07:00
renderJobs(handleClick, jobs = []) {
return jobs
2016-02-05 20:48:59 -08:00
.filter(({ isPaid, isApproved, isFilled }) => {
return isPaid && isApproved && !isFilled;
})
.map(({
id,
company,
position,
isHighlighted,
locale
}) => {
2016-02-05 20:48:59 -08:00
const className = classnames({
'jobs-list': true,
'col-xs-12': true,
'jobs-list-highlight': isHighlighted
});
2016-02-05 20:48:59 -08:00
return (
<ListGroupItem
className={ className }
key={ id }
onClick={ () => handleClick(id) }>
<div>
<h4 className='pull-left' style={{ display: 'inline-block' }}>
<bold>{ company }</bold>
{' '}
<span className='hidden-xs hidden-sm'>
- { position }
</span>
</h4>
<h4
className='pull-right'
style={{ display: 'inline-block' }}>
{ this.addLocation(locale) }
</h4>
</div>
</ListGroupItem>
);
});
}
2015-09-07 23:52:21 -07:00
render() {
const {
handleClick,
jobs
} = this.props;
2015-09-07 23:52:21 -07:00
return (
<ListGroup>
{ this.renderJobs(handleClick, jobs) }
</ListGroup>
2015-09-07 23:52:21 -07:00
);
}
2016-02-05 20:48:59 -08:00
}