@graphcommerce/magento-cart 8.1.0-canary.5 → 8.1.0-canary.50
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/Api/CartItemCountChanged.graphql +1 -1
- package/CHANGELOG.md +125 -0
- package/components/CartAddress/CartAddress.graphql +1 -0
- package/components/CartAgreementsForm/CartAgreementsForm.tsx +58 -24
- package/components/CartStartCheckout/CartStartCheckout.graphql +1 -1
- package/components/CartStartCheckout/CartStartCheckout.tsx +7 -6
- package/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx +6 -5
- package/components/CartTotals/CartTotals.graphql +8 -4
- package/components/CartTotals/CartTotals.tsx +9 -6
- package/components/InlineAccount/InlineAccount.tsx +1 -4
- package/components/OrderSucces/OrderSuccesPage.graphql +1 -1
- package/hooks/useFormGqlMutationCart.ts +6 -2
- package/package.json +15 -15
- package/plugins/MagentoCartGraphqlProvider.tsx +6 -6
- package/plugins/useSignInFormMergeCart.ts +1 -0
- package/typePolicies.ts +1 -0
- package/hooks/CurrentCartId.graphqls +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,130 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.1.0-canary.50
|
|
4
|
+
|
|
5
|
+
## 8.1.0-canary.49
|
|
6
|
+
|
|
7
|
+
## 8.1.0-canary.48
|
|
8
|
+
|
|
9
|
+
## 8.1.0-canary.47
|
|
10
|
+
|
|
11
|
+
## 8.1.0-canary.46
|
|
12
|
+
|
|
13
|
+
## 8.1.0-canary.45
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#2216](https://github.com/graphcommerce-org/graphcommerce/pull/2216) [`2faebf1`](https://github.com/graphcommerce-org/graphcommerce/commit/2faebf16fbda95390872ac0debe979fa570ed904) - When signing in make sure the cart isn't merged if the login is unsuccesful
|
|
18
|
+
([@paales](https://github.com/paales))
|
|
19
|
+
|
|
20
|
+
## 8.1.0-canary.44
|
|
21
|
+
|
|
22
|
+
## 8.1.0-canary.43
|
|
23
|
+
|
|
24
|
+
## 8.1.0-canary.42
|
|
25
|
+
|
|
26
|
+
## 8.1.0-canary.41
|
|
27
|
+
|
|
28
|
+
## 8.1.0-canary.40
|
|
29
|
+
|
|
30
|
+
## 8.1.0-canary.39
|
|
31
|
+
|
|
32
|
+
## 8.1.0-canary.38
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Add company and vat fields to shipping and billing forms
|
|
37
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Fix bug with persist not applying saved changes by moving <FromPersist/> below the form components
|
|
42
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
43
|
+
|
|
44
|
+
## 8.1.0-canary.37
|
|
45
|
+
|
|
46
|
+
## 8.1.0-canary.36
|
|
47
|
+
|
|
48
|
+
## 8.1.0-canary.35
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- [#2301](https://github.com/graphcommerce-org/graphcommerce/pull/2301) [`13d0649`](https://github.com/graphcommerce-org/graphcommerce/commit/13d06498d121f93b52c25930e50aa3b0bd12a818) - Created a new EmailElement component to make re-use easier
|
|
53
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
54
|
+
|
|
55
|
+
## 8.1.0-canary.34
|
|
56
|
+
|
|
57
|
+
### Minor Changes
|
|
58
|
+
|
|
59
|
+
- [#2303](https://github.com/graphcommerce-org/graphcommerce/pull/2303) [`f407e96`](https://github.com/graphcommerce-org/graphcommerce/commit/f407e961868683a257c8f7fe8ceb588fb825db9b) - Get shippingMethodPrices from selected shipping method if supported on the magento version
|
|
60
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
61
|
+
|
|
62
|
+
## 8.1.0-canary.33
|
|
63
|
+
|
|
64
|
+
## 8.1.0-canary.32
|
|
65
|
+
|
|
66
|
+
## 8.1.0-canary.31
|
|
67
|
+
|
|
68
|
+
## 8.1.0-canary.30
|
|
69
|
+
|
|
70
|
+
## 8.1.0-canary.29
|
|
71
|
+
|
|
72
|
+
## 8.1.0-canary.28
|
|
73
|
+
|
|
74
|
+
## 8.1.0-canary.27
|
|
75
|
+
|
|
76
|
+
## 8.1.0-canary.26
|
|
77
|
+
|
|
78
|
+
## 8.1.0-canary.25
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- [#2266](https://github.com/graphcommerce-org/graphcommerce/pull/2266) [`0d1fe7a`](https://github.com/graphcommerce-org/graphcommerce/commit/0d1fe7a26ed2d18510c8767795294654c478fb88) - Enable the use of one or more anchor links within the 'checkbox_text' field and customize their paths.
|
|
83
|
+
([@carlocarels90](https://github.com/carlocarels90))
|
|
84
|
+
|
|
85
|
+
## 8.1.0-canary.24
|
|
86
|
+
|
|
87
|
+
## 8.1.0-canary.23
|
|
88
|
+
|
|
89
|
+
## 8.1.0-canary.22
|
|
90
|
+
|
|
91
|
+
## 8.1.0-canary.21
|
|
92
|
+
|
|
93
|
+
## 8.1.0-canary.20
|
|
94
|
+
|
|
95
|
+
## 8.1.0-canary.19
|
|
96
|
+
|
|
97
|
+
## 8.1.0-canary.18
|
|
98
|
+
|
|
99
|
+
## 8.1.0-canary.17
|
|
100
|
+
|
|
101
|
+
## 8.1.0-canary.16
|
|
102
|
+
|
|
103
|
+
## 8.1.0-canary.15
|
|
104
|
+
|
|
105
|
+
## 8.1.0-canary.14
|
|
106
|
+
|
|
107
|
+
## 8.1.0-canary.13
|
|
108
|
+
|
|
109
|
+
## 8.1.0-canary.12
|
|
110
|
+
|
|
111
|
+
## 8.1.0-canary.11
|
|
112
|
+
|
|
113
|
+
## 8.1.0-canary.10
|
|
114
|
+
|
|
115
|
+
## 8.1.0-canary.9
|
|
116
|
+
|
|
117
|
+
## 8.1.0-canary.8
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- [#2247](https://github.com/graphcommerce-org/graphcommerce/pull/2247) [`a56a7c6`](https://github.com/graphcommerce-org/graphcommerce/commit/a56a7c67cf27dfb91bf763a873beeec562ab3156) - Solve an issue where the cart would be sometimes undefined, but Partial was too eleborate
|
|
122
|
+
([@paales](https://github.com/paales))
|
|
123
|
+
|
|
124
|
+
## 8.1.0-canary.7
|
|
125
|
+
|
|
126
|
+
## 8.1.0-canary.6
|
|
127
|
+
|
|
3
128
|
## 8.1.0-canary.5
|
|
4
129
|
|
|
5
130
|
## 8.0.6-canary.4
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
UseFormComposeOptions,
|
|
9
9
|
} from '@graphcommerce/react-hook-form'
|
|
10
10
|
import { i18n } from '@lingui/core'
|
|
11
|
-
import { Box, Link, SxProps, Theme } from '@mui/material'
|
|
11
|
+
import { Box, Link, SxProps, Theme, Typography } from '@mui/material'
|
|
12
12
|
import React from 'react'
|
|
13
13
|
import { CartAgreementsDocument } from './CartAgreements.gql'
|
|
14
14
|
|
|
@@ -18,16 +18,27 @@ const componentName = 'CartAgreementsForm' as const
|
|
|
18
18
|
const parts = ['form', 'formInner', 'formControlRoot', 'manualCheck'] as const
|
|
19
19
|
const { classes } = extendableComponent(componentName, parts)
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Checks if a string contains an anchor tag (<a> ... </a>).
|
|
23
|
+
* @param {string} str - The string to check.
|
|
24
|
+
* @returns {boolean} - True if the string contains an anchor tag, otherwise false.
|
|
25
|
+
*/
|
|
26
|
+
const containsAnchorTag = (str: string): boolean => {
|
|
27
|
+
const anchorTagRegex = /<a\s+[^>]*>(.*?)<\/a>/i
|
|
28
|
+
return anchorTagRegex.test(str)
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
22
32
|
const { step, sx = [] } = props
|
|
23
33
|
const { data } = useQuery(CartAgreementsDocument)
|
|
24
34
|
|
|
25
35
|
// sort conditions so checkboxes will be placed first
|
|
26
36
|
const sortedAgreements = data?.checkoutAgreements
|
|
27
|
-
? [...data.checkoutAgreements]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
? [...data.checkoutAgreements]?.sort((a, b) => {
|
|
38
|
+
if (a?.mode === 'MANUAL') return -1
|
|
39
|
+
if (b?.mode === 'MANUAL') return 1
|
|
40
|
+
return 0
|
|
41
|
+
})
|
|
31
42
|
: []
|
|
32
43
|
|
|
33
44
|
const form = useForm()
|
|
@@ -48,7 +59,6 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
|
48
59
|
className={classes.form}
|
|
49
60
|
sx={[(theme) => ({ pt: theme.spacings.md }), ...(Array.isArray(sx) ? sx : [sx])]}
|
|
50
61
|
>
|
|
51
|
-
<FormPersist form={form} name='PaymentAgreementsForm' />
|
|
52
62
|
<form noValidate onSubmit={submit} name='cartAgreements'>
|
|
53
63
|
<Box className={classes.formInner} sx={{ typography: 'body1', display: 'inline-block' }}>
|
|
54
64
|
{data?.checkoutAgreements &&
|
|
@@ -56,6 +66,45 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
|
56
66
|
if (!agreement) return null
|
|
57
67
|
const href = `/checkout/terms/${agreement.name?.toLowerCase().replace(/\s+/g, '-')}`
|
|
58
68
|
const agreementTextParts = agreement.checkbox_text.split(agreement.name)
|
|
69
|
+
// check if the agreement text contains an anchor tag
|
|
70
|
+
const containsLink = containsAnchorTag(agreement.checkbox_text)
|
|
71
|
+
let labelContent: React.ReactNode
|
|
72
|
+
|
|
73
|
+
if (containsLink) {
|
|
74
|
+
labelContent = (
|
|
75
|
+
<Typography
|
|
76
|
+
dangerouslySetInnerHTML={{ __html: agreement.checkbox_text }}
|
|
77
|
+
sx={{
|
|
78
|
+
'& a': {
|
|
79
|
+
color: 'secondary.main',
|
|
80
|
+
textDecoration: 'none',
|
|
81
|
+
'&:hover, &:focus, &:active': {
|
|
82
|
+
textDecoration: 'underline',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
)
|
|
88
|
+
} else if (
|
|
89
|
+
agreement.mode === 'MANUAL' &&
|
|
90
|
+
agreement.checkbox_text.includes(agreement.name)
|
|
91
|
+
) {
|
|
92
|
+
labelContent = (
|
|
93
|
+
<>
|
|
94
|
+
{agreementTextParts[0]}
|
|
95
|
+
<Link href={href} color='secondary' underline='hover'>
|
|
96
|
+
{agreement.name}
|
|
97
|
+
</Link>
|
|
98
|
+
{agreementTextParts[1]}
|
|
99
|
+
</>
|
|
100
|
+
)
|
|
101
|
+
} else {
|
|
102
|
+
labelContent = (
|
|
103
|
+
<Link href={href} color='secondary' underline='hover'>
|
|
104
|
+
{agreement.checkbox_text}
|
|
105
|
+
</Link>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
59
108
|
|
|
60
109
|
return (
|
|
61
110
|
<React.Fragment key={agreement.agreement_id}>
|
|
@@ -72,27 +121,11 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
|
72
121
|
rules={{
|
|
73
122
|
required: i18n._(/* i18n */ 'You have to agree in order to proceed'),
|
|
74
123
|
}}
|
|
75
|
-
label={
|
|
76
|
-
agreement.checkbox_text.includes(agreement.name) ? (
|
|
77
|
-
<>
|
|
78
|
-
{agreementTextParts[0]}
|
|
79
|
-
<Link href={href} color='secondary' underline='hover'>
|
|
80
|
-
{agreement.name}
|
|
81
|
-
</Link>
|
|
82
|
-
{agreementTextParts[1]}
|
|
83
|
-
</>
|
|
84
|
-
) : (
|
|
85
|
-
<Link href={href} color='secondary' underline='hover'>
|
|
86
|
-
{agreement.checkbox_text}
|
|
87
|
-
</Link>
|
|
88
|
-
)
|
|
89
|
-
}
|
|
124
|
+
label={labelContent}
|
|
90
125
|
/>
|
|
91
126
|
) : (
|
|
92
127
|
<Box className={classes.manualCheck} sx={{ padding: `9px 0` }}>
|
|
93
|
-
|
|
94
|
-
{agreement.checkbox_text}
|
|
95
|
-
</Link>
|
|
128
|
+
{labelContent}
|
|
96
129
|
</Box>
|
|
97
130
|
)}
|
|
98
131
|
</React.Fragment>
|
|
@@ -100,6 +133,7 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
|
100
133
|
})}
|
|
101
134
|
</Box>
|
|
102
135
|
</form>
|
|
136
|
+
<FormPersist form={form} name='PaymentAgreementsForm' />
|
|
103
137
|
</FormDiv>
|
|
104
138
|
)
|
|
105
139
|
}
|
|
@@ -5,14 +5,15 @@ import { Box, Button, ButtonProps, SxProps, Theme } from '@mui/material'
|
|
|
5
5
|
import React from 'react'
|
|
6
6
|
import { CartStartCheckoutFragment } from './CartStartCheckout.gql'
|
|
7
7
|
|
|
8
|
-
export type CartStartCheckoutProps =
|
|
8
|
+
export type CartStartCheckoutProps = {
|
|
9
9
|
children?: React.ReactNode
|
|
10
10
|
sx?: SxProps<Theme>
|
|
11
11
|
buttonProps?: ButtonProps<'button'>
|
|
12
12
|
disabled?: boolean
|
|
13
|
+
cart?: CartStartCheckoutFragment | null | undefined
|
|
13
14
|
onStart?: (
|
|
14
15
|
e: React.MouseEvent<HTMLButtonElement>,
|
|
15
|
-
cart:
|
|
16
|
+
cart: CartStartCheckoutFragment | null | undefined,
|
|
16
17
|
) => void
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -32,11 +33,11 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
|
|
|
32
33
|
buttonProps: { onClick, ...buttonProps } = {},
|
|
33
34
|
disabled,
|
|
34
35
|
sx = [],
|
|
35
|
-
|
|
36
|
+
cart,
|
|
36
37
|
} = props
|
|
37
38
|
|
|
38
|
-
const hasTotals = (cart
|
|
39
|
-
const hasErrors = cart
|
|
39
|
+
const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0
|
|
40
|
+
const hasErrors = cart?.items?.some((item) => (item?.errors?.length ?? 0) > 0)
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<Box
|
|
@@ -74,7 +75,7 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
|
|
|
74
75
|
</Box>{' '}
|
|
75
76
|
{hasTotals && (
|
|
76
77
|
<span className={classes.checkoutMoney}>
|
|
77
|
-
<Money {...cart
|
|
78
|
+
<Money {...cart?.prices?.grand_total} />
|
|
78
79
|
</span>
|
|
79
80
|
)}
|
|
80
81
|
</Button>
|
|
@@ -4,13 +4,14 @@ import { SxProps, Theme } from '@mui/material'
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { CartStartCheckoutFragment } from './CartStartCheckout.gql'
|
|
6
6
|
|
|
7
|
-
export type CartStartCheckoutLinkOrButtonProps =
|
|
7
|
+
export type CartStartCheckoutLinkOrButtonProps = {
|
|
8
8
|
children?: React.ReactNode
|
|
9
9
|
sx?: SxProps<Theme>
|
|
10
10
|
disabled?: boolean
|
|
11
|
+
cart?: CartStartCheckoutFragment | null | undefined
|
|
11
12
|
onStart?: (
|
|
12
13
|
e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement>,
|
|
13
|
-
cart:
|
|
14
|
+
cart: CartStartCheckoutFragment | null | undefined,
|
|
14
15
|
) => void
|
|
15
16
|
linkOrButtonProps?: LinkOrButtonProps
|
|
16
17
|
}
|
|
@@ -21,11 +22,11 @@ export function CartStartCheckoutLinkOrButton(props: CartStartCheckoutLinkOrButt
|
|
|
21
22
|
onStart,
|
|
22
23
|
disabled,
|
|
23
24
|
linkOrButtonProps: { onClick, button, ...linkOrButtonProps } = {},
|
|
24
|
-
|
|
25
|
+
cart,
|
|
25
26
|
} = props
|
|
26
27
|
|
|
27
|
-
const hasTotals = (cart
|
|
28
|
-
const hasErrors = cart
|
|
28
|
+
const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0
|
|
29
|
+
const hasErrors = cart?.items?.some((item) => (item?.errors?.length ?? 0) > 0)
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
32
|
<LinkOrButton
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
fragment CartTotals on Cart
|
|
2
|
-
@injectable
|
|
3
|
-
@inject(into: ["CartItemCountChanged", "PaymentMethodUpdated"]) {
|
|
1
|
+
fragment CartTotals on Cart @inject(into: ["CartItemCountChanged", "PaymentMethodUpdated"]) {
|
|
4
2
|
shipping_addresses {
|
|
5
3
|
selected_shipping_method {
|
|
6
4
|
carrier_code
|
|
@@ -10,8 +8,14 @@ fragment CartTotals on Cart
|
|
|
10
8
|
amount {
|
|
11
9
|
...Money
|
|
12
10
|
}
|
|
11
|
+
price_excl_tax {
|
|
12
|
+
...Money
|
|
13
|
+
}
|
|
14
|
+
price_incl_tax {
|
|
15
|
+
...Money
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
|
-
# todo:
|
|
18
|
+
# todo: When 245 is not supported anymore, remove available_shipping_methods from fragment.
|
|
15
19
|
available_shipping_methods {
|
|
16
20
|
carrier_code
|
|
17
21
|
method_code
|
|
@@ -42,12 +42,15 @@ export function CartTotals(props: CartTotalsProps) {
|
|
|
42
42
|
const { shipping_addresses, prices } = data.cart
|
|
43
43
|
const shippingMethod = shipping_addresses?.[0]?.selected_shipping_method
|
|
44
44
|
|
|
45
|
-
const shippingMethodPrices =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const shippingMethodPrices =
|
|
46
|
+
import.meta.graphCommerce.magentoVersion >= 246
|
|
47
|
+
? shippingMethod
|
|
48
|
+
: shipping_addresses?.[0]?.available_shipping_methods?.find(
|
|
49
|
+
(avail) =>
|
|
50
|
+
(shippingMethod?.amount?.value ?? 0) > 0 &&
|
|
51
|
+
avail?.carrier_code === shippingMethod?.carrier_code &&
|
|
52
|
+
avail?.method_code === shippingMethod?.method_code,
|
|
53
|
+
)
|
|
51
54
|
|
|
52
55
|
return (
|
|
53
56
|
<Box
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useQuery } from '@graphcommerce/graphql'
|
|
2
1
|
import {
|
|
3
2
|
SignUpFormInline,
|
|
4
3
|
IsEmailAvailableDocument,
|
|
@@ -7,7 +6,6 @@ import {
|
|
|
7
6
|
} from '@graphcommerce/magento-customer'
|
|
8
7
|
import { Button, FormRow, extendableComponent } from '@graphcommerce/next-ui'
|
|
9
8
|
import { Trans } from '@lingui/react'
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
11
9
|
import { Box, SxProps, TextField, Theme, Typography } from '@mui/material'
|
|
12
10
|
import React, { useState } from 'react'
|
|
13
11
|
import { useCartQuery } from '../../hooks/useCartQuery'
|
|
@@ -101,8 +99,7 @@ export function InlineAccount(props: InlineAccountProps) {
|
|
|
101
99
|
<FormRow>
|
|
102
100
|
<TextField
|
|
103
101
|
variant='outlined'
|
|
104
|
-
|
|
105
|
-
label='Email'
|
|
102
|
+
label={<Trans id='Email address' />}
|
|
106
103
|
value={cart?.email}
|
|
107
104
|
InputProps={{
|
|
108
105
|
readOnly: true,
|
|
@@ -12,7 +12,7 @@ export function useFormGqlMutationCart<
|
|
|
12
12
|
V extends { cartId: string; [index: string]: unknown },
|
|
13
13
|
>(
|
|
14
14
|
document: TypedDocumentNode<Q, V>,
|
|
15
|
-
options: UseFormGraphQlOptions<Q, V> = {},
|
|
15
|
+
options: UseFormGraphQlOptions<Q, V> & { submitWhileLocked?: boolean } = {},
|
|
16
16
|
operationOptions?: MutationHookOptions<Q, V>,
|
|
17
17
|
): UseFormGqlMutationReturn<Q, V> {
|
|
18
18
|
const cartId = useCartIdCreate()
|
|
@@ -26,7 +26,11 @@ export function useFormGqlMutationCart<
|
|
|
26
26
|
const vars = { ...variables, cartId: await cartId() }
|
|
27
27
|
|
|
28
28
|
const res = client.cache.readQuery({ query: CurrentCartIdDocument })
|
|
29
|
-
if (res?.currentCartId?.locked)
|
|
29
|
+
if (!options.submitWhileLocked && res?.currentCartId?.locked) {
|
|
30
|
+
console.log('Could not submit form, cart is locked', res.currentCartId.locked)
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
return options.onBeforeSubmit ? options.onBeforeSubmit(vars) : vars
|
|
31
35
|
},
|
|
32
36
|
},
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-cart",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "8.1.0-canary.
|
|
5
|
+
"version": "8.1.0-canary.50",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^8.1.0-canary.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.
|
|
17
|
-
"@graphcommerce/framer-next-pages": "^8.1.0-canary.
|
|
18
|
-
"@graphcommerce/framer-scroller": "^8.1.0-canary.
|
|
19
|
-
"@graphcommerce/framer-utils": "^8.1.0-canary.
|
|
20
|
-
"@graphcommerce/graphql": "^8.1.0-canary.
|
|
21
|
-
"@graphcommerce/image": "^8.1.0-canary.
|
|
22
|
-
"@graphcommerce/magento-customer": "^8.1.0-canary.
|
|
23
|
-
"@graphcommerce/magento-graphql": "^8.1.0-canary.
|
|
24
|
-
"@graphcommerce/magento-store": "^8.1.0-canary.
|
|
25
|
-
"@graphcommerce/next-ui": "^8.1.0-canary.
|
|
26
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
27
|
-
"@graphcommerce/react-hook-form": "^8.1.0-canary.
|
|
28
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^8.1.0-canary.50",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.50",
|
|
17
|
+
"@graphcommerce/framer-next-pages": "^8.1.0-canary.50",
|
|
18
|
+
"@graphcommerce/framer-scroller": "^8.1.0-canary.50",
|
|
19
|
+
"@graphcommerce/framer-utils": "^8.1.0-canary.50",
|
|
20
|
+
"@graphcommerce/graphql": "^8.1.0-canary.50",
|
|
21
|
+
"@graphcommerce/image": "^8.1.0-canary.50",
|
|
22
|
+
"@graphcommerce/magento-customer": "^8.1.0-canary.50",
|
|
23
|
+
"@graphcommerce/magento-graphql": "^8.1.0-canary.50",
|
|
24
|
+
"@graphcommerce/magento-store": "^8.1.0-canary.50",
|
|
25
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.50",
|
|
26
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.50",
|
|
27
|
+
"@graphcommerce/react-hook-form": "^8.1.0-canary.50",
|
|
28
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.50",
|
|
29
29
|
"@lingui/core": "^4.2.1",
|
|
30
30
|
"@lingui/macro": "^4.2.1",
|
|
31
31
|
"@lingui/react": "^4.2.1",
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { GraphQLProviderProps } from '@graphcommerce/graphql'
|
|
2
|
-
import type { PluginProps } from '@graphcommerce/next-config'
|
|
2
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { cartErrorLink } from '../link/createCartErrorLink'
|
|
4
4
|
import { cartTypePolicies, migrateCart } from '../typePolicies'
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
|
|
6
|
+
export const config: PluginConfig = {
|
|
7
|
+
type: 'component',
|
|
8
|
+
module: '@graphcommerce/graphql',
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
function
|
|
11
|
+
export function GraphQLProvider(props: PluginProps<GraphQLProviderProps>) {
|
|
10
12
|
const { Prev, links = [], policies = [], migrations = [], ...rest } = props
|
|
11
13
|
return (
|
|
12
14
|
<Prev
|
|
@@ -17,5 +19,3 @@ function MagentoCartGraphqlProvider(props: PluginProps<GraphQLProviderProps>) {
|
|
|
17
19
|
/>
|
|
18
20
|
)
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
export const Plugin = MagentoCartGraphqlProvider
|
package/typePolicies.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const cartTypePolicies: StrictTypedTypePolicies = {
|
|
|
24
24
|
return merged ? [merged] : []
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
|
+
items: { merge: (_, incoming) => incoming },
|
|
27
28
|
prices: {
|
|
28
29
|
merge: (existing: CartPrices[] | undefined, incoming: CartPrices[], options) =>
|
|
29
30
|
options.mergeObjects(existing ?? {}, incoming),
|