-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.jsx
53 lines (48 loc) · 1.47 KB
/
index.jsx
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import PropTypes from 'prop-types';
import AddToCartButton from '@shopgate/pwa-ui-shared/AddToCartButton';
import { withForwardedRef } from '@shopgate/engage/core';
import styles from './style';
/**
* The AddMoreButton component.
* @param {Function} handleAddToCart The addToCart handler.
* @param {Object} context The component context.
* @param {boolean} disabled Should the button shown as disabled.
* @param {boolean} loading Should the button shown as loading.
* @param {boolean} visible Should the button be visible.
* @param {Function} onReset The reset handler.
* @return {JSX}
*/
const AddMoreButton = ({
handleAddToCart, disabled, loading, onReset, visible, forwardedRef,
}, context) => {
const { __ } = context.i18n();
return (
<AddToCartButton
onClick={handleAddToCart}
onReset={onReset}
isDisabled={disabled}
isLoading={loading}
className={styles.container}
aria-hidden={!visible}
aria-label={__('product.add_to_cart')}
ref={forwardedRef}
/>
);
};
AddMoreButton.propTypes = {
disabled: PropTypes.bool.isRequired,
handleAddToCart: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
visible: PropTypes.bool.isRequired,
forwardedRef: PropTypes.shape(),
onReset: PropTypes.func,
};
AddMoreButton.defaultProps = {
onReset: () => {},
forwardedRef: null,
};
AddMoreButton.contextTypes = {
i18n: PropTypes.func,
};
export default withForwardedRef(AddMoreButton);