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
};
createJobClickHandler(id) {
const { findJob, push } = this.props;
if (!id) {
return null;
}
createJobClickHandler() {
const { findJob } = this.props;
return id => {
return (id) => {
findJob(id);
push(`/jobs/${id}`);
};
}

View File

@ -1,5 +1,6 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { LinkContainer } from 'react-router-bootstrap';
import { ListGroup, ListGroupItem } from 'react-bootstrap';
import PureComponent from 'react-pure-render/component';
@ -41,10 +42,14 @@ export default class ListJobs extends PureComponent {
'jobs-list-highlight': isHighlighted
});
const to = `/jobs/${id}`;
return (
<LinkContainer
key={ id }
to={ to }>
<ListGroupItem
className={ className }
key={ id }
onClick={ () => handleClick(id) }>
<div>
<h4 className='pull-left' style={{ display: 'inline-block' }}>
@ -61,6 +66,7 @@ export default class ListJobs extends PureComponent {
</h4>
</div>
</ListGroupItem>
</LinkContainer>
);
});
}

View File

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