From 072eca0e5038a7755ca9b2c94dfe1a0c3f110968 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 24 May 2018 15:19:21 -0400 Subject: colocate queries and components --- frontend/components/TakeMyMoney.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'frontend/components/TakeMyMoney.js') 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 ( - + {({ data: { me }, error }) => { if (!me || !me.cart.length) return null; if (error) return ; @@ -56,7 +71,7 @@ class TakeMyMoney extends Component { ); }} - + ); } } -- cgit v1.3