From 430f29f3c4dcda8df1e97a69c05726fb4903ee75 Mon Sep 17 00:00:00 2001 From: Stephen Rugh Date: Fri, 17 Jan 2020 16:08:25 -0600 Subject: [PATCH 01/11] Inital coupon code impl Signed-off-by: Stephen Rugh --- .../CouponCode/couponCode.css | 44 ++++ .../PriceAdjustments/CouponCode/couponCode.js | 211 ++++++++++++++++++ .../PriceAdjustments/CouponCode/index.js | 1 + .../PriceAdjustments/priceAdjustments.js | 13 +- .../components/CartPage/PriceSummary/index.js | 2 +- 5 files changed, 265 insertions(+), 6 deletions(-) create mode 100644 packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css create mode 100644 packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js create mode 100644 packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/index.js diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css new file mode 100644 index 0000000000..17a12f6119 --- /dev/null +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css @@ -0,0 +1,44 @@ +.entryForm { + display: grid; + grid-template-columns: 1fr 1fr; + grid-column-gap: 2rem; +} + +.applyButton { + composes: root_normalPriority from '../../../Button/button.css'; + align-self: center; + width: 2rem; + + /* To match height of input in same row...*/ + height: 2.25rem; +} + +.errorMessage { + color: rgb(var(--venia-error)); +} + +@media (max-width: 640px) { + .entryForm { + /* on mobile, switch to rows */ + grid-template-columns: unset; + grid-template-rows: 1fr 1fr; + grid-row-gap: 1rem; + } + + .applyButton { + composes: applyButton; + align-self: center; + justify-self: center; + } +} + +/* Styles for "removal" state. */ +.appliedCoupon { + font-size: 1rem; +} + +.removeButton { + margin-left: 1rem; + font-weight: bold; + text-decoration: underline; +} diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js new file mode 100644 index 0000000000..8afb2071c1 --- /dev/null +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js @@ -0,0 +1,211 @@ +import React, { useCallback, useEffect } from 'react'; +import { useLazyQuery, useMutation } from '@apollo/react-hooks'; +import gql from 'graphql-tag'; +import { useCartContext } from '@magento/peregrine/lib/context/cart'; +import { PriceSummaryQuery } from '../../PriceSummary'; +import Button from '../../../Button'; +import { mergeClasses } from '../../../../classify'; +import defaultClasses from './couponCode.css'; +import { Form } from 'informed'; +import Field from '../../../Field'; +import TextInput from '../../../TextInput'; + +export const APPLY_COUPON_MUTATION = gql` + mutation applyCouponToCart($cartId: String!, $couponCode: String!) { + applyCouponToCart( + input: { cart_id: $cartId, coupon_code: $couponCode } + ) { + cart { + id + # TODO: refetch discounts query + # prices { + # discounts { + # amount { + # value + # } + # } + # } + # applied_coupons { + # code + # } + } + } + } +`; +export const REMOVE_COUPON_MUTATION = gql` + mutation removeCouponFromCart($cartId: String!) { + removeCouponFromCart(input: { cart_id: $cartId }) { + cart { + id + # TODO: refetch discounts query + # prices { + # discounts { + # amount { + # value + # } + # } + # } + # applied_coupons { + # code + # } + } + } + } +`; +const GET_APPLIED_COUPONS = gql` + query getAppliedCoupons($cartId: String!) { + cart(cart_id: $cartId) { + id + applied_coupons { + code + } + } + } +`; + +const CouponCode = props => { + const classes = mergeClasses(defaultClasses, props.classes); + + const [{ cartId }] = useCartContext(); + const [fetchAppliedCoupons, { data, error: fetchError }] = useLazyQuery( + GET_APPLIED_COUPONS, + { + fetchPolicy: 'cache-and-network' + } + ); + + const [ + applyCoupon, + { error: applyError, loading: applyingCoupon } + ] = useMutation(APPLY_COUPON_MUTATION); + const [removeCoupon, { loading: removingCoupon }] = useMutation( + REMOVE_COUPON_MUTATION + ); + + const handleApplyCoupon = useCallback( + async ({ couponCode }) => { + if (!couponCode) return; + try { + await applyCoupon({ + variables: { + cartId, + couponCode + }, + refetchQueries: [ + { + query: GET_APPLIED_COUPONS, + variables: { + cartId + } + }, + { + query: PriceSummaryQuery, + variables: { + cartId + } + } + ] + }); + } catch (err) { + console.error(err); + } + }, + [applyCoupon, cartId] + ); + + const handleRemoveCoupon = useCallback( + async couponCode => { + await removeCoupon({ + variables: { + cartId, + couponCode + }, + refetchQueries: [ + { + query: GET_APPLIED_COUPONS, + variables: { + cartId + } + }, + { + query: PriceSummaryQuery, + variables: { + cartId + } + } + ] + }); + }, + [cartId, removeCoupon] + ); + + useEffect(() => { + if (cartId) { + fetchAppliedCoupons({ + variables: { + cartId + } + }); + } + }, [cartId, fetchAppliedCoupons]); + + if (!data) { + return null; + } + + if (fetchError) { + // TODO: Make this nicer + return 'Something went wrong -- unable to retrieve applied coupons.'; + } + + let message = ''; + if (data.cart.applied_coupons) { + const codes = data.cart.applied_coupons.map(({ code }) => { + return ( + + {code} + + + ); + }); + + return
{codes}
; + } else { + if (applyError) { + message = 'An error occurred. Try again.'; + } + return ( +
+ + + + {/* TODO: Button alignment isn't correct. Fix it.*/} + + + +
+ ); + } +}; + +export default CouponCode; diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/index.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/index.js new file mode 100644 index 0000000000..e272e3dd4a --- /dev/null +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/index.js @@ -0,0 +1 @@ +export { default } from './couponCode'; diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/priceAdjustments.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/priceAdjustments.js index 4336dfbf5b..cbc0934adf 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/priceAdjustments.js +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/priceAdjustments.js @@ -4,26 +4,29 @@ import { Accordion, Section } from '../../Accordion'; import { mergeClasses } from '../../../classify'; import defaultClasses from './priceAdjustments.css'; +import CouponCode from './CouponCode'; const PriceAdjustments = props => { const classes = mergeClasses(defaultClasses, props.classes); + // TODO: Minimizing accordion views actually unmounts the components. If a component does things, like make a query, on mount, it may make unnecessary queries. Can we just hide the content? return (
Shipping Methods to be completed by PWA-239.
-
- - Coupon Codes to be completed by PWA-75. - +
+
diff --git a/packages/venia-ui/lib/components/CartPage/PriceSummary/index.js b/packages/venia-ui/lib/components/CartPage/PriceSummary/index.js index bf71c9a8c8..d33de3f445 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceSummary/index.js +++ b/packages/venia-ui/lib/components/CartPage/PriceSummary/index.js @@ -1 +1 @@ -export { default } from './priceSummary'; +export { default, PriceSummaryQuery } from './priceSummary'; From 3fa0274ba18c0825942b967a0e2cc2b5ac0d0712 Mon Sep 17 00:00:00 2001 From: Stephen Rugh Date: Tue, 21 Jan 2020 12:08:45 -0600 Subject: [PATCH 02/11] Use fragments in requeest body instead of refetchQueries to prevent overfetch Signed-off-by: Stephen Rugh --- .../PriceAdjustments/CouponCode/couponCode.js | 72 ++++--------------- .../CouponCode/couponCodeFragments.js | 9 +++ .../PriceSummary/priceSummaryFragments.js | 15 ++-- 3 files changed, 34 insertions(+), 62 deletions(-) create mode 100644 packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCodeFragments.js diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js index 8afb2071c1..c7ae342136 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js @@ -2,7 +2,6 @@ import React, { useCallback, useEffect } from 'react'; import { useLazyQuery, useMutation } from '@apollo/react-hooks'; import gql from 'graphql-tag'; import { useCartContext } from '@magento/peregrine/lib/context/cart'; -import { PriceSummaryQuery } from '../../PriceSummary'; import Button from '../../../Button'; import { mergeClasses } from '../../../../classify'; import defaultClasses from './couponCode.css'; @@ -10,57 +9,41 @@ import { Form } from 'informed'; import Field from '../../../Field'; import TextInput from '../../../TextInput'; +import { AppliedCouponsFragment } from './couponCodeFragments'; +import { CartPageFragment } from '../../cartPageFragments'; + export const APPLY_COUPON_MUTATION = gql` mutation applyCouponToCart($cartId: String!, $couponCode: String!) { applyCouponToCart( input: { cart_id: $cartId, coupon_code: $couponCode } ) { cart { - id - # TODO: refetch discounts query - # prices { - # discounts { - # amount { - # value - # } - # } - # } - # applied_coupons { - # code - # } + ...CartPageFragment } } } + ${CartPageFragment} `; + export const REMOVE_COUPON_MUTATION = gql` mutation removeCouponFromCart($cartId: String!) { removeCouponFromCart(input: { cart_id: $cartId }) { cart { - id - # TODO: refetch discounts query - # prices { - # discounts { - # amount { - # value - # } - # } - # } - # applied_coupons { - # code - # } + ...CartPageFragment } } } + ${CartPageFragment} `; + const GET_APPLIED_COUPONS = gql` query getAppliedCoupons($cartId: String!) { cart(cart_id: $cartId) { id - applied_coupons { - code - } + ...AppliedCouponsFragment } } + ${AppliedCouponsFragment} `; const CouponCode = props => { @@ -90,21 +73,7 @@ const CouponCode = props => { variables: { cartId, couponCode - }, - refetchQueries: [ - { - query: GET_APPLIED_COUPONS, - variables: { - cartId - } - }, - { - query: PriceSummaryQuery, - variables: { - cartId - } - } - ] + } }); } catch (err) { console.error(err); @@ -119,21 +88,7 @@ const CouponCode = props => { variables: { cartId, couponCode - }, - refetchQueries: [ - { - query: GET_APPLIED_COUPONS, - variables: { - cartId - } - }, - { - query: PriceSummaryQuery, - variables: { - cartId - } - } - ] + } }); }, [cartId, removeCoupon] @@ -154,6 +109,7 @@ const CouponCode = props => { } if (fetchError) { + console.log(fetchError); // TODO: Make this nicer return 'Something went wrong -- unable to retrieve applied coupons.'; } diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCodeFragments.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCodeFragments.js new file mode 100644 index 0000000000..9a016e23b5 --- /dev/null +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCodeFragments.js @@ -0,0 +1,9 @@ +import gql from 'graphql-tag'; + +export const AppliedCouponsFragment = gql` + fragment AppliedCouponsFragment on Cart { + applied_coupons { + code + } + } +`; diff --git a/packages/venia-ui/lib/components/CartPage/PriceSummary/priceSummaryFragments.js b/packages/venia-ui/lib/components/CartPage/PriceSummary/priceSummaryFragments.js index 262395fe16..2c56e731e3 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceSummary/priceSummaryFragments.js +++ b/packages/venia-ui/lib/components/CartPage/PriceSummary/priceSummaryFragments.js @@ -5,6 +5,15 @@ import { GiftCardSummaryFragment } from './giftCardSummary'; import { ShippingSummaryFragment } from './shippingSummary'; import { TaxSummaryFragment } from './taxSummary'; +export const GrandTotalFragment = gql` + fragment GrandTotalFragment on CartPrices { + grand_total { + currency + value + } + } +`; + export const PriceSummaryFragment = gql` fragment PriceSummaryFragment on Cart { id @@ -15,10 +24,7 @@ export const PriceSummaryFragment = gql` prices { ...TaxSummaryFragment ...DiscountSummaryFragment - grand_total { - currency - value - } + ...GrandTotalFragment subtotal_excluding_tax { currency value @@ -28,6 +34,7 @@ export const PriceSummaryFragment = gql` } ${DiscountSummaryFragment} ${GiftCardSummaryFragment} + ${GrandTotalFragment} ${ShippingSummaryFragment} ${TaxSummaryFragment} `; From 8b005ddc44753b91a590fa0155df0b3a254b261a Mon Sep 17 00:00:00 2001 From: Stephen Rugh Date: Tue, 21 Jan 2020 13:27:13 -0600 Subject: [PATCH 03/11] Use empty space for correct sizing in desktop mode Signed-off-by: Stephen Rugh --- .../CartPage/PriceAdjustments/CouponCode/couponCode.css | 3 +-- .../CartPage/PriceAdjustments/CouponCode/couponCode.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css index 17a12f6119..34c2ab0b7b 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css @@ -22,7 +22,6 @@ /* on mobile, switch to rows */ grid-template-columns: unset; grid-template-rows: 1fr 1fr; - grid-row-gap: 1rem; } .applyButton { @@ -32,7 +31,7 @@ } } -/* Styles for "removal" state. */ +/* Styles for "removal" view. */ .appliedCoupon { font-size: 1rem; } diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js index c7ae342136..7fb1fe2cf4 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js @@ -61,6 +61,7 @@ const CouponCode = props => { applyCoupon, { error: applyError, loading: applyingCoupon } ] = useMutation(APPLY_COUPON_MUTATION); + const [removeCoupon, { loading: removingCoupon }] = useMutation( REMOVE_COUPON_MUTATION ); @@ -110,8 +111,7 @@ const CouponCode = props => { if (fetchError) { console.log(fetchError); - // TODO: Make this nicer - return 'Something went wrong -- unable to retrieve applied coupons.'; + return 'Something went wrong. Refresh and try again.'; } let message = ''; @@ -148,8 +148,8 @@ const CouponCode = props => { message={message} /> - {/* TODO: Button alignment isn't correct. Fix it.*/} - + {/* To ensure proper alignment, pass a space as the label.*/} + - + ); }); - return
{codes}
; + return
{codes}
; } else { return ( From 19ef9f63cc6f107a1f771b82830ff0293e676646 Mon Sep 17 00:00:00 2001 From: Stephen Rugh Date: Wed, 22 Jan 2020 09:59:23 -0600 Subject: [PATCH 08/11] Add tests for coupon code Signed-off-by: Stephen Rugh --- .../__snapshots__/couponCode.spec.js.snap | 190 ++++++++++++++++++ .../CouponCode/__tests__/couponCode.spec.js | 159 +++++++++++++++ .../CouponCode/couponCode.css | 2 +- .../PriceAdjustments/CouponCode/couponCode.js | 24 +-- .../priceAdjustments.spec.js.snap | 16 +- .../__tests__/priceAdjustments.spec.js | 2 + 6 files changed, 370 insertions(+), 23 deletions(-) create mode 100644 packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/__snapshots__/couponCode.spec.js.snap create mode 100644 packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/couponCode.spec.js diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/__snapshots__/couponCode.spec.js.snap b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/__snapshots__/couponCode.spec.js.snap new file mode 100644 index 0000000000..2eb6aafdea --- /dev/null +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/__snapshots__/couponCode.spec.js.snap @@ -0,0 +1,190 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`disables remove button on click 1`] = ` +
+ + COUPON + + +
+`; + +exports[`disables submit button on coupon entry 1`] = ` + +
+ + + + + + + + +

+ +

+
+
+
+ +`; + +exports[`renders CouponCode input and submit button 1`] = ` +
+
+ + + + + + + + +

+ +

+
+
+
+
+`; + +exports[`renders an error message if an error occurs on code entry 1`] = ` +
+
+ + + + + + + + +

+ An error occurred. Try again. +

+
+
+
+
+`; + +exports[`renders an error state if unable to fetch applied coupons 1`] = `"Something went wrong. Refresh and try again."`; + +exports[`renders nothing if no data is returned 1`] = `null`; + +exports[`renders the coupon code view if applied coupons has data 1`] = ` +
+ + COUPON + + +
+`; diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/couponCode.spec.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/couponCode.spec.js new file mode 100644 index 0000000000..04af2d22d2 --- /dev/null +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/__tests__/couponCode.spec.js @@ -0,0 +1,159 @@ +import React from 'react'; +import { createTestInstance } from '@magento/peregrine'; + +import CouponCode from '../couponCode'; +import { useLazyQuery, useMutation } from '@apollo/react-hooks'; + +jest.mock('@apollo/react-hooks', () => { + const runQuery = jest.fn(); + const runMutation = jest.fn(); + const queryResult = { + data: { + cart: { + id: 'cartId', + applied_coupons: null + } + }, + error: null, + loading: false + }; + + const mutationResult = { + error: null, + loading: false + }; + + const useLazyQuery = jest.fn(() => [runQuery, queryResult]); + const useMutation = jest.fn(() => [runMutation, mutationResult]); + + return { useLazyQuery, useMutation }; +}); + +jest.mock('@magento/peregrine/lib/context/cart', () => { + const state = { cartId: 'cart123' }; + const api = {}; + const useCartContext = jest.fn(() => [state, api]); + + return { useCartContext }; +}); + +const defaultProps = { + classes: { + applyButton: 'applybutton', + appliedCoupon: 'appliedCoupon', + entryForm: 'entryForm', + removeButton: 'removeButton' + } +}; + +test('renders nothing if no data is returned', () => { + useLazyQuery.mockReturnValueOnce([ + jest.fn(), + { + data: null + } + ]); + + const tree = createTestInstance(); + + expect(tree.toJSON()).toMatchSnapshot(); +}); + +test('renders an error state if unable to fetch applied coupons', () => { + useLazyQuery.mockReturnValueOnce([ + jest.fn(), + { + data: {}, + error: true + } + ]); + + const tree = createTestInstance(); + + expect(tree.toJSON()).toMatchSnapshot(); +}); + +test('renders CouponCode input and submit button', () => { + const instance = createTestInstance(); + + expect(instance.toJSON()).toMatchSnapshot(); +}); + +test('disables submit button on coupon entry', () => { + useMutation.mockReturnValueOnce([ + jest.fn(), + { + loading: true + } + ]); + + const instance = createTestInstance(); + expect(instance.toJSON()).toMatchSnapshot(); +}); + +test('renders an error message if an error occurs on code entry', () => { + useMutation.mockReturnValueOnce([ + jest.fn(), + { + error: 'AN ERROR' + } + ]); + const instance = createTestInstance(); + + expect(instance.toJSON()).toMatchSnapshot(); +}); + +test('renders the coupon code view if applied coupons has data', () => { + useLazyQuery.mockReturnValueOnce([ + jest.fn(), + { + data: { + cart: { + applied_coupons: [ + { + code: 'COUPON' + } + ] + } + } + } + ]); + const instance = createTestInstance(); + + expect(instance.toJSON()).toMatchSnapshot(); +}); + +test('disables remove button on click', () => { + useLazyQuery.mockReturnValueOnce([ + jest.fn(), + { + data: { + cart: { + applied_coupons: [ + { + code: 'COUPON' + } + ] + } + } + } + ]); + + // Mock the click of the remove button + useMutation + .mockReturnValueOnce([ + jest.fn(), + { + loading: false + } + ]) + .mockReturnValueOnce([ + jest.fn(), + { + loading: true + } + ]); + + const instance = createTestInstance(); + expect(instance.toJSON()).toMatchSnapshot(); +}); diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css index 2bad0fdf6e..9869087874 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.css @@ -1,3 +1,4 @@ +/* Styles for "add" view. */ .entryForm { display: grid; grid-template-columns: 1fr 1fr; @@ -28,7 +29,6 @@ } /* Styles for "removal" view. */ - .removeButton { margin-left: 1rem; font-weight: bold; diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js index e23b50bfd5..17d806d8fe 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js @@ -13,7 +13,17 @@ import TextInput from '../../../TextInput'; import { AppliedCouponsFragment } from './couponCodeFragments'; import { CartPageFragment } from '../../cartPageFragments'; -export const APPLY_COUPON_MUTATION = gql` +const GET_APPLIED_COUPONS = gql` + query getAppliedCoupons($cartId: String!) { + cart(cart_id: $cartId) { + id + ...AppliedCouponsFragment + } + } + ${AppliedCouponsFragment} +`; + +const APPLY_COUPON_MUTATION = gql` mutation applyCouponToCart($cartId: String!, $couponCode: String!) { applyCouponToCart( input: { cart_id: $cartId, coupon_code: $couponCode } @@ -26,7 +36,7 @@ export const APPLY_COUPON_MUTATION = gql` ${CartPageFragment} `; -export const REMOVE_COUPON_MUTATION = gql` +const REMOVE_COUPON_MUTATION = gql` mutation removeCouponFromCart($cartId: String!) { removeCouponFromCart(input: { cart_id: $cartId }) { cart { @@ -37,16 +47,6 @@ export const REMOVE_COUPON_MUTATION = gql` ${CartPageFragment} `; -const GET_APPLIED_COUPONS = gql` - query getAppliedCoupons($cartId: String!) { - cart(cart_id: $cartId) { - id - ...AppliedCouponsFragment - } - } - ${AppliedCouponsFragment} -`; - const CouponCode = props => { const classes = mergeClasses(defaultClasses, props.classes); diff --git a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap index a526f228d3..79e2a6e4fc 100644 --- a/packages/venia-ui/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap +++ b/packages/venia-ui/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap @@ -23,18 +23,12 @@ exports[`it renders Venia price adjustments 1`] = ` xmlns="http://www.w3.org/2000/svg" > -
+
-
+
+ +