blob: c80baa61579e83972593457f8b6a91611d165097 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { Component } from 'react';
import { compose } from 'react-apollo';
import { uiEnhancer, updateUIEnhancer } from '../enhancers/enhancers';
import PropTypes from 'prop-types';
class ToggleCart extends Component {
static propTypes = {
render: PropTypes.func.isRequired,
toggleCart: PropTypes.func.isRequired,
ui: PropTypes.object.isRequired,
};
toggle = e => {
// if this is a keyPress event, make sure it's the enter key
if (e.keyCode && e.keyCode !== 16) return;
this.props.toggleCart(!this.props.ui.uiData.isCartOpen);
};
render() {
return this.props.render(this.toggle);
}
}
export default compose(uiEnhancer, updateUIEnhancer)(ToggleCart);
|