2018-02-02 04:36:08 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import View from './view';
|
2018-02-14 18:19:22 +01:00
|
|
|
import { onNewAssetRequest } from 'actions/show';
|
2018-02-02 04:36:08 +01:00
|
|
|
|
|
|
|
const mapStateToProps = ({ show }) => {
|
2018-02-13 04:01:29 +01:00
|
|
|
// select request info
|
|
|
|
const requestId = show.request.id;
|
|
|
|
const requestName = show.request.data.name;
|
|
|
|
const requestModifier = show.request.data.modifier;
|
|
|
|
const requestExtension = show.request.data.extension;
|
2018-02-14 00:53:27 +01:00
|
|
|
const assetList = show.assetList;
|
2018-02-13 04:08:17 +01:00
|
|
|
// select asset info
|
2018-02-14 00:53:27 +01:00
|
|
|
const previousRequest = show.assetRequests[show.request.id] || null;
|
2018-02-13 04:01:29 +01:00
|
|
|
let asset;
|
|
|
|
if (previousRequest) {
|
|
|
|
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; // note: just store this in the request
|
2018-02-14 00:53:27 +01:00
|
|
|
asset = assetList[assetKey] || null;
|
2018-02-13 04:01:29 +01:00
|
|
|
};
|
|
|
|
// return props
|
|
|
|
return {
|
|
|
|
requestId,
|
|
|
|
requestName,
|
|
|
|
requestModifier,
|
|
|
|
requestExtension,
|
|
|
|
asset,
|
2018-02-02 04:36:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-02-14 18:19:22 +01:00
|
|
|
const mapDispatchToProps = () => {
|
2018-02-03 03:16:18 +01:00
|
|
|
return {
|
2018-02-14 18:19:22 +01:00
|
|
|
onNewAssetRequest,
|
2018-02-03 03:16:18 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(View);
|