@graphcommerce/magento-cart 3.0.2 → 3.0.6

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.0.4...@graphcommerce/magento-cart@3.0.5) (2021-09-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add to cart button ([8a69454](https://github.com/ho-nl/m2-pwa/commit/8a69454b1372a563020e1ef1b7c50363b8d29717))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [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
18
 
8
19
  **Note:** Version bump only for package @graphcommerce/magento-cart
@@ -1,10 +1,10 @@
1
- import { Fab, FabProps, NoSsr } from '@material-ui/core'
2
1
  import {
3
2
  iconShoppingBag,
4
3
  StyledBadge,
5
4
  SvgImageSimple,
6
5
  useFixedFabAnimation,
7
6
  } from '@graphcommerce/next-ui'
7
+ import { Fab, FabProps, NoSsr } from '@material-ui/core'
8
8
  import { m } from 'framer-motion'
9
9
  import PageLink from 'next/link'
10
10
  import React from 'react'
@@ -1,4 +1,3 @@
1
- import { Divider, makeStyles, Theme } from '@material-ui/core'
2
1
  import { Scroller, ScrollerButton, ScrollerProvider } from '@graphcommerce/framer-scroller'
3
2
  import { Image } from '@graphcommerce/image'
4
3
  import {
@@ -9,6 +8,7 @@ import {
9
8
  SvgImageSimple,
10
9
  UseStyles,
11
10
  } from '@graphcommerce/next-ui'
11
+ import { Divider, makeStyles, Theme } from '@material-ui/core'
12
12
  import clsx from 'clsx'
13
13
  import React from 'react'
14
14
  import { useCartQuery } from '../../hooks'
@@ -1,6 +1,6 @@
1
- import { makeStyles, Theme } from '@material-ui/core'
2
1
  import { Money } from '@graphcommerce/magento-store'
3
2
  import { Button, iconChevronRight, responsiveVal, SvgImage } from '@graphcommerce/next-ui'
3
+ import { makeStyles, Theme } from '@material-ui/core'
4
4
  import PageLink from 'next/link'
5
5
  import React, { PropsWithChildren } from 'react'
6
6
  import { CartStartCheckoutFragment } from './CartStartCheckout.gql'
@@ -1,6 +1,6 @@
1
- import { Link, makeStyles, Theme, Typography } from '@material-ui/core'
2
1
  import { CartAddressMultiLine } from '@graphcommerce/magento-cart-address'
3
2
  import { SectionContainer, UseStyles } from '@graphcommerce/next-ui'
3
+ import { Link, makeStyles, Theme, Typography } from '@material-ui/core'
4
4
  import PageLink from 'next/link'
5
5
  import React from 'react'
6
6
  import { useCartQuery } from '../../hooks'
@@ -1,6 +1,6 @@
1
- import { Divider, makeStyles, Theme } from '@material-ui/core'
2
1
  import { Money, MoneyProps } from '@graphcommerce/magento-store'
3
2
  import { AnimatedRow, UseStyles } from '@graphcommerce/next-ui'
3
+ import { Divider, makeStyles, Theme } from '@material-ui/core'
4
4
  import clsx from 'clsx'
5
5
  import { AnimatePresence } from 'framer-motion'
6
6
  import React from 'react'
@@ -1,5 +1,5 @@
1
- import { makeStyles, Theme, Typography } from '@material-ui/core'
2
1
  import { responsiveVal, SvgImage, iconSadShoppingBag } from '@graphcommerce/next-ui'
2
+ import { makeStyles, Theme, Typography } from '@material-ui/core'
3
3
  import React from 'react'
4
4
 
5
5
  const useStyles = makeStyles(
@@ -1,6 +1,3 @@
1
- export * from './AddToCartButton/AddToCartButton'
2
- export { default as AddToCartButton } from './AddToCartButton/AddToCartButton'
3
-
4
1
  export * from './CartFab/CartFab'
5
2
  export { default as CartFab } from './CartFab/CartFab'
6
3
 
@@ -1,5 +1,4 @@
1
1
  import { MutationHookOptions, TypedDocumentNode } from '@apollo/client'
2
- import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
2
  import {
4
3
  useFormGqlMutation,
5
4
  UseFormGqlMutationReturn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-cart",
3
- "version": "3.0.2",
3
+ "version": "3.0.6",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
6
  "browserslist": [
@@ -14,22 +14,22 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@graphcommerce/browserslist-config-pwa": "^3.0.1",
17
- "@graphcommerce/eslint-config-pwa": "^3.0.1",
18
- "@graphcommerce/prettier-config-pwa": "^3.0.1",
19
- "@graphcommerce/typescript-config-pwa": "^3.0.1",
20
- "@playwright/test": "^1.14.1"
17
+ "@graphcommerce/eslint-config-pwa": "^3.0.4",
18
+ "@graphcommerce/prettier-config-pwa": "^3.0.2",
19
+ "@graphcommerce/typescript-config-pwa": "^3.1.0",
20
+ "@playwright/test": "^1.15.0"
21
21
  },
22
22
  "dependencies": {
23
23
  "@apollo/client": "^3.3.21",
24
- "@graphcommerce/framer-scroller": "^0.2.2",
25
- "@graphcommerce/graphql": "^2.103.1",
26
- "@graphcommerce/image": "^2.104.2",
27
- "@graphcommerce/magento-cart-address": "^2.103.2",
28
- "@graphcommerce/magento-customer": "^3.0.2",
29
- "@graphcommerce/magento-graphql": "^2.103.1",
30
- "@graphcommerce/magento-store": "^3.0.2",
31
- "@graphcommerce/next-ui": "^3.0.2",
32
- "@graphcommerce/react-hook-form": "^2.102.1",
24
+ "@graphcommerce/framer-scroller": "^0.2.5",
25
+ "@graphcommerce/graphql": "^2.103.4",
26
+ "@graphcommerce/image": "^2.104.5",
27
+ "@graphcommerce/magento-cart-address": "^2.103.6",
28
+ "@graphcommerce/magento-customer": "^3.0.6",
29
+ "@graphcommerce/magento-graphql": "^2.103.4",
30
+ "@graphcommerce/magento-store": "^3.0.6",
31
+ "@graphcommerce/next-ui": "^3.0.6",
32
+ "@graphcommerce/react-hook-form": "^2.102.4",
33
33
  "@graphql-typed-document-node/core": "^3.1.0",
34
34
  "@material-ui/core": "^4.12.3",
35
35
  "@material-ui/lab": "^4.0.0-alpha.60",
@@ -39,5 +39,5 @@
39
39
  "react": "^17.0.2",
40
40
  "react-dom": "^17.0.2"
41
41
  },
42
- "gitHead": "05d36d5da1bee914defba6d0ddb50d7fe1932866"
42
+ "gitHead": "cf2b61fa96aca043ff841b018334ca8c28e5e6cf"
43
43
  }
@@ -1,127 +0,0 @@
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
- }