2018-02-07 19:52:09 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import View from './view';
|
2018-01-30 18:00:02 +01:00
|
|
|
|
2018-02-07 19:52:09 +01:00
|
|
|
const mapStateToProps = ({ show }) => {
|
2018-02-14 20:39:24 +01:00
|
|
|
console.log('mapping state to props', show);
|
|
|
|
// select request info
|
|
|
|
const requestId = show.request.id;
|
|
|
|
// select asset info
|
|
|
|
let asset;
|
2018-02-14 21:09:57 +01:00
|
|
|
const request = show.previousRequests[requestId] || null;
|
2018-02-14 20:39:24 +01:00
|
|
|
const assetList = show.assetList;
|
2018-02-14 21:09:57 +01:00
|
|
|
if (request && assetList) {
|
|
|
|
const assetKey = request.key; // note: just store this in the request
|
2018-02-14 20:39:24 +01:00
|
|
|
asset = assetList[assetKey] || null;
|
2018-02-13 05:01:02 +01:00
|
|
|
};
|
|
|
|
// return props
|
|
|
|
return {
|
2018-02-14 20:39:24 +01:00
|
|
|
asset,
|
2018-02-07 19:52:09 +01:00
|
|
|
};
|
2018-01-30 18:00:02 +01:00
|
|
|
};
|
|
|
|
|
2018-02-07 19:52:09 +01:00
|
|
|
export default connect(mapStateToProps, null)(View);
|