-
Notifications
You must be signed in to change notification settings - Fork 58
/
checkout-item.container.jsx
43 lines (37 loc) · 1.12 KB
/
checkout-item.container.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
import React from 'react';
import { compose, graphql } from 'react-apollo';
import { gql } from 'apollo-boost';
import CheckoutItem from './checkout-item.component';
const ADD_ITEM_TO_CART = gql`
mutation AddItemToCart($item: Item!) {
addItemToCart(item: $item) @client
}
`;
const REMOVE_ITEM_FROM_CART = gql`
mutation RemoveItemFromCart($item: Item!) {
removeItemFromCart(item: $item) @client
}
`;
const CLEAR_ITEM_FROM_CART = gql`
mutation ClearItemFromCart($item: Item!) {
clearItemFromCart(item: $item) @client
}
`;
const CollectionItemContainer = ({
addItemToCart,
removeItemFromCart,
clearItemFromCart,
...otherProps
}) => (
<CheckoutItem
{...otherProps}
addItem={item => addItemToCart({ variables: { item } })}
removeItem={item => removeItemFromCart({ variables: { item } })}
clearItem={item => clearItemFromCart({ variables: { item } })}
/>
);
export default compose(
graphql(ADD_ITEM_TO_CART, { name: 'addItemToCart' }),
graphql(REMOVE_ITEM_FROM_CART, { name: 'removeItemFromCart' }),
graphql(CLEAR_ITEM_FROM_CART, { name: 'clearItemFromCart' })
)(CollectionItemContainer);