@graphcommerce/magento-cart 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/Api/CartItemCountChanged.gql.ts +4 -0
  2. package/Api/CartItemCountChanged.graphql +9 -0
  3. package/CHANGELOG.md +324 -0
  4. package/README.md +102 -0
  5. package/components/AddToCartButton/AddToCartButton.tsx +127 -0
  6. package/components/ApolloCartError/ApolloCartErrorAlert.tsx +36 -0
  7. package/components/ApolloCartError/ApolloCartErrorFullPage.tsx +1 -0
  8. package/components/CartFab/CartFab.gql.ts +12 -0
  9. package/components/CartFab/CartFab.graphql +6 -0
  10. package/components/CartFab/CartFab.tsx +67 -0
  11. package/components/CartFab/CartTotalQuantity.gql.ts +4 -0
  12. package/components/CartFab/CartTotalQuantity.graphql +3 -0
  13. package/components/CartItemSummary/GetCartItemSummary.gql.ts +12 -0
  14. package/components/CartItemSummary/GetCartItemSummary.graphql +6 -0
  15. package/components/CartItemSummary/index.tsx +133 -0
  16. package/components/CartStartCheckout/CartStartCheckout.gql.ts +4 -0
  17. package/components/CartStartCheckout/CartStartCheckout.graphql +7 -0
  18. package/components/CartStartCheckout/CartStartCheckout.tsx +63 -0
  19. package/components/CartSummary/CartSummary.gql.ts +4 -0
  20. package/components/CartSummary/CartSummary.graphql +15 -0
  21. package/components/CartSummary/GetCartSummary.gql.ts +12 -0
  22. package/components/CartSummary/GetCartSummary.graphql +5 -0
  23. package/components/CartSummary/index.tsx +139 -0
  24. package/components/CartTotals/CartTotals.gql.ts +4 -0
  25. package/components/CartTotals/CartTotals.graphql +51 -0
  26. package/components/CartTotals/CartTotals.tsx +187 -0
  27. package/components/CartTotals/GetCartTotals.gql.ts +12 -0
  28. package/components/CartTotals/GetCartTotals.graphql +5 -0
  29. package/components/EmptyCart/EmptyCart.tsx +56 -0
  30. package/components/index.ts +24 -0
  31. package/hooks/CreateEmptyCart.gql.ts +10 -0
  32. package/hooks/CreateEmptyCart.graphql +3 -0
  33. package/hooks/CurrentCartId.gql.ts +10 -0
  34. package/hooks/CurrentCartId.graphql +6 -0
  35. package/hooks/CurrentCartId.graphqls +11 -0
  36. package/hooks/CustomerCart.gql.ts +10 -0
  37. package/hooks/CustomerCart.graphql +7 -0
  38. package/hooks/UseCartRedirect.gql.ts +12 -0
  39. package/hooks/UseCartRedirect.graphql +5 -0
  40. package/hooks/UseMergeCustomerCart.gql.ts +13 -0
  41. package/hooks/UseMergeCustomerCart.graphql +6 -0
  42. package/hooks/index.ts +8 -0
  43. package/hooks/useAssignCurrentCartId.ts +18 -0
  44. package/hooks/useCartIdCreate.ts +22 -0
  45. package/hooks/useCartQuery.ts +37 -0
  46. package/hooks/useClearCurrentCartId.ts +18 -0
  47. package/hooks/useCurrentCartId.ts +6 -0
  48. package/hooks/useDisplayInclTax.ts +7 -0
  49. package/hooks/useFormGqlMutationCart.ts +28 -0
  50. package/hooks/useMergeCustomerCart.ts +49 -0
  51. package/index.ts +4 -0
  52. package/next-env.d.ts +4 -0
  53. package/package.json +42 -0
  54. package/tsconfig.json +5 -0
  55. package/typePolicies.ts +56 -0
@@ -0,0 +1,4 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ export type CartItemCountChangedFragment = { __typename: 'Cart', id: string, total_quantity: number, items?: Types.Maybe<Array<Types.Maybe<{ __typename: 'BundleCartItem', uid: string, quantity: number } | { __typename: 'ConfigurableCartItem', uid: string, quantity: number } | { __typename: 'DownloadableCartItem', uid: string, quantity: number } | { __typename: 'SimpleCartItem', uid: string, quantity: number } | { __typename: 'VirtualCartItem', uid: string, quantity: number }>>>, prices?: Types.Maybe<{ __typename: 'CartPrices', grand_total?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, applied_taxes?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, discounts?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, subtotal_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_including_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_with_discount_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }> }>, shipping_addresses: Array<Types.Maybe<{ selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string, method_title: string, carrier_title: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ carrier_code: string, method_code?: Types.Maybe<string>, price_incl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, price_excl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>> }>> };
@@ -0,0 +1,9 @@
1
+ fragment CartItemCountChanged on Cart @injectable {
2
+ __typename
3
+ id
4
+ items {
5
+ __typename
6
+ uid
7
+ quantity
8
+ }
9
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,324 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [3.0.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.0.0...@graphcommerce/magento-cart@3.0.1) (2021-09-27)
7
+
8
+ **Note:** Version bump only for package @graphcommerce/magento-cart
9
+
10
+
11
+
12
+
13
+
14
+ # 3.0.0 (2021-09-27)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * account flow (wip) ([0e75aeb](https://github.com/ho-nl/m2-pwa/commit/0e75aebcab3043f9dcd7fd095f9c46cb25d40d57))
20
+ * add cartprices to cartTypePolicies ([d6877f5](https://github.com/ho-nl/m2-pwa/commit/d6877f526ae60d824a343a70704285d0504db469))
21
+ * add styling for subtitle1 ([3b18e36](https://github.com/ho-nl/m2-pwa/commit/3b18e36e66d7c7406585a930723fa4f152763a26))
22
+ * add the correct svg for empty cart ([e62f490](https://github.com/ho-nl/m2-pwa/commit/e62f490f64ccaf5290b9c9bbf02222b549b8ca11))
23
+ * address fragments ([96e68c3](https://github.com/ho-nl/m2-pwa/commit/96e68c3f96e40dded50ec5859909a7326b47e37b))
24
+ * address multi line props bug ([2cb3071](https://github.com/ho-nl/m2-pwa/commit/2cb3071a05b75297b3a44915c31b77d4c46ff9cb))
25
+ * adjust imports to correct ones ([c6e3092](https://github.com/ho-nl/m2-pwa/commit/c6e3092569d1c49fe138b3810704da8e04acbbe2))
26
+ * allow url to be used for the CartTotals ([b7d1d6a](https://github.com/ho-nl/m2-pwa/commit/b7d1d6a608309d59ff7a87464fc1e429e2eb064f))
27
+ * always show Cart in back button on shipping step ([8f5a0d7](https://github.com/ho-nl/m2-pwa/commit/8f5a0d71d78fad6f630ff985b02187bd7c86adc9))
28
+ * animate checkout login flow ([0fa32f6](https://github.com/ho-nl/m2-pwa/commit/0fa32f634b94a1f827cf2e4e44e2399a10efb7a1))
29
+ * back button url category path ([d8c83ba](https://github.com/ho-nl/m2-pwa/commit/d8c83ba86eb9a29c3b028a64657a5656ca0f6fc4))
30
+ * cannot execute query error in checkout when signed in ([0004841](https://github.com/ho-nl/m2-pwa/commit/00048418afcf6199bf3714a7b472b6f70dcd99f0))
31
+ * cart cache not up-to-date ([aae4d30](https://github.com/ho-nl/m2-pwa/commit/aae4d302e320475d28a356ec304ea6afb64c3080))
32
+ * cart couldn’t be loaded because it was missing available_payment_methods ([e5df734](https://github.com/ho-nl/m2-pwa/commit/e5df7344e3f65a906d92f8daa72f04073d7ab66e))
33
+ * cart didn't use the AppShellTitle ([65a58c8](https://github.com/ho-nl/m2-pwa/commit/65a58c8dc7d39cd4c9cb31c4005828376c9e7ad1))
34
+ * cart fab box shadow animation ([4c73e42](https://github.com/ho-nl/m2-pwa/commit/4c73e423a920f6485f72b24141cccda010a35ab7))
35
+ * cart icon shows badge without content ([0d06614](https://github.com/ho-nl/m2-pwa/commit/0d06614f090a0aa635d4b1da0d0586d531a90242))
36
+ * cart item discount rendering ([0fb0fd2](https://github.com/ho-nl/m2-pwa/commit/0fb0fd2b1a3de07503fbdef08400311355939f16))
37
+ * cart item options list as button ([864bc85](https://github.com/ho-nl/m2-pwa/commit/864bc8517503c5813b482172e0f11d2b4cdcc28f))
38
+ * cart item product link ([04e6313](https://github.com/ho-nl/m2-pwa/commit/04e6313afe4efd4dc359bd827be04fb029e021eb))
39
+ * cart item styling ([1def7f4](https://github.com/ho-nl/m2-pwa/commit/1def7f49ad4dd621aff6cfd058acc489e522650f))
40
+ * cart items not linking to product page ([d2163e1](https://github.com/ho-nl/m2-pwa/commit/d2163e18ef4561613bee89080b21f0298e29efe6))
41
+ * cart summary components use correct query ([3a61bfe](https://github.com/ho-nl/m2-pwa/commit/3a61bfe7c0e308ea79f3d94403b2182ec4dfe442))
42
+ * **cart-item-summary:** remove unnecessary animate presence ([95a0750](https://github.com/ho-nl/m2-pwa/commit/95a0750a3d27fa206a7f88635cbfbcfd8034957c))
43
+ * **cart-item-summary:** thumbnail image bottom spacing ([f761a42](https://github.com/ho-nl/m2-pwa/commit/f761a4221f65f3c8897cc36298ed973bccbd3266))
44
+ * **cart-summary:** spacings ([73b7379](https://github.com/ho-nl/m2-pwa/commit/73b7379731bd1fe21c27d9b12f29b518efe73dce))
45
+ * **cart:** cart items need to be fetched after the product count changed ([0f7dd80](https://github.com/ho-nl/m2-pwa/commit/0f7dd80d37cde19d172e38f8f0b8d7f8ee6a7dca))
46
+ * **cart:** display prices with taxes for specific store views ([fd25541](https://github.com/ho-nl/m2-pwa/commit/fd25541646c41111f5ea53822d244591cb08b199))
47
+ * **cart:** merge or prices didn’t go well ([49efd8c](https://github.com/ho-nl/m2-pwa/commit/49efd8c934ea4e0f8ebcb5ac65f89f9ea2c0fa26))
48
+ * **cart:** update totals when changing quantities ([20f2b3f](https://github.com/ho-nl/m2-pwa/commit/20f2b3fd4fb87d3a542495af9822476d27d8b1ab))
49
+ * checkout button styling ([8565ef2](https://github.com/ho-nl/m2-pwa/commit/8565ef2d4ad5c3e930b8d7d8fa6debb3a799c371))
50
+ * checkout login flow ([c6aace8](https://github.com/ho-nl/m2-pwa/commit/c6aace8cbf5319325fb2b2c0c9b778c080095d4c))
51
+ * checkout stepper not highlighting completed steps ([f0bfc24](https://github.com/ho-nl/m2-pwa/commit/f0bfc24b7b47140d149a16849575bf3ac56ac474))
52
+ * coupon animations, spacing, rippl;ie ([cef3a08](https://github.com/ho-nl/m2-pwa/commit/cef3a08d0545947518873c5257c59fc1b98f1a21))
53
+ * discount error when removing a discount ([bb6fae3](https://github.com/ho-nl/m2-pwa/commit/bb6fae3ccee694d6a19d9de01febd4cc0166b49c))
54
+ * display prices excl and incl tax ([0d41135](https://github.com/ho-nl/m2-pwa/commit/0d411350e4621928411c2800be6ea02c6125049a))
55
+ * dynamic configurable cart item options ([d2cc538](https://github.com/ho-nl/m2-pwa/commit/d2cc5383800ca19baa267da7808005c910dfbf62))
56
+ * header fab icons size ([772a721](https://github.com/ho-nl/m2-pwa/commit/772a7213a7ee8274ed006fcd6b6fb5123630a771))
57
+ * header item marges ([45e89c7](https://github.com/ho-nl/m2-pwa/commit/45e89c76d569dfa59c2412f03b231e028903dbcd))
58
+ * helper list styles ([2cb825d](https://github.com/ho-nl/m2-pwa/commit/2cb825d24edf8772b191c50ded521590c70966df))
59
+ * hide discounts when no discounts available ([5a993e6](https://github.com/ho-nl/m2-pwa/commit/5a993e6810481a0cb878cf2f1ebcb100a7a35733))
60
+ * icon alignments & sizes ([3b349c9](https://github.com/ho-nl/m2-pwa/commit/3b349c96f08f25cad892cf224ee76e937fb338b8))
61
+ * ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
62
+ * **image:** fix build ([b730cb6](https://github.com/ho-nl/m2-pwa/commit/b730cb6ae4e50dcf2f60e2046d6acf3047caacb3))
63
+ * implement next-ui barrel imports ([75bea70](https://github.com/ho-nl/m2-pwa/commit/75bea703dba898f18a2a1dfa3243ebd0a4e6f0e1))
64
+ * input checkmarks ([279c1c1](https://github.com/ho-nl/m2-pwa/commit/279c1c112ada46fdea102024298e8293d1a23293))
65
+ * make sense of spacings for mobile navigation ([bd42c97](https://github.com/ho-nl/m2-pwa/commit/bd42c973753cd3e09ae8599bfef677979bae21f6))
66
+ * make sure an empty cart gets initialized properly ([12df845](https://github.com/ho-nl/m2-pwa/commit/12df8456117393cc7c387ba6e072190a831b7a58))
67
+ * make sure region is cleared when switching country ([422ef88](https://github.com/ho-nl/m2-pwa/commit/422ef888f74eb6c278d68b216fa0114f1499f196))
68
+ * make sure the session token gets deactivated when trying to merge carts when it cant ([2a9416b](https://github.com/ho-nl/m2-pwa/commit/2a9416b5c9efcd28a27f4183922ab419f62ea767))
69
+ * make sure to use barrel files ([b73aaf1](https://github.com/ho-nl/m2-pwa/commit/b73aaf1b47db1c807e6b8665e33c7fd5633c49b4))
70
+ * messagesnackbar text alignment ([1314d64](https://github.com/ho-nl/m2-pwa/commit/1314d642a776707462709df380f6fa7fee40ca9d))
71
+ * onBeforeSubmit didn’t work ([a3e780a](https://github.com/ho-nl/m2-pwa/commit/a3e780a52251b844dfad3a5c40542980a57319b9))
72
+ * only show forgot password link when signing in ([f0ed943](https://github.com/ho-nl/m2-pwa/commit/f0ed9437a9f3043bb78d49da698f8351657e9dd5))
73
+ * quantity value not shown in cart item ([d6421aa](https://github.com/ho-nl/m2-pwa/commit/d6421aa5383e095a5c1615595b28b5341238d1ce))
74
+ * quantity value not shown in cart items ([013f58c](https://github.com/ho-nl/m2-pwa/commit/013f58cde1e5cc3f7131e5d87f51fdb37d51f784))
75
+ * **react-hook-form:** assertFormGqlOperation ([ce09fa5](https://github.com/ho-nl/m2-pwa/commit/ce09fa50f73f6d06b2caa15b1223ba7470a7ea96))
76
+ * **react-hook-form:** not not always submit ComposedForm ([642833f](https://github.com/ho-nl/m2-pwa/commit/642833fe8b311b20db2ccdd57f0492b8429c0e81))
77
+ * remove magento-product form package ([210ba3e](https://github.com/ho-nl/m2-pwa/commit/210ba3eeaadb9e4724dc9b34aa0570ea428e30d8))
78
+ * rename NextButton to Button, change imports ([976adb0](https://github.com/ho-nl/m2-pwa/commit/976adb0bf906310d1efce888dcc9be1e28ce0f1b))
79
+ * rename product prop to name ([9b7ed5a](https://github.com/ho-nl/m2-pwa/commit/9b7ed5a03747211c3f93d2628110ab6bfac4d552))
80
+ * shipping method costs in total costs container ([ff74b4b](https://github.com/ho-nl/m2-pwa/commit/ff74b4b6bc93674aeb62df64fb4918bb59172e03))
81
+ * show form checkmarks when field is valid ([7df8cad](https://github.com/ho-nl/m2-pwa/commit/7df8cadd5292c7d8a1d1e4c981d51adf7b5b8119))
82
+ * show sign in steps in checkout ([e56b1f2](https://github.com/ho-nl/m2-pwa/commit/e56b1f25d1f8f60e2d9afc84a5ce2f0e134fd9b5))
83
+ * sign up form inline animations ([83b5ba8](https://github.com/ho-nl/m2-pwa/commit/83b5ba85cd421cfc748f7af339012a34e07b48f1))
84
+ * since all links are of next/link we need to add passHref for custom components ([16fb931](https://github.com/ho-nl/m2-pwa/commit/16fb93100d367203ea79bb4f93357221253f2ecd))
85
+ * smaller delete button cart item on mobile ([fc09ebf](https://github.com/ho-nl/m2-pwa/commit/fc09ebf8f25ef29744644f6d84d4b3a33b1f17b3))
86
+ * some symantic errors ([9fa6994](https://github.com/ho-nl/m2-pwa/commit/9fa69947f163d5e2b05b1bd5c5a72eccada93489))
87
+ * spelling error in empty cart svg ([6d02d64](https://github.com/ho-nl/m2-pwa/commit/6d02d6403f1b12b55ebaf7d3cafffc5d127d990a))
88
+ * styling of cart totals ([f879f24](https://github.com/ho-nl/m2-pwa/commit/f879f24ac6732ff9c822ab4af7cc9adea1662001))
89
+ * telephone field default value ([b456d4a](https://github.com/ho-nl/m2-pwa/commit/b456d4a102331a49b3c7146ea90b46dd93bf66dc))
90
+ * telephone field value shipping address form ([9db0c90](https://github.com/ho-nl/m2-pwa/commit/9db0c90645f845eb4e0dd2a2862d7af67b2c8547))
91
+ * use SvgImageSimple for multiple areas ([bf851a6](https://github.com/ho-nl/m2-pwa/commit/bf851a6740e1956a78f457c2d90904ee2f65da2f))
92
+ * useFormAutoSubmit modes ([9180bf2](https://github.com/ho-nl/m2-pwa/commit/9180bf21a140f5741078007c42972ded433c277c))
93
+ * wrong casing ([ba64fc1](https://github.com/ho-nl/m2-pwa/commit/ba64fc182033b19ce4fc9294bd14eb457de05d48))
94
+ * yarn workspace packages hot reload ([d03fc9f](https://github.com/ho-nl/m2-pwa/commit/d03fc9fdda3486476761786f2b56a934cc92befc))
95
+
96
+
97
+ ### Features
98
+
99
+ * ability to place order after the payment has completed ([8fd479a](https://github.com/ho-nl/m2-pwa/commit/8fd479aded46ec1ba61b5dc42eccf4aaedff6c0c))
100
+ * add add-to-cart snackbar to all products ([e9570fd](https://github.com/ho-nl/m2-pwa/commit/e9570fdb55331b2a790f8910c0722dba83480f64))
101
+ * add barrel file for magento-customer ([02fb7f0](https://github.com/ho-nl/m2-pwa/commit/02fb7f004de968ee968b00e364b2b370f4f7d4f1))
102
+ * add component for empty cart ([1198ce0](https://github.com/ho-nl/m2-pwa/commit/1198ce0d1ddf835a84a0a881748747ae753fc466))
103
+ * add input for product quantity ([efc32a5](https://github.com/ho-nl/m2-pwa/commit/efc32a549fd701b38fd90ff677550eb8da8bcdb3))
104
+ * add preload to first item for ProductListItemsBase ([a4e06bc](https://github.com/ho-nl/m2-pwa/commit/a4e06bcb4192596b25d509b61669cff9d8bfdee7))
105
+ * add product-review to renderers and products ([1a9b84b](https://github.com/ho-nl/m2-pwa/commit/1a9b84b6b7de213e82f0c86106eea4b79f38f864))
106
+ * added braintree libraries for checkout process ([970ae9a](https://github.com/ho-nl/m2-pwa/commit/970ae9a03510e6e6851ffb81758ab71daedc7096))
107
+ * added PaymentModule API and persistent selection of form fields ([b67f735](https://github.com/ho-nl/m2-pwa/commit/b67f7358f62edd56a8232d625ecee56af350bfb8))
108
+ * address formatter wip ([6ab18be](https://github.com/ho-nl/m2-pwa/commit/6ab18be560b0432d6dc7772d46ff69a1f9139a20))
109
+ * animated cart rows and checkout stepper component ([5b3294d](https://github.com/ho-nl/m2-pwa/commit/5b3294d4a97c89d5c4690bbeac0814481babe3c9))
110
+ * animated filters ([846e233](https://github.com/ho-nl/m2-pwa/commit/846e233c9653821afbe9cfe7742dc42bb869a078))
111
+ * apollo error full page component ([fc1e695](https://github.com/ho-nl/m2-pwa/commit/fc1e695251a8792abaec5b9382e8301d3794cb6d))
112
+ * apollo error full page on account pages ([ed8c80f](https://github.com/ho-nl/m2-pwa/commit/ed8c80ffa66094e5aee3b0ca830436d863a85e82))
113
+ * apply coupon code to cart items ([0c2cebc](https://github.com/ho-nl/m2-pwa/commit/0c2cebc7d2b621d80395486d77c549d07392c2bf))
114
+ * better handling of shipping options ([9598f9b](https://github.com/ho-nl/m2-pwa/commit/9598f9bf5c523dfa2f043e6df42ce5e33aa218db))
115
+ * better sign in form handling ([6ac339f](https://github.com/ho-nl/m2-pwa/commit/6ac339fdfa1ece959cc8548e5bfadfca7c1f5cf6))
116
+ * cart fab on mobile ([bd2e9eb](https://github.com/ho-nl/m2-pwa/commit/bd2e9ebe056ba9a81b5c7228f1e5be57171266f4))
117
+ * **cart:** merge customer and guest carts when logging in ([25ebc0f](https://github.com/ho-nl/m2-pwa/commit/25ebc0f4e825f8512e2c3f1e01bf23a2d019b0d3))
118
+ * **cart:** when a cart is not active anymore show a clear cart button ([5d04a14](https://github.com/ho-nl/m2-pwa/commit/5d04a14726c040b20b34c0b88f923aee1dff22e5))
119
+ * checkout email added ([452a953](https://github.com/ho-nl/m2-pwa/commit/452a95377e116bfa8b757d3ccc45cf2e4ac7cc51))
120
+ * checkout/payment page added to checkout ([7e54cd6](https://github.com/ho-nl/m2-pwa/commit/7e54cd68685543ded27b285f15f6d9729b969a02))
121
+ * configurable product page ([486d5b4](https://github.com/ho-nl/m2-pwa/commit/486d5b448b854b5c9482b1313b7888b7f0743502))
122
+ * coupon form on payment page ([a163961](https://github.com/ho-nl/m2-pwa/commit/a1639617be756b357177fcce255cf662c5314499))
123
+ * created stacked-pages package ([d86008e](https://github.com/ho-nl/m2-pwa/commit/d86008ee659ccb25b194a41d624b394a1ddbd088))
124
+ * detailed cart view ([3a7126c](https://github.com/ho-nl/m2-pwa/commit/3a7126c08a1be580a1d9bba86951e11558cb0e5b))
125
+ * edit billing address on checkout payment step ([96a5719](https://github.com/ho-nl/m2-pwa/commit/96a5719437616006efb2588c3516d3f2608c1fb8))
126
+ * fallback to shop country of locale ([21e1378](https://github.com/ho-nl/m2-pwa/commit/21e13780252becdc1da06352354cd6789ab3e85e))
127
+ * forgot password on shipping step ([c9d11e2](https://github.com/ho-nl/m2-pwa/commit/c9d11e249945a4fa662b93ca26177a3ee9f9bb06))
128
+ * form styling consistency ([87cba85](https://github.com/ho-nl/m2-pwa/commit/87cba85e828fa42a02dfe74ac841aa2b39a60f4e))
129
+ * **framer-scroller:** implemented the scroller on all pages ([73fb518](https://github.com/ho-nl/m2-pwa/commit/73fb518eff74edb2b3212e892b3d8cc2b088011b))
130
+ * full page ui back and menu button position swap ([93b3419](https://github.com/ho-nl/m2-pwa/commit/93b34197947d133f4d1480c4ce68a0302201b858))
131
+ * full page ui desktop variant ([a70f301](https://github.com/ho-nl/m2-pwa/commit/a70f3013da36fa131f82fb44457b107fb7705df6))
132
+ * **graphql:** introduced new graphql package that holds all generated files ([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
133
+ * **graphql:** introducing local schema migrations ([e77ef8a](https://github.com/ho-nl/m2-pwa/commit/e77ef8ad4cd5723e2352dec937b45ee976929b24))
134
+ * groundwork for complete reimplementation of product pages ([b224da8](https://github.com/ho-nl/m2-pwa/commit/b224da8273eb5c8173ad30d006391b2291331623))
135
+ * **image:** introduced completely rewritten Image component ([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
136
+ * implemented checkmo payment method ([18525b2](https://github.com/ho-nl/m2-pwa/commit/18525b2f4efe9bd0eea12a7a992d284f341e0c68))
137
+ * inline cart svg ([fbcb518](https://github.com/ho-nl/m2-pwa/commit/fbcb51856afa81188bc292bd49fad5b164b5fcc7))
138
+ * inline sign up form in checkout ([d7c1066](https://github.com/ho-nl/m2-pwa/commit/d7c106632a6d754f7826f03c16b77f4b1e735377))
139
+ * introduces framer-next-pages and framer-sheet to next-ui and soxbase package ([e04ad8a](https://github.com/ho-nl/m2-pwa/commit/e04ad8a94cd1fd5a7c5575c9db7916b6e8a88f16))
140
+ * introducing useAutoSubmit for useForm to handle shipping address step ([d375a12](https://github.com/ho-nl/m2-pwa/commit/d375a123d5ba88285703fc1706a43c21c5a248d5))
141
+ * login flow ([8132b1a](https://github.com/ho-nl/m2-pwa/commit/8132b1a9be7040c3e2f70f1c1d04e6a9d7840a91))
142
+ * **magento-customer:** introduced ApolloCustomerErrorAlert ([e5406d9](https://github.com/ho-nl/m2-pwa/commit/e5406d91f914de290c5f097955e312312e567972))
143
+ * **magento-graphql:** added core magentoTypePolicies ([bdf15d0](https://github.com/ho-nl/m2-pwa/commit/bdf15d0d3c04e88339a8385d76f3b1ab9589fde3))
144
+ * make action optional in snackbar ([70cf9a4](https://github.com/ho-nl/m2-pwa/commit/70cf9a456e483040b2aad087a9cc01ecf85fe4c8))
145
+ * **next-ui:** SectionContainer/SectionHeader now accepts variantLeft/variantRight as prop ([a58f8f2](https://github.com/ho-nl/m2-pwa/commit/a58f8f2962e74c9aaa41142524d42d9c8f662b8d))
146
+ * next.js 11 ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
147
+ * **payments:** make PaymentMethodContext injectable ([68c664a](https://github.com/ho-nl/m2-pwa/commit/68c664adb7eb6eb86d7a819213deb87152392347))
148
+ * **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
149
+ * product delivery component for sidebar ([caa9809](https://github.com/ho-nl/m2-pwa/commit/caa9809d6c10570cb47e58c5e8191c40f20f1dbe))
150
+ * quick checkout component on cart page ([0eaafe5](https://github.com/ho-nl/m2-pwa/commit/0eaafe510da3a473b9888707a198361db9b65e06))
151
+ * **react-hook-form:** added ComposedForm component to handle the submission of multiple forms ([1172ec5](https://github.com/ho-nl/m2-pwa/commit/1172ec5abcb0e1b72bb362b977bf0c22997bac9a))
152
+ * reimplemented RowSwipeableGrid ([a9131de](https://github.com/ho-nl/m2-pwa/commit/a9131dea19347db2985ee3864e460dfa8a3f2182))
153
+ * renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
154
+ * support vscode graphql extension ([9324507](https://github.com/ho-nl/m2-pwa/commit/9324507c3c149fbcb7cd51ac41250a8637521ceb))
155
+ * svgimage component ([f369605](https://github.com/ho-nl/m2-pwa/commit/f3696051e381a24c543fd24e199da5b17f9e124f))
156
+ * **theme:** restructured fonts and applied to home and category page ([6adf5f1](https://github.com/ho-nl/m2-pwa/commit/6adf5f11321bdfbf499125f1161c5abf5a1bfe4a))
157
+ * upgrade to node 14 ([d079a75](https://github.com/ho-nl/m2-pwa/commit/d079a751e9bfd8dc7f5009d2c9f31c336a0c96ab))
158
+ * upgraded to nextjs 11 ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
159
+ * use official nextjs image endpoint ([0e76ab4](https://github.com/ho-nl/m2-pwa/commit/0e76ab4cece15d4d6f192cb938588a34abaebe8a))
160
+ * useFormMutationCart and simpler imports ([012f090](https://github.com/ho-nl/m2-pwa/commit/012f090e8f54d09f35d393c61ad1e2319f5a90ff))
161
+ * useFormPersist, useFormAutoSubmit, useFormGqlMutation everywhere ([e591285](https://github.com/ho-nl/m2-pwa/commit/e5912854babee87c8efc5b7c00455d61b301aad3))
162
+ * working on EmailForm ([f16141f](https://github.com/ho-nl/m2-pwa/commit/f16141f8cc0dfeaef8dee2a3e635bda898550a51))
163
+ * working on payment implementation contract ([bc3a41a](https://github.com/ho-nl/m2-pwa/commit/bc3a41a3de25c197bd65bdb68640c82f83c4698a))
164
+ * working on shipping-method step ([d89a072](https://github.com/ho-nl/m2-pwa/commit/d89a072298baa20bfa0ac7a2a885c40728a23edb))
165
+ * working on useMergeCarts ([e39360c](https://github.com/ho-nl/m2-pwa/commit/e39360cf33dbca351d57b0186117248fa102f6c8))
166
+
167
+
168
+ ### Reverts
169
+
170
+ * Revert "chore: upgrade @apollo/client" ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
171
+
172
+
173
+
174
+ ## 2.0.8 (2020-10-28)
175
+
176
+
177
+ ### Bug Fixes
178
+
179
+ * make sure themes extensions are found ([5aa18db](https://github.com/ho-nl/m2-pwa/commit/5aa18db514fd2e2f50681367e39523f8e742ece0))
180
+
181
+
182
+ ### Features
183
+
184
+ * added generated graphql.ts files ([3e44415](https://github.com/ho-nl/m2-pwa/commit/3e44415b018e74b502e9e98479aa5e84041f337d))
185
+ * split into packages ([2ee7fd6](https://github.com/ho-nl/m2-pwa/commit/2ee7fd6c0056f467d114f04d92c6c0ddf622d151))
186
+
187
+
188
+ ### BREAKING CHANGES
189
+
190
+ * huge folder structure refactor, please read README to reinstall
191
+
192
+
193
+
194
+
195
+
196
+ # Change Log
197
+
198
+ All notable changes to this project will be documented in this file. See
199
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
200
+
201
+ # [2.107.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.106.6...@graphcommerce/magento-cart@2.107.0) (2021-09-24)
202
+
203
+ ### Bug Fixes
204
+
205
+ - cart cache not up-to-date
206
+ ([aae4d30](https://github.com/ho-nl/m2-pwa/commit/aae4d302e320475d28a356ec304ea6afb64c3080))
207
+ - **cart-summary:** spacings
208
+ ([73b7379](https://github.com/ho-nl/m2-pwa/commit/73b7379731bd1fe21c27d9b12f29b518efe73dce))
209
+
210
+ ### Features
211
+
212
+ - edit billing address on checkout payment step
213
+ ([96a5719](https://github.com/ho-nl/m2-pwa/commit/96a5719437616006efb2588c3516d3f2608c1fb8))
214
+
215
+ # [2.106.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.105.9...@graphcommerce/magento-cart@2.106.0) (2021-09-01)
216
+
217
+ # [2.106.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.105.9...@graphcommerce/magento-cart@2.106.0) (2021-09-01)
218
+
219
+ ### Features
220
+
221
+ - **framer-scroller:** implemented the scroller on all pages
222
+ ([73fb518](https://github.com/ho-nl/m2-pwa/commit/73fb518eff74edb2b3212e892b3d8cc2b088011b))
223
+
224
+ ## [2.105.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.105.4...@graphcommerce/magento-cart@2.105.5) (2021-08-18)
225
+
226
+ ### Bug Fixes
227
+
228
+ - **cart:** display prices with taxes for specific store views
229
+ ([fd25541](https://github.com/ho-nl/m2-pwa/commit/fd25541646c41111f5ea53822d244591cb08b199))
230
+ - display prices excl and incl tax
231
+ ([0d41135](https://github.com/ho-nl/m2-pwa/commit/0d411350e4621928411c2800be6ea02c6125049a))
232
+ - make sure the session token gets deactivated when trying to merge carts when
233
+ it cant
234
+ ([2a9416b](https://github.com/ho-nl/m2-pwa/commit/2a9416b5c9efcd28a27f4183922ab419f62ea767))
235
+
236
+ ## [2.105.3](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.105.2...@graphcommerce/magento-cart@2.105.3) (2021-08-13)
237
+
238
+ ### Bug Fixes
239
+
240
+ - **cart-item-summary:** remove unnecessary animate presence
241
+ ([95a0750](https://github.com/ho-nl/m2-pwa/commit/95a0750a3d27fa206a7f88635cbfbcfd8034957c))
242
+ - **cart-item-summary:** thumbnail image bottom spacing
243
+ ([f761a42](https://github.com/ho-nl/m2-pwa/commit/f761a4221f65f3c8897cc36298ed973bccbd3266))
244
+
245
+ ## [2.105.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.105.1...@graphcommerce/magento-cart@2.105.2) (2021-08-13)
246
+
247
+ ### Bug Fixes
248
+
249
+ - cart didn't use the AppShellTitle
250
+ ([65a58c8](https://github.com/ho-nl/m2-pwa/commit/65a58c8dc7d39cd4c9cb31c4005828376c9e7ad1))
251
+
252
+ # [2.105.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.104.2...@graphcommerce/magento-cart@2.105.0) (2021-08-13)
253
+
254
+ ### Features
255
+
256
+ - coupon form on payment page
257
+ ([a163961](https://github.com/ho-nl/m2-pwa/commit/a1639617be756b357177fcce255cf662c5314499))
258
+
259
+ # [2.104.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.103.3...@graphcommerce/magento-cart@2.104.0) (2021-08-12)
260
+
261
+ ### Features
262
+
263
+ - upgraded to nextjs 11
264
+ ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
265
+
266
+ ## [2.103.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.103.1...@graphcommerce/magento-cart@2.103.2) (2021-08-09)
267
+
268
+ ### Bug Fixes
269
+
270
+ - use SvgImageSimple for multiple areas
271
+ ([bf851a6](https://github.com/ho-nl/m2-pwa/commit/bf851a6740e1956a78f457c2d90904ee2f65da2f))
272
+
273
+ ### Reverts
274
+
275
+ - Revert "chore: upgrade @apollo/client"
276
+ ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
277
+
278
+ # [2.103.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.102.6...@graphcommerce/magento-cart@2.103.0) (2021-08-06)
279
+
280
+ ### Features
281
+
282
+ - **theme:** restructured fonts and applied to home and category page
283
+ ([6adf5f1](https://github.com/ho-nl/m2-pwa/commit/6adf5f11321bdfbf499125f1161c5abf5a1bfe4a))
284
+
285
+ ## [2.102.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.102.4...@graphcommerce/magento-cart@2.102.5) (2021-08-03)
286
+
287
+ ### Bug Fixes
288
+
289
+ - coupon animations, spacing, rippl;ie
290
+ ([cef3a08](https://github.com/ho-nl/m2-pwa/commit/cef3a08d0545947518873c5257c59fc1b98f1a21))
291
+ - discount error when removing a discount
292
+ ([bb6fae3](https://github.com/ho-nl/m2-pwa/commit/bb6fae3ccee694d6a19d9de01febd4cc0166b49c))
293
+
294
+ # [2.102.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.101.8...@graphcommerce/magento-cart@2.102.0) (2021-07-26)
295
+
296
+ ### Features
297
+
298
+ - **playwright:** added new playwright package to enable browser testing
299
+ ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
300
+
301
+ ## [2.101.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.101.5...@graphcommerce/magento-cart@2.101.6) (2021-07-23)
302
+
303
+ ### Bug Fixes
304
+
305
+ - adjust imports to correct ones
306
+ ([c6e3092](https://github.com/ho-nl/m2-pwa/commit/c6e3092569d1c49fe138b3810704da8e04acbbe2))
307
+
308
+ # [2.101.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@2.100.10...@graphcommerce/magento-cart@2.101.0) (2021-07-20)
309
+
310
+ ### Bug Fixes
311
+
312
+ - cart fab box shadow animation
313
+ ([4c73e42](https://github.com/ho-nl/m2-pwa/commit/4c73e423a920f6485f72b24141cccda010a35ab7))
314
+ - ignore md files from triggering version updates
315
+ ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
316
+
317
+ ### Features
318
+
319
+ - cart fab on mobile
320
+ ([bd2e9eb](https://github.com/ho-nl/m2-pwa/commit/bd2e9ebe056ba9a81b5c7228f1e5be57171266f4))
321
+ - full page ui back and menu button position swap
322
+ ([93b3419](https://github.com/ho-nl/m2-pwa/commit/93b34197947d133f4d1480c4ce68a0302201b858))
323
+ - full page ui desktop variant
324
+ ([a70f301](https://github.com/ho-nl/m2-pwa/commit/a70f3013da36fa131f82fb44457b107fb7705df6))
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Magento Cart
2
+
3
+ ## How to build a proper checkout flow
4
+
5
+ - Fragment: GraphQL Fragment
6
+ - Query: GraphQL Query
7
+ - Mutation: GraphQL Mutation
8
+ - FormComponent: GraphQL Form Component
9
+ - Contains a Mutation
10
+ - Contains a useGqlMutationForm
11
+ - FragmentComponent: GraphQL Fragment Component
12
+ - Renders a Fragment
13
+
14
+ There is no such thing:
15
+
16
+ - QueryComponent
17
+
18
+ ## Cart Story
19
+
20
+ We might have the following setup:
21
+
22
+ - ProductPage
23
+ - GraphQL Fragment Components:
24
+ - CartCount
25
+ - CartCountFragment.graphql
26
+ - MyCustomInlineCart
27
+ - MyCustomInlineCartFragment.graphql
28
+ - GraphQL Form Components:
29
+ - AddToCartForm
30
+ - AddToCartFormMutation.graphql
31
+ - AddConfigurableToCartForm
32
+ - AddConfigurableToCartFormMutation.graphql
33
+ - CartPage
34
+ - GraphQL Fragment Components
35
+ - CartItems
36
+ - CartItemsFragment.graphql
37
+ - CartTotals
38
+ - CartTotalsFragment.graphql
39
+ - MyCustomCartThingy
40
+ - MyCustomCartThingyFragment.graphql
41
+ - GraphQL Form Components:
42
+ - CartDiscount
43
+ - CartDiscountFragment.graphql
44
+ - CartDiscountMutation.graphql
45
+ - ShippingPage
46
+ - GraphQL Form Components:
47
+ - ShippingAddressForm
48
+ - ShippingAddressFormFragment.graphql
49
+ - ShippingAddressFormMutation.graphql
50
+
51
+ What do we want:
52
+
53
+ When calling `AddToCartFormMutation` or `AddConfigurableToCartForm` I want the
54
+ `CartCountFragment` and `MyCustomInlineCartFragment` to update.
55
+
56
+ - A Mutation **must not** request fields outside of the scope of the package it
57
+ retains in.
58
+
59
+ ## Colocation of fragments
60
+
61
+ Apollo suggests to use the colocation of Fragments
62
+ https://www.apollographql.com/docs/react/data/fragments/#creating-colocated-fragments
63
+
64
+ This creates a top-down dependency burden while generating components. On the
65
+ top level, you need to know all Fragments that are going to be used. This
66
+ requires deep knowledge of the whole data tree.
67
+
68
+ We'd like to be able to follow Depency Inversion principle "Depend upon
69
+ abstractions, not concretions."
70
+
71
+ ## Fragment interfaces
72
+
73
+ By introducing the concept of interfaces for fragments we can merge multiple
74
+ fragments into one:
75
+
76
+ ```graphql
77
+ @extend()
78
+ fragment AllPages on Cart {}
79
+
80
+ @extend()
81
+ fragment CartPage on Cart {}
82
+
83
+ @extend()
84
+ fragment ShippingPage on Cart {}
85
+
86
+ @extend()
87
+ fragment PaymentPage on Cart {}
88
+ ```
89
+
90
+ On the CartHeader
91
+
92
+ ```graphql
93
+
94
+ @extend('AllPages')
95
+ fragment CartHeaderFragment on Cart {}
96
+ ```
97
+
98
+ We create 'mergeable fragments', when multiple fragments with the same name are
99
+ encountered, we merge those fragments into one.
100
+
101
+ Since the Fragments that are rendered differ based on a specific page we in
102
+ theory can't fetch the absolute minimal.
@@ -0,0 +1,127 @@
1
+ import { TypedDocumentNode, useQuery } from '@apollo/client'
2
+ import { Divider, makeStyles, Theme, Typography } from '@material-ui/core'
3
+ import { ProductInterface } from '@graphcommerce/graphql'
4
+ import { CustomerTokenDocument } from '@graphcommerce/magento-customer'
5
+ import { Money, MoneyProps } from '@graphcommerce/magento-store'
6
+ import {
7
+ Button,
8
+ ButtonProps,
9
+ MessageSnackbar,
10
+ SvgImage,
11
+ TextInputNumber,
12
+ iconCheckmark,
13
+ iconChevronRight,
14
+ } from '@graphcommerce/next-ui'
15
+ import { DeepPartial, UnpackNestedValue, Path } from '@graphcommerce/react-hook-form'
16
+ import PageLink from 'next/link'
17
+ import React from 'react'
18
+ import { useFormGqlMutationCart } from '../../hooks/useFormGqlMutationCart'
19
+ import ApolloCartErrorAlert from '../ApolloCartError/ApolloCartErrorAlert'
20
+
21
+ const useStyles = makeStyles(
22
+ (theme: Theme) => ({
23
+ button: {
24
+ marginTop: theme.spacings.sm,
25
+ width: '100%',
26
+ },
27
+ messageIcon: {
28
+ marginBottom: '-2px',
29
+ marginRight: 5,
30
+ },
31
+ price: {
32
+ fontWeight: theme.typography.fontWeightBold,
33
+ margin: `${theme.spacings.sm} 0`,
34
+ },
35
+ divider: {
36
+ margin: `${theme.spacings.xs} 0`,
37
+ },
38
+ }),
39
+ { name: 'AddToCart' },
40
+ )
41
+
42
+ export type AddToCartProps = React.ComponentProps<typeof AddToCartButton>
43
+
44
+ export default function AddToCartButton<Q, V extends { cartId: string; [index: string]: unknown }>(
45
+ props: Pick<ProductInterface, 'name'> & {
46
+ mutation: TypedDocumentNode<Q, V>
47
+ variables: Omit<V, 'cartId'>
48
+ name: string
49
+ price: MoneyProps
50
+ children?: React.ReactNode
51
+ } & Omit<ButtonProps, 'type' | 'name'>,
52
+ ) {
53
+ const { name, children, mutation, variables, price, ...buttonProps } = props
54
+
55
+ const form = useFormGqlMutationCart<Q, V>(mutation, {
56
+ defaultValues: variables as UnpackNestedValue<DeepPartial<V>>,
57
+ })
58
+
59
+ const { handleSubmit, formState, error, muiRegister, required } = form
60
+ const submitHandler = handleSubmit(() => {})
61
+ const classes = useStyles()
62
+
63
+ const { data: tokenQuery } = useQuery(CustomerTokenDocument)
64
+
65
+ return (
66
+ <form onSubmit={submitHandler} noValidate>
67
+ <Divider className={classes.divider} />
68
+
69
+ <Typography variant='h4' className={classes.price}>
70
+ <Money {...price} />
71
+ </Typography>
72
+
73
+ <TextInputNumber
74
+ variant='outlined'
75
+ error={formState.isSubmitted && !!formState.errors.quantity}
76
+ required={required.quantity}
77
+ inputProps={{ min: 1 }}
78
+ {...muiRegister('quantity' as Path<V>, { required: required.quantity })}
79
+ helperText={formState.isSubmitted && formState.errors.quantity}
80
+ disabled={formState.isSubmitting}
81
+ size='small'
82
+ />
83
+ {children}
84
+ <Button
85
+ type='submit'
86
+ classes={{ root: classes.button }}
87
+ loading={formState.isSubmitting}
88
+ color='primary'
89
+ variant='pill'
90
+ size='large'
91
+ {...buttonProps}
92
+ >
93
+ Add to Cart
94
+ </Button>
95
+
96
+ <ApolloCartErrorAlert error={error} />
97
+
98
+ <MessageSnackbar
99
+ open={!formState.isSubmitting && formState.isSubmitSuccessful && !error?.message}
100
+ variant='pill'
101
+ color='default'
102
+ action={
103
+ <PageLink href='/cart'>
104
+ <Button
105
+ size='medium'
106
+ variant='pill'
107
+ color='secondary'
108
+ endIcon={<SvgImage src={iconChevronRight} shade='inverted' alt='chevron right' />}
109
+ >
110
+ View shopping cart
111
+ </Button>
112
+ </PageLink>
113
+ }
114
+ >
115
+ <div>
116
+ <SvgImage
117
+ src={iconCheckmark}
118
+ loading='eager'
119
+ alt='checkmark'
120
+ className={classes.messageIcon}
121
+ />
122
+ <strong>{name}</strong>&nbsp;has been added to your shopping cart!
123
+ </div>
124
+ </MessageSnackbar>
125
+ </form>
126
+ )
127
+ }
@@ -0,0 +1,36 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { CustomerTokenDocument } from '@graphcommerce/magento-customer'
3
+ import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
4
+ import { ApolloErrorAlert, ApolloErrorAlertProps, Button } from '@graphcommerce/next-ui'
5
+ import Link from 'next/link'
6
+ import React from 'react'
7
+ import { useClearCurrentCartId } from '../../hooks/useClearCurrentCartId'
8
+
9
+ export type ApolloCartErrorAlertProps = ApolloErrorAlertProps
10
+
11
+ export default function ApolloCartErrorAlert(props: ApolloCartErrorAlertProps) {
12
+ const { error } = props
13
+ const clear = useClearCurrentCartId()
14
+ const token = useQuery(CustomerTokenDocument).data?.customerToken
15
+
16
+ let action: JSX.Element | undefined
17
+
18
+ const [, noSuchEntity] = graphqlErrorByCategory({ category: 'graphql-no-such-entity', error })
19
+ action = noSuchEntity && clear ? <Button onClick={clear}>Reset Cart</Button> : undefined
20
+
21
+ const [, authorizationError] = graphqlErrorByCategory({
22
+ category: 'graphql-authorization',
23
+ error,
24
+ mask: token?.token ? 'Please reauthenticate and try again' : 'You must sign in to continue',
25
+ })
26
+ action =
27
+ authorizationError && clear ? (
28
+ <Link href='/account/signin' passHref>
29
+ <Button>Sign in</Button>
30
+ </Link>
31
+ ) : (
32
+ action
33
+ )
34
+
35
+ return <ApolloErrorAlert {...props} graphqlErrorAlertProps={{ action }} />
36
+ }
@@ -0,0 +1,12 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
5
+
6
+ export const CartFabDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"CartFab"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"total_quantity"}}]}}]}}]} as unknown as DocumentNode<CartFabQuery, CartFabQueryVariables>;
7
+ export type CartFabQueryVariables = Types.Exact<{
8
+ cartId: Types.Scalars['String'];
9
+ }>;
10
+
11
+
12
+ export type CartFabQuery = { cart?: Types.Maybe<{ id: string, total_quantity: number }> };
@@ -0,0 +1,6 @@
1
+ query CartFab($cartId: String!) {
2
+ cart(cart_id: $cartId) {
3
+ id
4
+ ...CartTotalQuantity
5
+ }
6
+ }