-
Notifications
You must be signed in to change notification settings - Fork 7
/
connector.js
29 lines (26 loc) · 1014 Bytes
/
connector.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import addCurrentProductToCart from '@shopgate/pwa-common-commerce/cart/actions/addCurrentProductToCart';
import {
isProductPageLoading,
isProductPageOrderable,
} from '@shopgate/pwa-common-commerce/product/selectors/page';
import { connect } from 'react-redux';
import { selectActionCount } from './selectors';
/**
* Connects the current application state to the component props.
* @param {Object} state The current application state.
* @return {[type]} [description]
*/
const mapStateToProps = state => ({
isLoading: isProductPageLoading(state),
isOrderable: isProductPageOrderable(state),
cartProductCount: selectActionCount(state),
});
/**
* Connects the dispatch function to a callable function in the props.
* @param {Function} dispatch The redux dispatch function.
* @return {Object} The extended component props.
*/
const mapDispatchToProps = dispatch => ({
handleAddToCart: () => dispatch(addCurrentProductToCart()),
});
export default connect(mapStateToProps, mapDispatchToProps);