-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: do not render things when no items are in cart (#2112)
* Move fragments out of components for reuse. Do not render adjustments or price summary when no items are in cart Signed-off-by: Stephen Rugh <[email protected]> * Fix useCartPage tests Signed-off-by: Stephen Rugh <[email protected]> * Compose fragment to top level cart page and reuse in mutation Signed-off-by: Stephen Rugh <[email protected]> * Reset fetch policies to default cache-first. Use ids in all graphql cart queries to match cache entries Signed-off-by: Stephen Rugh <[email protected]> * Move fragment out of product listing query Signed-off-by: Stephen Rugh <[email protected]> * Use id in fragments instead of query Signed-off-by: Stephen Rugh <[email protected]> * readd fetch policy since other mutations would have to be modified and that's out of scope... Signed-off-by: Stephen Rugh <[email protected]> * recompose cart query using child fragments Signed-off-by: Stephen Rugh <[email protected]> * do not render listing if no items. fix tests Signed-off-by: Stephen Rugh <[email protected]>
- Loading branch information
1 parent
cacde9c
commit 0d72488
Showing
21 changed files
with
338 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/venia-ui/lib/components/CartPage/PriceSummary/priceSummaryFragments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
import { DiscountSummaryFragment } from './discountSummary'; | ||
import { GiftCardSummaryFragment } from './giftCardSummary'; | ||
import { ShippingSummaryFragment } from './shippingSummary'; | ||
import { TaxSummaryFragment } from './taxSummary'; | ||
|
||
export const PriceSummaryFragment = gql` | ||
fragment PriceSummaryFragment on Cart { | ||
id | ||
items { | ||
quantity | ||
} | ||
...ShippingSummaryFragment | ||
prices { | ||
...TaxSummaryFragment | ||
...DiscountSummaryFragment | ||
grand_total { | ||
currency | ||
value | ||
} | ||
subtotal_excluding_tax { | ||
currency | ||
value | ||
} | ||
} | ||
...GiftCardSummaryFragment | ||
} | ||
${DiscountSummaryFragment} | ||
${GiftCardSummaryFragment} | ||
${ShippingSummaryFragment} | ||
${TaxSummaryFragment} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/venia-ui/lib/components/CartPage/ProductListing/productListingFragments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
export const ProductListingFragment = gql` | ||
fragment ProductListingFragment on Cart { | ||
id | ||
items { | ||
id | ||
product { | ||
name | ||
small_image { | ||
url | ||
} | ||
} | ||
prices { | ||
price { | ||
currency | ||
value | ||
} | ||
} | ||
quantity | ||
... on ConfigurableCartItem { | ||
configurable_options { | ||
option_label | ||
value_label | ||
} | ||
} | ||
} | ||
} | ||
`; |
Oops, something went wrong.