2018-01-31 02:15:23 +01:00
|
|
|
import React from 'react';
|
2018-02-07 20:30:39 +01:00
|
|
|
import ErrorPage from 'components/ErrorPage';
|
2018-02-02 20:10:58 +01:00
|
|
|
import ShowAssetLite from 'components/ShowAssetLite';
|
|
|
|
import ShowAssetDetails from 'components/ShowAssetDetails';
|
2018-01-31 02:15:23 +01:00
|
|
|
import request from 'utils/request';
|
|
|
|
|
2018-02-07 22:26:07 +01:00
|
|
|
function buildIdFromModifierObject (modifier) {
|
|
|
|
if (modifier) {
|
|
|
|
if (modifier.channel.name) {
|
|
|
|
return `${modifier.channel.name}#${modifier.channel.id}`;
|
|
|
|
}
|
|
|
|
return modifier.id;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2018-01-31 02:15:23 +01:00
|
|
|
class ShowAsset extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
this.getLongClaimId = this.getLongClaimId.bind(this);
|
|
|
|
this.getClaimData = this.getClaimData.bind(this);
|
|
|
|
}
|
|
|
|
componentDidMount () {
|
2018-02-07 22:26:07 +01:00
|
|
|
const { request: { name, modifier }, assetRequests } = this.props;
|
|
|
|
const id = buildIdFromModifierObject(modifier);
|
|
|
|
// check to see if we have this asset
|
|
|
|
if (assetRequests[id]) {
|
|
|
|
// case: the assetRequest exists
|
|
|
|
this.props.onNewAssetRequest(id, name, modifier); // request the long id and update the store with a new asset request record.
|
|
|
|
} else {
|
|
|
|
// case: the asset request does not exist
|
|
|
|
this.onRepeatAssetRequest(name, modifier); // get the asset request record...?
|
2018-01-31 02:15:23 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-07 22:26:07 +01:00
|
|
|
onRepeatAssetRequest (id, modifier, assetRequests) {
|
|
|
|
// get the results of the existing asset request
|
|
|
|
const {error, claimId} = assetRequests[id];
|
|
|
|
console.log(`results form past request ${id}:`, error, claimId);
|
2018-01-31 02:15:23 +01:00
|
|
|
}
|
2018-02-05 01:40:28 +01:00
|
|
|
componentWillUnmount () {
|
|
|
|
this.props.onAssetClaimDataClear();
|
|
|
|
}
|
2018-01-31 02:15:23 +01:00
|
|
|
render () {
|
2018-02-07 19:52:09 +01:00
|
|
|
const { error, claimData, extension } = this.props;
|
|
|
|
if (error) {
|
|
|
|
return (
|
2018-02-07 20:30:39 +01:00
|
|
|
<ErrorPage error={error}/>
|
2018-02-07 19:52:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (claimData) {
|
|
|
|
if (extension) {
|
2018-02-05 02:51:17 +01:00
|
|
|
return (
|
2018-02-07 19:52:09 +01:00
|
|
|
<ShowAssetLite />
|
2018-02-05 02:51:17 +01:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
2018-02-07 19:52:09 +01:00
|
|
|
<ShowAssetDetails />
|
2018-02-05 02:51:17 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
2018-01-31 02:15:23 +01:00
|
|
|
return (
|
2018-02-07 19:52:09 +01:00
|
|
|
<div> </div>
|
2018-01-31 02:15:23 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ShowAsset;
|