summaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/__tests__/TakeMyMoney.test.js12
-rw-r--r--frontend/__tests__/__snapshots__/Nav.test.js.snap4
-rw-r--r--frontend/__tests__/__snapshots__/Order.test.js.snap2
-rw-r--r--frontend/components/TakeMyMoney.js2
-rw-r--r--frontend/queries/queries.graphql377
5 files changed, 177 insertions, 220 deletions
diff --git a/frontend/__tests__/TakeMyMoney.test.js b/frontend/__tests__/TakeMyMoney.test.js
index b17de17..f2d0ca7 100644
--- a/frontend/__tests__/TakeMyMoney.test.js
+++ b/frontend/__tests__/TakeMyMoney.test.js
@@ -40,7 +40,9 @@ describe('<TakeMyMoney />', () => {
});
it('creates an order onToken', async () => {
- const createOrderSpy = jest.fn().mockResolvedValue({ data: { createOrder: { id: 'xyz789' } } });
+ const createOrderSpy = jest
+ .fn()
+ .mockResolvedValue({ data: { CREATE_ORDER_MUTATION: { id: 'xyz789' } } });
const wrapper = mount(
<MockedProvider mocks={mocks}>
@@ -64,7 +66,9 @@ describe('<TakeMyMoney />', () => {
wrapper.update();
NProgress.start = jest.fn();
- const createOrderSpy = jest.fn().mockResolvedValue({ data: { createOrder: { id: 'xyz789' } } });
+ const createOrderSpy = jest
+ .fn()
+ .mockResolvedValue({ data: { CREATE_ORDER_MUTATION: { id: 'xyz789' } } });
const component = wrapper.find('TakeMyMoney');
component.instance().onToken({ id: 'abc123' }, createOrderSpy);
wrapper.find('button').simulate('click');
@@ -83,7 +87,9 @@ describe('<TakeMyMoney />', () => {
// Spy on Router Push
Router.router.push = jest.fn();
- const createOrderSpy = jest.fn().mockResolvedValue({ data: { createOrder: { id: 'xyz789' } } });
+ const createOrderSpy = jest
+ .fn()
+ .mockResolvedValue({ data: { CREATE_ORDER_MUTATION: { id: 'xyz789' } } });
const component = wrapper.find('TakeMyMoney');
component.instance().onToken({ id: 'abc123' }, createOrderSpy);
diff --git a/frontend/__tests__/__snapshots__/Nav.test.js.snap b/frontend/__tests__/__snapshots__/Nav.test.js.snap
index f084308..8ac3ae4 100644
--- a/frontend/__tests__/__snapshots__/Nav.test.js.snap
+++ b/frontend/__tests__/__snapshots__/Nav.test.js.snap
@@ -16,10 +16,10 @@ exports[`<Nav></Nav> Renders minimal nav when logged out 1`] = `
</a>
</Link>
<Link
- href="/add"
+ href="/sell"
>
<a
- href="/add"
+ href="/sell"
onClick={[Function]}
>
Sell
diff --git a/frontend/__tests__/__snapshots__/Order.test.js.snap b/frontend/__tests__/__snapshots__/Order.test.js.snap
index cfdd4f6..8e76546 100644
--- a/frontend/__tests__/__snapshots__/Order.test.js.snap
+++ b/frontend/__tests__/__snapshots__/Order.test.js.snap
@@ -29,7 +29,7 @@ exports[`<Order/> Renders the order 1`] = `
Date
</span>
<span>
- March 31, 2018 8:00 PM
+ March 90, 2018 8:00 A
</span>
</p>
<p>
diff --git a/frontend/components/TakeMyMoney.js b/frontend/components/TakeMyMoney.js
index 8efdb6b..4675cfe 100644
--- a/frontend/components/TakeMyMoney.js
+++ b/frontend/components/TakeMyMoney.js
@@ -21,7 +21,7 @@ class TakeMyMoney extends Component {
},
});
// Route them to that order page
- const { id } = order.data.createOrder;
+ const { id } = order.data.CREATE_ORDER_MUTATION;
Router.push({
pathname: `/order`,
query: { id },
diff --git a/frontend/queries/queries.graphql b/frontend/queries/queries.graphql
index d9a5588..61d5587 100644
--- a/frontend/queries/queries.graphql
+++ b/frontend/queries/queries.graphql
@@ -8,278 +8,229 @@ fragment itemDetails on Item {
largeImage
}
-# export const CREATE_ITEM_MUTATION = gql`
- # ${itemDetails}
- mutation CREATE_ITEM_MUTATION($description: String!, $title: String!, $price: Int!, $image: String, $largeImage: String) {
- createItem(description: $description, title: $title, price: $price, image: $image, largeImage: $largeImage) {
- ...itemDetails
- }
- }
-# `;
-
-# export const SIGNUP_MUTATION = gql`
- mutation SIGNUP_MUTATION($email: String!, $name: String!, $password: String!) {
- signup(email: $email, name: $name, password: $password) {
- token
- user {
- id
- email
- name
- }
- }
+mutation CREATE_ITEM_MUTATION($description: String!, $title: String!, $price: Int!, $image: String, $largeImage: String) {
+ createItem(description: $description, title: $title, price: $price, image: $image, largeImage: $largeImage) {
+ ...itemDetails
}
-# `;
+}
-# export const SIGNIN_MUTATION = gql`
- mutation SIGNIN_MUTATION($email: String!, $password: String!) {
- signin(email: $email, password: $password) {
- token
- user {
- id
- email
- name
- }
+mutation SIGNUP_MUTATION($email: String!, $name: String!, $password: String!) {
+ signup(email: $email, name: $name, password: $password) {
+ token
+ user {
+ id
+ email
+ name
}
}
-# `;
+}
-# export const REQUEST_RESET_MUTATION = gql`
- mutation REQUEST_RESET_MUTATION($email: String!) {
- requestReset(email: $email) {
+mutation SIGNIN_MUTATION($email: String!, $password: String!) {
+ signin(email: $email, password: $password) {
+ token
+ user {
id
+ email
+ name
}
}
-# `;
+}
-# export const RESET_MUTATION = gql`
- mutation RESET_MUTATION($resetToken: String!, $password: String!, $confirmPassword: String!) {
- resetPassword(resetToken: $resetToken, password: $password, confirmPassword: $confirmPassword) {
- token
- user {
- id
- email
- name
- }
- }
+mutation REQUEST_RESET_MUTATION($email: String!) {
+ requestReset(email: $email) {
+ id
}
-# `;
+}
-# export const CREATE_ORDER_MUTATION = gql`
- mutation CREATE_ORDER_MUTATION($token: String!) {
- createOrder(token: $token) {
+mutation RESET_MUTATION($resetToken: String!, $password: String!, $confirmPassword: String!) {
+ resetPassword(resetToken: $resetToken, password: $password, confirmPassword: $confirmPassword) {
+ token
+ user {
id
- charge
- total
- items {
- id
- title
- }
+ email
+ name
}
}
-# `;
+}
-# export const ALL_ITEMS_QUERY = gql`
- # Import the Fragment
- # ${itemDetails}
- query ALL_ITEMS_QUERY($skip: Int = 0, $first: Int = ${perPage}) {
- itemsConnection(orderBy: createdAt_DESC, first: $first, skip: $skip) {
- aggregate {
- count
- }
- }
- items(orderBy: createdAt_DESC, first: $first, skip: $skip) {
- ...itemDetails
+mutation CREATE_ORDER_MUTATION($token: String!) {
+ createOrder(token: $token) {
+ id
+ charge
+ total
+ items {
+ id
+ title
}
}
-# `;
+}
-# export const SINGLE_ITEM_QUERY = gql`
- # ${itemDetails}
- query SINGLE_ITEM_QUERY($id: ID!) {
- items(where: { id: $id }) {
- user {
- id
- email
- name
- }
- ...itemDetails
+query ALL_ITEMS_QUERY($skip: Int = 0, $first: Int = 4) {
+ itemsConnection(orderBy: createdAt_DESC, first: $first, skip: $skip) {
+ aggregate {
+ count
}
}
-# `;
+ items(orderBy: createdAt_DESC, first: $first, skip: $skip) {
+ ...itemDetails
+ }
+}
-# export const SINGLE_ORDER_QUERY = gql`
- query SINGLE_ORDER_QUERY($id: ID!) {
- order(id: $id) {
+query SINGLE_ITEM_QUERY($id: ID!) {
+ items(where: { id: $id }) {
+ user {
id
- charge
- total
- createdAt
- user {
- id
- }
- items {
- id
- title
- price
- description
- image
- quantity
- }
+ email
+ name
}
+ ...itemDetails
}
-# `;
+}
-# export const SEARCH_ITEMS_QUERY = gql`
- # ${itemDetails}
- query SEARCH_ITEMS_QUERY($searchTerm: String!) {
- items(
- where: {
- OR: [
- { title_contains: $searchTerm }
- { description_contains: $searchTerm }
- ]
- }
- ) {
- ...itemDetails
+query SINGLE_ORDER_QUERY($id: ID!) {
+ order(id: $id) {
+ id
+ charge
+ total
+ createdAt
+ user {
+ id
}
- }
-# `;
-
-# export const REMOVE_ITEM_MUTATION = gql`
- mutation REMOVE_ITEM_MUTATION($id: ID!) {
- deleteItem(id: $id) {
+ items {
id
title
+ price
description
+ image
+ quantity
}
}
-# `;
+}
-# export const UPDATE_ITEM_MUTATION = gql`
- # ${itemDetails}
- mutation UPDATE_ITEM_MUTATION(
- $id: ID!
- $title: String
- $description: String
- $price: Int
- ) {
- updateItem(
- id: $id
- description: $description
- title: $title
- price: $price
- ) {
- ...itemDetails
+query SEARCH_ITEMS_QUERY($searchTerm: String!) {
+ items(
+ where: {
+ OR: [
+ { title_contains: $searchTerm }
+ { description_contains: $searchTerm }
+ ]
}
+ ) {
+ ...itemDetails
}
-# `;
+}
-# export const UPDATE_USER_MUTATION = gql`
- mutation UPDATE_USER_MUTATION($name: String!) {
- updateUser(name: $name) {
- name
- }
+mutation REMOVE_ITEM_MUTATION($id: ID!) {
+ deleteItem(id: $id) {
+ id
+ title
+ description
}
-# `;
+}
-# export const CURRENT_USER_QUERY = gql`
- # ${itemDetails}
- query CURRENT_USER_QUERY {
- me {
- id
- email
- name
- permissions
- orders {
- id
- charge
- total
- }
- cart {
- id
- quantity
- item {
- ...itemDetails
- }
- }
- }
+mutation UPDATE_ITEM_MUTATION(
+ $id: ID!
+ $title: String
+ $description: String
+ $price: Int
+) {
+ updateItem(
+ id: $id
+ description: $description
+ title: $title
+ price: $price
+ ) {
+ ...itemDetails
+ }
+}
+
+mutation UPDATE_USER_MUTATION($name: String!) {
+ updateUser(name: $name) {
+ name
}
-# `;
+}
-# export const USER_ORDERS_QUERY = gql`
- query USER_ORDERS_QUERY {
- orders(orderBy: createdAt_DESC) {
+query CURRENT_USER_QUERY {
+ me {
+ id
+ email
+ name
+ permissions
+ orders {
id
+ charge
total
- createdAt
- updatedAt
- items {
- id
- title
- price
- description
- quantity
- image
- }
}
- }
-# `;
-
-# export const ADD_TO_CART_MUTATION = gql`
- mutation ADD_TO_CART_MUTATION($id: ID!) {
- addToCart(id: $id) {
+ cart {
id
quantity
item {
- id
- price
- description
- image
- title
+ ...itemDetails
}
}
}
-# `;
+}
-# export const REMOVE_FROM_CART_MUTATION = gql`
- mutation REMOVE_FROM_CART_MUTATION($id: ID!) {
- removeFromCart(id: $id) {
+query USER_ORDERS_QUERY {
+ orders(orderBy: createdAt_DESC) {
+ id
+ total
+ createdAt
+ updatedAt
+ items {
id
+ title
+ price
+ description
+ quantity
+ image
}
}
-# `;
+}
-# export const ALL_USERS_QUERY = gql`
- query ALL_USERS_QUERY {
- users {
+mutation ADD_TO_CART_MUTATION($id: ID!) {
+ addToCart(id: $id) {
+ id
+ quantity
+ item {
id
- name
- email
- permissions
+ price
+ description
+ image
+ title
}
}
-# `;
+}
-# export const UPDATE_PERMISSIONS_MUTATION = gql`
- mutation UPDATE_PERMISSIONS_MUTATION($permissions: [Permission], $userId: ID!) {
- updatePermissions(permissions: $permissions, userId: $userId) {
- id
- permissions
- name
- email
- }
+mutation REMOVE_FROM_CART_MUTATION($id: ID!) {
+ removeFromCart(id: $id) {
+ id
}
-# `;
+}
-# export const LOCAL_STATE_QUERY = gql`
- query LOCAL_STATE_QUERY {
- cartOpen @client
+query ALL_USERS_QUERY {
+ users {
+ id
+ name
+ email
+ permissions
}
-# `;
+}
-# export const TOGGLE_CART_MUTATION = gql`
- mutation TOGGLE_CART_MUTATION {
- toggleCart @client
+mutation UPDATE_PERMISSIONS_MUTATION($permissions: [Permission], $userId: ID!) {
+ updatePermissions(permissions: $permissions, userId: $userId) {
+ id
+ permissions
+ name
+ email
}
-# `;
- "
+}
+
+query LOCAL_STATE_QUERY {
+ cartOpen @client
+}
+
+mutation TOGGLE_CART_MUTATION {
+ toggleCart @client
+}
+