summaryrefslogtreecommitdiffstats
path: root/frontend/components/TakeMyMoney.js
diff options
context:
space:
mode:
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>
);
}
}