2018-02-02 04:36:08 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import View from './view';
|
2018-02-13 03:18:56 +01:00
|
|
|
import { newAssetRequest, showNewAsset } from 'actions/show';
|
2018-02-02 04:36:08 +01:00
|
|
|
|
|
|
|
const mapStateToProps = ({ show }) => {
|
2018-02-13 03:18:56 +01:00
|
|
|
let props = {};
|
|
|
|
props['requestType'] = show.request.type;
|
|
|
|
props['requestId'] = show.request.id;
|
|
|
|
props['requestName'] = show.request.data.name;
|
|
|
|
props['requestModifier'] = show.request.data.modifier;
|
|
|
|
props['requestExtension'] = show.request.data.extension;
|
|
|
|
// select request
|
|
|
|
const existingRequest = show.assetRequests[show.request.id];
|
|
|
|
if (existingRequest) {
|
|
|
|
props['existingRequest'] = existingRequest;
|
|
|
|
// select asset info
|
|
|
|
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; // note: just store this in the request
|
|
|
|
const existingAsset = show.assetList[assetKey];
|
|
|
|
if (existingAsset) {
|
|
|
|
console.log('existing asset found', existingAsset);
|
|
|
|
props['asset'] = existingAsset;
|
|
|
|
};
|
2018-02-02 04:36:08 +01:00
|
|
|
};
|
2018-02-13 03:18:56 +01:00
|
|
|
return props;
|
2018-02-02 04:36:08 +01:00
|
|
|
};
|
|
|
|
|
2018-02-03 03:16:18 +01:00
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
2018-02-09 01:23:09 +01:00
|
|
|
// request
|
2018-02-08 03:01:51 +01:00
|
|
|
onNewRequest: (id, name, modifier) => {
|
|
|
|
dispatch(newAssetRequest(id, name, modifier));
|
2018-02-07 22:26:07 +01:00
|
|
|
},
|
2018-02-09 01:23:09 +01:00
|
|
|
// show asset
|
2018-02-08 23:01:45 +01:00
|
|
|
onShowNewAsset: (name, claimId) => {
|
|
|
|
dispatch(showNewAsset(name, claimId));
|
2018-02-07 19:52:09 +01:00
|
|
|
},
|
2018-02-03 03:16:18 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(View);
|