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

43 lines
1.2 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,
2018-02-08 20:50:30 +01:00
assetList : show.assetList,
2018-02-08 08:02:57 +01:00
// show asset
error : show.showAsset.error,
2018-02-09 01:23:09 +01:00
id : show.showAsset.id,
};
};
2018-02-03 03:16:18 +01:00
const mapDispatchToProps = dispatch => {
return {
2018-02-09 01:23:09 +01:00
// request
onNewRequest: (id, name, modifier) => {
dispatch(newAssetRequest(id, name, modifier));
2018-02-07 22:26:07 +01:00
},
onRequestError: (error) => {
dispatch(updateRequestError(error, null, null));
},
2018-02-09 01:23:09 +01:00
// show asset
onShowNewAsset: (name, claimId) => {
dispatch(showNewAsset(name, claimId));
},
2018-02-09 01:23:09 +01:00
onShowExistingAsset: (assetId) => {
dispatch(updateShowAsset(null, assetId));
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);