2018-02-02 04:36:08 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import View from './view';
|
2018-02-08 03:01:51 +01:00
|
|
|
import { newAssetRequest, updateRequestError, showNewAsset, updateShowAsset, clearShowAsset } from 'actions/show';
|
2018-02-02 04:36:08 +01:00
|
|
|
|
|
|
|
const mapStateToProps = ({ show }) => {
|
|
|
|
return {
|
2018-02-08 08:02:57 +01:00
|
|
|
// request
|
2018-02-08 05:15:44 +01:00
|
|
|
requestId : show.request.id,
|
|
|
|
requestName : show.request.data.name,
|
|
|
|
requestModifier : show.request.data.modifier,
|
|
|
|
requestExtension: show.request.data.extension,
|
2018-02-08 03:01:51 +01:00
|
|
|
assetRequests : show.assetRequests,
|
|
|
|
assets : show.assets,
|
2018-02-08 08:02:57 +01:00
|
|
|
// show asset
|
2018-02-08 03:01:51 +01:00
|
|
|
error : show.showAsset.error,
|
|
|
|
name : show.showAsset.name,
|
|
|
|
claimData : show.showAsset.claimData,
|
2018-02-08 08:02:57 +01:00
|
|
|
// test
|
2018-02-08 05:15:44 +01:00
|
|
|
showAsset : show.assets[show.request.id],
|
2018-02-02 04:36:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-02-03 03:16:18 +01:00
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
2018-02-07 22:26:07 +01:00
|
|
|
// new
|
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-08 03:01:51 +01:00
|
|
|
onRequestError: (error) => {
|
|
|
|
dispatch(updateRequestError(error, null, null));
|
|
|
|
},
|
|
|
|
onShowNewAsset: (id, name, claimId) => {
|
|
|
|
dispatch(showNewAsset(id, name, claimId));
|
2018-02-07 19:52:09 +01:00
|
|
|
},
|
2018-02-08 03:01:51 +01:00
|
|
|
onShowExistingAsset: (id, error, name, claimId, shortId, claimData) => {
|
|
|
|
dispatch(updateShowAsset(id, error, name, claimId, shortId, claimData));
|
2018-02-03 03:16:18 +01:00
|
|
|
},
|
2018-02-08 03:01:51 +01:00
|
|
|
onLeaveShowAsset: () => {
|
|
|
|
dispatch(clearShowAsset()); // clear any errors
|
2018-02-03 03:16:18 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(View);
|