Add redirects
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import React, { createClass } from 'react';
|
||||
import { History } from 'react-router';
|
||||
import { contain } from 'thundercats-react';
|
||||
|
||||
import ShowJob from './ShowJob.jsx';
|
||||
import JobNotFound from './JobNotFound.jsx';
|
||||
import { isJobValid } from '../utils';
|
||||
|
||||
export default contain(
|
||||
{
|
||||
@@ -20,5 +25,26 @@ export default contain(
|
||||
return job.id !== id;
|
||||
}
|
||||
},
|
||||
ShowJob
|
||||
createClass({
|
||||
displayName: 'Show',
|
||||
|
||||
mixins: [History],
|
||||
|
||||
componentDidMount() {
|
||||
const { job } = this.props;
|
||||
// redirect user in client
|
||||
if (!isJobValid(job)) {
|
||||
this.history.pushState(null, '/jobs');
|
||||
}
|
||||
},
|
||||
|
||||
render() {
|
||||
const { job } = this.props;
|
||||
|
||||
if (!isJobValid(job)) {
|
||||
return <JobNotFound />;
|
||||
}
|
||||
return <ShowJob { ...this.props }/>;
|
||||
}
|
||||
})
|
||||
);
|
||||
|
Reference in New Issue
Block a user