2018-01-30 09:00:02 -08:00
|
|
|
import React from 'react';
|
2018-03-16 13:03:54 -07:00
|
|
|
import ErrorPage from 'pages/ErrorPage';
|
2018-03-07 20:31:10 -08:00
|
|
|
import ShowAssetLite from 'containers/ShowAssetLite';
|
|
|
|
import ShowAssetDetails from 'containers/ShowAssetDetails';
|
|
|
|
import ShowChannel from 'containers/ShowChannel';
|
2018-01-30 09:00:02 -08:00
|
|
|
|
2018-02-14 11:39:24 -08:00
|
|
|
import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from 'constants/show_request_types';
|
2018-02-02 11:10:58 -08:00
|
|
|
|
2018-01-30 09:00:02 -08:00
|
|
|
class ShowPage extends React.Component {
|
|
|
|
componentDidMount () {
|
2018-02-22 15:43:26 -08:00
|
|
|
this.props.onHandleShowPageUri(this.props.match.params);
|
2018-01-31 14:50:35 -08:00
|
|
|
}
|
|
|
|
componentWillReceiveProps (nextProps) {
|
2018-02-02 16:49:39 -08:00
|
|
|
if (nextProps.match.params !== this.props.match.params) {
|
2018-02-22 15:43:26 -08:00
|
|
|
this.props.onHandleShowPageUri(nextProps.match.params);
|
2018-01-30 09:00:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
render () {
|
2018-02-07 11:30:39 -08:00
|
|
|
const { error, requestType } = this.props;
|
|
|
|
if (error) {
|
2018-01-31 19:12:54 -08:00
|
|
|
return (
|
2018-02-22 15:43:26 -08:00
|
|
|
<ErrorPage error={error} />
|
2018-01-31 19:12:54 -08:00
|
|
|
);
|
|
|
|
}
|
2018-02-07 11:30:39 -08:00
|
|
|
switch (requestType) {
|
2018-02-02 11:10:58 -08:00
|
|
|
case CHANNEL:
|
2018-02-02 18:16:18 -08:00
|
|
|
return <ShowChannel />;
|
2018-02-14 11:39:24 -08:00
|
|
|
case ASSET_LITE:
|
|
|
|
return <ShowAssetLite />;
|
|
|
|
case ASSET_DETAILS:
|
|
|
|
return <ShowAssetDetails />;
|
2018-02-02 11:10:58 -08:00
|
|
|
default:
|
|
|
|
return <p>loading...</p>;
|
2018-01-30 09:00:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ShowPage;
|