@graphcommerce/magento-product 9.0.0-canary.60 → 9.0.0-canary.62
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
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 9.0.0-canary.62
|
4
|
+
|
5
|
+
## 9.0.0-canary.61
|
6
|
+
|
7
|
+
### Minor Changes
|
8
|
+
|
9
|
+
- [#2327](https://github.com/graphcommerce-org/graphcommerce/pull/2327) [`0935c33`](https://github.com/graphcommerce-org/graphcommerce/commit/0935c33ad08c963b2a406c92739590ac6acce7d2) - Move render logic from AddProductsToCartSnackbar to AddProductsToCartSnackbarMessage so this can be reused outside of AddProductsToCartForm ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
10
|
+
|
3
11
|
## 9.0.0-canary.60
|
4
12
|
|
5
13
|
## 9.0.0-canary.59
|
@@ -1,19 +1,7 @@
|
|
1
1
|
import { useFormState } from '@graphcommerce/ecommerce-ui'
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
Button,
|
5
|
-
ErrorSnackbar,
|
6
|
-
ErrorSnackbarProps,
|
7
|
-
iconChevronRight,
|
8
|
-
IconSvg,
|
9
|
-
ListFormat,
|
10
|
-
MessageSnackbar,
|
11
|
-
MessageSnackbarProps,
|
12
|
-
nonNullable,
|
13
|
-
useLocale,
|
14
|
-
} from '@graphcommerce/next-ui'
|
15
|
-
import { Plural, Trans } from '@lingui/macro'
|
2
|
+
import { ErrorSnackbarProps, MessageSnackbarProps, nonNullable } from '@graphcommerce/next-ui'
|
16
3
|
import { useMemo } from 'react'
|
4
|
+
import { AddProductsToCartSnackbarMessage } from './AddProductsToCartSnackbarMessage'
|
17
5
|
import { findAddedItems } from './findAddedItems'
|
18
6
|
import { toUserErrors } from './toUserErrors'
|
19
7
|
import { useFormAddProductsToCart } from './useFormAddProductsToCart'
|
@@ -27,9 +15,9 @@ export type AddProductsToCartSnackbarProps = {
|
|
27
15
|
export function AddProductsToCartSnackbar(props: AddProductsToCartSnackbarProps) {
|
28
16
|
const { errorSnackbar, successSnackbar, disableSuccessSnackbar } = props
|
29
17
|
const { error, data, redirect, control, submittedVariables } = useFormAddProductsToCart()
|
18
|
+
|
30
19
|
const formState = useFormState({ control })
|
31
20
|
|
32
|
-
const locale = useLocale()
|
33
21
|
const userErrors = toUserErrors(data)
|
34
22
|
|
35
23
|
const showSuccess =
|
@@ -45,60 +33,14 @@ export function AddProductsToCartSnackbar(props: AddProductsToCartSnackbarProps)
|
|
45
33
|
[data, submittedVariables],
|
46
34
|
)
|
47
35
|
|
48
|
-
const showErrorSnackbar = userErrors.length > 0
|
49
|
-
|
50
36
|
return (
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
{
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
{showSuccess && (
|
61
|
-
<MessageSnackbar
|
62
|
-
variant='pill'
|
63
|
-
severity='success'
|
64
|
-
{...successSnackbar}
|
65
|
-
open={showSuccess}
|
66
|
-
action={
|
67
|
-
<Button
|
68
|
-
href='/cart'
|
69
|
-
id='view-shopping-cart-button'
|
70
|
-
size='medium'
|
71
|
-
variant='pill'
|
72
|
-
color='secondary'
|
73
|
-
endIcon={<IconSvg src={iconChevronRight} />}
|
74
|
-
sx={{ display: 'flex' }}
|
75
|
-
>
|
76
|
-
<Trans>View shopping cart</Trans>
|
77
|
-
</Button>
|
78
|
-
}
|
79
|
-
>
|
80
|
-
<Plural
|
81
|
-
value={addedItems.length}
|
82
|
-
one={
|
83
|
-
<Trans>
|
84
|
-
<ListFormat listStyle='long' type='conjunction'>
|
85
|
-
{addedItems.map((item) => item?.itemInCart?.product.name).filter(nonNullable)}
|
86
|
-
</ListFormat>{' '}
|
87
|
-
has been added to your shopping cart
|
88
|
-
</Trans>
|
89
|
-
}
|
90
|
-
two={
|
91
|
-
<Trans>
|
92
|
-
<ListFormat listStyle='long' type='conjunction'>
|
93
|
-
{addedItems.map((item) => item?.itemInCart?.product.name).filter(nonNullable)}
|
94
|
-
</ListFormat>{' '}
|
95
|
-
have been added to your shopping cart!
|
96
|
-
</Trans>
|
97
|
-
}
|
98
|
-
other={<Trans># products have been added to your shopping cart!</Trans>}
|
99
|
-
/>
|
100
|
-
</MessageSnackbar>
|
101
|
-
)}
|
102
|
-
</>
|
37
|
+
<AddProductsToCartSnackbarMessage
|
38
|
+
error={error}
|
39
|
+
showSuccess={showSuccess}
|
40
|
+
userErrors={data?.addProductsToCart?.user_errors.filter(nonNullable)}
|
41
|
+
addedItems={addedItems.map((item) => item.itemInCart?.product.name).filter(nonNullable)}
|
42
|
+
errorSnackbar={errorSnackbar}
|
43
|
+
successSnackbar={successSnackbar}
|
44
|
+
/>
|
103
45
|
)
|
104
46
|
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { ApolloError } from '@graphcommerce/graphql'
|
2
|
+
import { CartUserInputError } from '@graphcommerce/graphql-mesh'
|
3
|
+
import { ApolloCartErrorSnackbar } from '@graphcommerce/magento-cart'
|
4
|
+
import {
|
5
|
+
Button,
|
6
|
+
ErrorSnackbar,
|
7
|
+
ErrorSnackbarProps,
|
8
|
+
IconSvg,
|
9
|
+
ListFormat,
|
10
|
+
MessageSnackbar,
|
11
|
+
MessageSnackbarProps,
|
12
|
+
iconChevronRight,
|
13
|
+
} from '@graphcommerce/next-ui'
|
14
|
+
import { Plural, Trans } from '@lingui/macro'
|
15
|
+
|
16
|
+
export type AddProductsToCartSnackbarMessageProps = {
|
17
|
+
errorSnackbar?: Omit<ErrorSnackbarProps, 'open'>
|
18
|
+
successSnackbar?: Omit<MessageSnackbarProps, 'open' | 'action'>
|
19
|
+
error?: ApolloError
|
20
|
+
userErrors?: Pick<CartUserInputError, 'message'>[]
|
21
|
+
showSuccess: boolean
|
22
|
+
addedItems: string[]
|
23
|
+
}
|
24
|
+
|
25
|
+
export function AddProductsToCartSnackbarMessage(props: AddProductsToCartSnackbarMessageProps) {
|
26
|
+
const { errorSnackbar, successSnackbar, error, userErrors, showSuccess, addedItems } = props
|
27
|
+
|
28
|
+
const showErrorSnackbar = !!userErrors?.length
|
29
|
+
|
30
|
+
return (
|
31
|
+
<>
|
32
|
+
{error && <ApolloCartErrorSnackbar error={error} />}
|
33
|
+
|
34
|
+
{showErrorSnackbar && (
|
35
|
+
<ErrorSnackbar variant='pill' severity='error' {...errorSnackbar} open={showErrorSnackbar}>
|
36
|
+
<>{userErrors.map((e) => e?.message).join(', ')}</>
|
37
|
+
</ErrorSnackbar>
|
38
|
+
)}
|
39
|
+
|
40
|
+
{showSuccess && (
|
41
|
+
<MessageSnackbar
|
42
|
+
variant='pill'
|
43
|
+
severity='success'
|
44
|
+
{...successSnackbar}
|
45
|
+
open={showSuccess}
|
46
|
+
action={
|
47
|
+
<Button
|
48
|
+
href='/cart'
|
49
|
+
id='view-shopping-cart-button'
|
50
|
+
size='medium'
|
51
|
+
variant='pill'
|
52
|
+
color='secondary'
|
53
|
+
endIcon={<IconSvg src={iconChevronRight} />}
|
54
|
+
sx={{ display: 'flex' }}
|
55
|
+
>
|
56
|
+
<Trans>View shopping cart</Trans>
|
57
|
+
</Button>
|
58
|
+
}
|
59
|
+
>
|
60
|
+
<Plural
|
61
|
+
value={addedItems.length}
|
62
|
+
one={
|
63
|
+
<Trans>
|
64
|
+
<ListFormat listStyle='long' type='conjunction'>
|
65
|
+
{addedItems.map((item) => item)}
|
66
|
+
</ListFormat>{' '}
|
67
|
+
has been added to your shopping cart
|
68
|
+
</Trans>
|
69
|
+
}
|
70
|
+
two={
|
71
|
+
<Trans>
|
72
|
+
<ListFormat listStyle='long' type='conjunction'>
|
73
|
+
{addedItems.map((item) => item)}
|
74
|
+
</ListFormat>{' '}
|
75
|
+
have been added to your shopping cart!
|
76
|
+
</Trans>
|
77
|
+
}
|
78
|
+
other={<Trans># products have been added to your shopping cart!</Trans>}
|
79
|
+
/>
|
80
|
+
</MessageSnackbar>
|
81
|
+
)}
|
82
|
+
</>
|
83
|
+
)
|
84
|
+
}
|
@@ -4,6 +4,7 @@ export * from './AddProductsToCartError'
|
|
4
4
|
export * from './AddProductsToCartFab'
|
5
5
|
export * from './AddProductsToCartForm'
|
6
6
|
export * from './AddProductsToCartSnackbar'
|
7
|
+
export * from './AddProductsToCartSnackbarMessage'
|
7
8
|
export * from './AddProductsToCartQuantity'
|
8
9
|
export * from './useAddProductsToCartAction'
|
9
10
|
export * from './useFormAddProductsToCart'
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@graphcommerce/magento-product",
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
5
|
-
"version": "9.0.0-canary.
|
5
|
+
"version": "9.0.0-canary.62",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -18,19 +18,19 @@
|
|
18
18
|
"typescript": "5.5.3"
|
19
19
|
},
|
20
20
|
"peerDependencies": {
|
21
|
-
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
23
|
-
"@graphcommerce/framer-next-pages": "^9.0.0-canary.
|
24
|
-
"@graphcommerce/framer-scroller": "^9.0.0-canary.
|
25
|
-
"@graphcommerce/graphql": "^9.0.0-canary.
|
26
|
-
"@graphcommerce/graphql-mesh": "^9.0.0-canary.
|
27
|
-
"@graphcommerce/image": "^9.0.0-canary.
|
28
|
-
"@graphcommerce/magento-cart": "^9.0.0-canary.
|
29
|
-
"@graphcommerce/magento-category": "^9.0.0-canary.
|
30
|
-
"@graphcommerce/magento-store": "^9.0.0-canary.
|
31
|
-
"@graphcommerce/next-ui": "^9.0.0-canary.
|
32
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
33
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
21
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.62",
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.62",
|
23
|
+
"@graphcommerce/framer-next-pages": "^9.0.0-canary.62",
|
24
|
+
"@graphcommerce/framer-scroller": "^9.0.0-canary.62",
|
25
|
+
"@graphcommerce/graphql": "^9.0.0-canary.62",
|
26
|
+
"@graphcommerce/graphql-mesh": "^9.0.0-canary.62",
|
27
|
+
"@graphcommerce/image": "^9.0.0-canary.62",
|
28
|
+
"@graphcommerce/magento-cart": "^9.0.0-canary.62",
|
29
|
+
"@graphcommerce/magento-category": "^9.0.0-canary.62",
|
30
|
+
"@graphcommerce/magento-store": "^9.0.0-canary.62",
|
31
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.62",
|
32
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.62",
|
33
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.62",
|
34
34
|
"@lingui/core": "^4.2.1",
|
35
35
|
"@lingui/macro": "^4.2.1",
|
36
36
|
"@lingui/react": "^4.2.1",
|