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,10 +42,14 @@ export default class ListJobs extends PureComponent {
'jobs-list-highlight': isHighlighted 'jobs-list-highlight': isHighlighted
}); });
const to = `/jobs/${id}`;
return ( return (
<LinkContainer
key={ id }
to={ to }>
<ListGroupItem <ListGroupItem
className={ className } className={ className }
key={ id }
onClick={ () => handleClick(id) }> onClick={ () => handleClick(id) }>
<div> <div>
<h4 className='pull-left' style={{ display: 'inline-block' }}> <h4 className='pull-left' style={{ display: 'inline-block' }}>
@ -61,6 +66,7 @@ export default class ListJobs extends PureComponent {
</h4> </h4>
</div> </div>
</ListGroupItem> </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 ];
}, },