summaryrefslogtreecommitdiffstats
path: root/frontend/components/TakeMyMoney.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-05-24 15:19:21 -0400
committerWes Bos <wesbos@gmail.com>2018-05-24 15:19:21 -0400
commit072eca0e5038a7755ca9b2c94dfe1a0c3f110968 (patch)
treea6c54e1503baf665ad0eeaeaad6d2a2b7ba3ba39 /frontend/components/TakeMyMoney.js
parentb294a6fa500b165aae86afbad5fce49a02314b0d (diff)
colocate queries and components
Diffstat (limited to 'frontend/components/TakeMyMoney.js')
-rw-r--r--frontend/components/TakeMyMoney.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/frontend/components/TakeMyMoney.js b/frontend/components/TakeMyMoney.js
index 5823d00..b9e42ea 100644
--- a/frontend/components/TakeMyMoney.js
+++ b/frontend/components/TakeMyMoney.js
@@ -4,9 +4,24 @@ import { Mutation, Query } from 'react-apollo';
import Router from 'next/router';
import NProgress from 'nprogress';
import PropTypes from 'prop-types';
-import { CREATE_ORDER_MUTATION, CURRENT_USER_QUERY } from '../queries/queries.graphql';
+import gql from 'graphql-tag';
import calcTotalPrice from '../lib/calcTotalPrice';
import Error from './ErrorMessage';
+import User, { CURRENT_USER_QUERY } from './User';
+
+const CREATE_ORDER_MUTATION = gql`
+ mutation createOrder($token: String!) {
+ createOrder(token: $token) {
+ id
+ charge
+ total
+ items {
+ id
+ title
+ }
+ }
+ }
+`;
function totalItems(cart) {
return cart.reduce((tally, cartItem) => tally + cartItem.quantity, 0);
@@ -30,7 +45,7 @@ class TakeMyMoney extends Component {
};
render() {
return (
- <Query query={CURRENT_USER_QUERY}>
+ <User>
{({ data: { me }, error }) => {
if (!me || !me.cart.length) return null;
if (error) return <Error error={error} />;
@@ -56,7 +71,7 @@ class TakeMyMoney extends Component {
</Mutation>
);
}}
- </Query>
+ </User>
);
}
}