generated from sysgears/apollo-universal-starter-kit
-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMyOrder.jsx
71 lines (58 loc) · 1.92 KB
/
MyOrder.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { withCurrentUser, withOrdersState, withFilterUpdating, withOrderStates, withOrders } from './OrderOperations';
import MyOrdersView from '../components/MyOrdersView';
import { subscribeToOrders } from './OrderSubscriptions';
const MyOrdersContainer = compose(withOrders)(props => {
const { ordersSubscribeToMore, refetch } = props;
// const listingsUpdated = SubscribeToOrdersForMyOrders(ordersSubscribeToMore, props.filter);
// useEffect(() => {
// if (listingsUpdated) {
// updateOrdersState(listingsUpdated, updateOrdersQuery);
// }
// });
useEffect(() => {
// setDidMount(true);
const subscribe = subscribeToOrders(ordersSubscribeToMore, props.filter);
// console.log(subscribe);
refetch();
// console.log(subscribe);
// () => ;
// setDidMount(false);
return () => subscribe();
}, [ordersSubscribeToMore, props.filter, refetch]);
// if (!didMount) {
// return null;
// }
// console.log('props', props);
return React.cloneElement(props.children, { ...props });
});
const MyOrders = props => {
const { currentUser, filter, currentUserLoading } = props;
// console.log('props', props);
return (
!currentUserLoading && (
<MyOrdersContainer filter={{ consumerId: currentUser && currentUser.id, ...filter }}>
<MyOrdersView {...props} />
</MyOrdersContainer>
)
);
};
MyOrders.propTypes = {
currentUserLoading: PropTypes.bool,
filter: PropTypes.object,
// updateQuery: PropTypes.func,
currentUser: PropTypes.object,
t: PropTypes.func
// ordersSubscribeToMore: PropTypes.func,
// filter: PropTypes.object
};
export default compose(
withCurrentUser,
withOrdersState,
withFilterUpdating,
withOrderStates,
translate('order')
)(MyOrders);