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

42 lines
1.3 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-07 22:26:07 +01:00
// new
requestName : show.assetRequest.name,
requestModifier : show.assetRequest.modifier,
requestExtension: show.assetRequest.extension,
assetRequests : show.assetRequests,
assets : show.assets,
2018-02-07 22:26:07 +01:00
// old
error : show.showAsset.error,
name : show.showAsset.name,
claimData : show.showAsset.claimData,
};
};
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);