1 | import get from 'lodash.get';
|
2 | import { useQuery } from '@apollo/react-hooks';
|
3 | import throwErrorInDev from '../helpers/throwErrorInDev';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export default function useCustomerOrdersQuery({ query, variables }) {
|
9 | const result = useQuery(query, { variables });
|
10 | throwErrorInDev(!result.loading && !get(result, 'data.customer.orderHeaders'), 'Double-check that your query includes `{ customer { orderHeaders } }`');
|
11 | const orders = get(result, 'data.customer.orderHeaders.result', []);
|
12 | const totalOrders = get(result, 'data.customer.orderHeaders.totalResults');
|
13 | return {
|
14 | // Default loading to true for SSR
|
15 | loading: result ? result.loading : true,
|
16 | orders,
|
17 | result,
|
18 | totalOrders
|
19 | };
|
20 | }
|
21 | //# sourceMappingURL=useCustomerOrdersQuery.js.map |
\ | No newline at end of file |