spee.ch/react/containers/ShowAsset/view.jsx

43 lines
1.2 KiB
React
Raw Normal View History

import React from 'react';
import ErrorPage from 'components/ErrorPage';
import ShowAssetLite from 'components/ShowAssetLite';
import ShowAssetDetails from 'components/ShowAssetDetails';
2018-02-08 08:18:18 +01:00
import { ASSET } from 'constants/show_request_types';
function requestIsAnAssetRequest ({ requestType }) {
return requestType === ASSET;
}
class ShowAsset extends React.Component {
componentDidMount () {
2018-02-14 00:53:27 +01:00
const { asset, requestId, requestName, requestModifier } = this.props;
if (!asset) { // case: the asset info does not exist
return this.props.onNewRequest(requestId, requestName, requestModifier);
};
}
componentWillReceiveProps (nextProps) {
if (requestIsAnAssetRequest(nextProps)) {
2018-02-14 00:53:27 +01:00
const { asset, requestId, requestName, requestModifier } = nextProps;
if (!asset) { // case: the asset info does not exist
return this.props.onNewRequest(requestId, requestName, requestModifier);
};
}
}
render () {
const {asset, requestExtension} = this.props;
if (asset) {
if (requestExtension) {
return <ShowAssetLite/>;
2018-02-05 02:51:17 +01:00
}
return <ShowAssetDetails/>;
}
;
return (
<ErrorPage error={'loading asset data...'}/>
);
}
};
export default ShowAsset;