spee.ch/react/containers/ShowAsset/index.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import View from './view';
import { newAssetRequest, updateRequestError, showNewAsset, updateShowAsset, clearShowAsset } from 'actions/show';
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,
assetRequests : show.assetRequests,
assets : show.assets,
2018-02-08 08:02:57 +01:00
// show asset
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-03 03:16:18 +01:00
const mapDispatchToProps = dispatch => {
return {
2018-02-07 22:26:07 +01:00
// new
onNewRequest: (id, name, modifier) => {
dispatch(newAssetRequest(id, name, modifier));
2018-02-07 22:26:07 +01:00
},
onRequestError: (error) => {
dispatch(updateRequestError(error, null, null));
},
onShowNewAsset: (id, name, claimId) => {
dispatch(showNewAsset(id, name, claimId));
},
onShowExistingAsset: (id, error, name, claimId, shortId, claimData) => {
dispatch(updateShowAsset(id, error, name, claimId, shortId, claimData));
2018-02-03 03:16:18 +01:00
},
onLeaveShowAsset: () => {
dispatch(clearShowAsset()); // clear any errors
2018-02-03 03:16:18 +01:00
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(View);