@graphcommerce/magento-cart 3.0.3 → 3.0.7
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 +11 -0
- package/components/CartFab/CartFab.tsx +1 -1
- package/components/CartItemSummary/index.tsx +1 -1
- package/components/CartStartCheckout/CartStartCheckout.tsx +1 -1
- package/components/CartSummary/index.tsx +1 -1
- package/components/CartTotals/CartTotals.tsx +1 -1
- package/components/EmptyCart/EmptyCart.tsx +1 -1
- package/components/index.ts +0 -3
- package/hooks/useFormGqlMutationCart.ts +0 -1
- package/package.json +13 -13
- package/components/AddToCartButton/AddToCartButton.tsx +0 -127
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(
|
package/components/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/magento-cart",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
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.
|
|
17
|
+
"@graphcommerce/eslint-config-pwa": "^3.0.4",
|
|
18
18
|
"@graphcommerce/prettier-config-pwa": "^3.0.2",
|
|
19
|
-
"@graphcommerce/typescript-config-pwa": "^3.0
|
|
19
|
+
"@graphcommerce/typescript-config-pwa": "^3.1.0",
|
|
20
20
|
"@playwright/test": "^1.15.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@apollo/client": "^3.3.21",
|
|
24
|
-
"@graphcommerce/framer-scroller": "^0.2.
|
|
25
|
-
"@graphcommerce/graphql": "^2.103.
|
|
26
|
-
"@graphcommerce/image": "^2.104.
|
|
27
|
-
"@graphcommerce/magento-cart-address": "^2.103.
|
|
28
|
-
"@graphcommerce/magento-customer": "^3.0.
|
|
29
|
-
"@graphcommerce/magento-graphql": "^2.103.
|
|
30
|
-
"@graphcommerce/magento-store": "^3.0.
|
|
31
|
-
"@graphcommerce/next-ui": "^3.0.
|
|
32
|
-
"@graphcommerce/react-hook-form": "^2.102.
|
|
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.7",
|
|
28
|
+
"@graphcommerce/magento-customer": "^3.0.7",
|
|
29
|
+
"@graphcommerce/magento-graphql": "^2.103.4",
|
|
30
|
+
"@graphcommerce/magento-store": "^3.0.7",
|
|
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": "
|
|
42
|
+
"gitHead": "e22e75eb7fb075dece93b268a9b3799c4e1e9cea"
|
|
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> has been added to your shopping cart!
|
|
123
|
-
</div>
|
|
124
|
-
</MessageSnackbar>
|
|
125
|
-
</form>
|
|
126
|
-
)
|
|
127
|
-
}
|