Fix job routing

This commit is contained in:
Berkeley Martinez
2016-02-28 17:25:21 -08:00
parent 5c76978377
commit f6c1260336
3 changed files with 33 additions and 30 deletions

View File

@ -48,15 +48,11 @@ export class Jobs extends PureComponent {
showModal: PropTypes.bool showModal: PropTypes.bool
}; };
createJobClickHandler(id) { createJobClickHandler() {
const { findJob, push } = this.props; const { findJob } = this.props;
if (!id) {
return null;
}
return id => { return (id) => {
findJob(id); findJob(id);
push(`/jobs/${id}`);
}; };
} }

View File

@ -1,5 +1,6 @@
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
import { LinkContainer } from 'react-router-bootstrap';
import { ListGroup, ListGroupItem } from 'react-bootstrap'; import { ListGroup, ListGroupItem } from 'react-bootstrap';
import PureComponent from 'react-pure-render/component'; import PureComponent from 'react-pure-render/component';
@ -41,26 +42,31 @@ export default class ListJobs extends PureComponent {
'jobs-list-highlight': isHighlighted 'jobs-list-highlight': isHighlighted
}); });
const to = `/jobs/${id}`;
return ( return (
<ListGroupItem <LinkContainer
className={ className }
key={ id } key={ id }
onClick={ () => handleClick(id) }> to={ to }>
<div> <ListGroupItem
<h4 className='pull-left' style={{ display: 'inline-block' }}> className={ className }
<bold>{ company }</bold> onClick={ () => handleClick(id) }>
{' '} <div>
<span className='hidden-xs hidden-sm'> <h4 className='pull-left' style={{ display: 'inline-block' }}>
- { position } <bold>{ company }</bold>
</span> {' '}
</h4> <span className='hidden-xs hidden-sm'>
<h4 - { position }
className='pull-right' </span>
style={{ display: 'inline-block' }}> </h4>
{ this.addLocation(locale) } <h4
</h4> className='pull-right'
</div> style={{ display: 'inline-block' }}>
</ListGroupItem> { this.addLocation(locale) }
</h4>
</div>
</ListGroupItem>
</LinkContainer>
); );
}); });
} }

View File

@ -6,7 +6,7 @@ import PureComponent from 'react-pure-render/component';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import contain from '../../../utils/professor-x'; import contain from '../../../utils/professor-x';
import { fetchJob } from '../redux/actions'; import { fetchJobs } from '../redux/actions';
import ShowJob from './ShowJob.jsx'; import ShowJob from './ShowJob.jsx';
import JobNotFound from './JobNotFound.jsx'; import JobNotFound from './JobNotFound.jsx';
@ -60,21 +60,22 @@ function generateMessage(
const mapStateToProps = createSelector( const mapStateToProps = createSelector(
state => state.app, state => state.app,
state => state.jobsApp.currentJob, state => state.jobsApp.currentJob,
({ username, isFrontEndCert, isBackEndCert }, job = {}) => ({ state => state.jobsApp.jobs.entities,
({ username, isFrontEndCert, isBackEndCert }, currentJob, jobs) => ({
username, username,
isFrontEndCert, isFrontEndCert,
isBackEndCert, isBackEndCert,
job job: jobs[currentJob] || {}
}) })
); );
const bindableActions = { const bindableActions = {
push, push,
fetchJob fetchJobs
}; };
const fetchOptions = { const fetchOptions = {
fetchAction: 'fetchJob', fetchAction: 'fetchJobs',
getActionArgs({ params: { id } }) { getActionArgs({ params: { id } }) {
return [ id ]; return [ id ];
}, },