-
Notifications
You must be signed in to change notification settings - Fork 7
/
connector.js
28 lines (25 loc) · 1.03 KB
/
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
import { connect } from 'react-redux';
import deleteProductsFromCart from '@shopgate/pwa-common-commerce/cart/actions/deleteProductsFromCart';
import updateProductsInCart from '@shopgate/pwa-common-commerce/cart/actions/updateProductsInCart';
import { getCurrency } from '@shopgate/pwa-common-commerce/cart/selectors';
/**
* Maps the contents of the state to the component props.
* @param {Object} state The current application state.
* @return {Object} The extended component props.
*/
const mapStateToProps = state => ({
currency: getCurrency(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 => ({
deleteProduct: cartItemId => dispatch(deleteProductsFromCart([cartItemId])),
updateProduct: (cartItemId, quantity) => dispatch(updateProductsInCart([{
cartItemId,
quantity,
}])),
});
export default connect(mapStateToProps, mapDispatchToProps);