@graphcommerce/magento-cart 8.1.0-canary.9 → 9.0.0-canary.54
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 +120 -0
- package/components/CartAddress/CartAddress.graphql +1 -0
- package/components/CartAgreementsForm/CartAgreementsForm.tsx +58 -24
- package/components/CartStartCheckout/CartStartCheckout.graphql +1 -1
- 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/useSignInFormMergeCart.ts +1 -0
- package/typePolicies.ts +1 -0
- package/hooks/CurrentCartId.graphqls +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.54
|
|
4
|
+
|
|
5
|
+
## 8.1.0-canary.53
|
|
6
|
+
|
|
7
|
+
## 8.1.0-canary.52
|
|
8
|
+
|
|
9
|
+
## 8.1.0-canary.51
|
|
10
|
+
|
|
11
|
+
## 8.1.0-canary.50
|
|
12
|
+
|
|
13
|
+
## 8.1.0-canary.49
|
|
14
|
+
|
|
15
|
+
## 8.1.0-canary.48
|
|
16
|
+
|
|
17
|
+
## 8.1.0-canary.47
|
|
18
|
+
|
|
19
|
+
## 8.1.0-canary.46
|
|
20
|
+
|
|
21
|
+
## 8.1.0-canary.45
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#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
|
|
26
|
+
([@paales](https://github.com/paales))
|
|
27
|
+
|
|
28
|
+
## 8.1.0-canary.44
|
|
29
|
+
|
|
30
|
+
## 8.1.0-canary.43
|
|
31
|
+
|
|
32
|
+
## 8.1.0-canary.42
|
|
33
|
+
|
|
34
|
+
## 8.1.0-canary.41
|
|
35
|
+
|
|
36
|
+
## 8.1.0-canary.40
|
|
37
|
+
|
|
38
|
+
## 8.1.0-canary.39
|
|
39
|
+
|
|
40
|
+
## 8.1.0-canary.38
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- [#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
|
|
45
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- [#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
|
|
50
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
51
|
+
|
|
52
|
+
## 8.1.0-canary.37
|
|
53
|
+
|
|
54
|
+
## 8.1.0-canary.36
|
|
55
|
+
|
|
56
|
+
## 8.1.0-canary.35
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- [#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
|
|
61
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
62
|
+
|
|
63
|
+
## 8.1.0-canary.34
|
|
64
|
+
|
|
65
|
+
### Minor Changes
|
|
66
|
+
|
|
67
|
+
- [#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
|
|
68
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
69
|
+
|
|
70
|
+
## 8.1.0-canary.33
|
|
71
|
+
|
|
72
|
+
## 8.1.0-canary.32
|
|
73
|
+
|
|
74
|
+
## 8.1.0-canary.31
|
|
75
|
+
|
|
76
|
+
## 8.1.0-canary.30
|
|
77
|
+
|
|
78
|
+
## 8.1.0-canary.29
|
|
79
|
+
|
|
80
|
+
## 8.1.0-canary.28
|
|
81
|
+
|
|
82
|
+
## 8.1.0-canary.27
|
|
83
|
+
|
|
84
|
+
## 8.1.0-canary.26
|
|
85
|
+
|
|
86
|
+
## 8.1.0-canary.25
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- [#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.
|
|
91
|
+
([@carlocarels90](https://github.com/carlocarels90))
|
|
92
|
+
|
|
93
|
+
## 8.1.0-canary.24
|
|
94
|
+
|
|
95
|
+
## 8.1.0-canary.23
|
|
96
|
+
|
|
97
|
+
## 8.1.0-canary.22
|
|
98
|
+
|
|
99
|
+
## 8.1.0-canary.21
|
|
100
|
+
|
|
101
|
+
## 8.1.0-canary.20
|
|
102
|
+
|
|
103
|
+
## 8.1.0-canary.19
|
|
104
|
+
|
|
105
|
+
## 8.1.0-canary.18
|
|
106
|
+
|
|
107
|
+
## 8.1.0-canary.17
|
|
108
|
+
|
|
109
|
+
## 8.1.0-canary.16
|
|
110
|
+
|
|
111
|
+
## 8.1.0-canary.15
|
|
112
|
+
|
|
113
|
+
## 8.1.0-canary.14
|
|
114
|
+
|
|
115
|
+
## 8.1.0-canary.13
|
|
116
|
+
|
|
117
|
+
## 8.1.0-canary.12
|
|
118
|
+
|
|
119
|
+
## 8.1.0-canary.11
|
|
120
|
+
|
|
121
|
+
## 8.1.0-canary.10
|
|
122
|
+
|
|
3
123
|
## 8.1.0-canary.9
|
|
4
124
|
|
|
5
125
|
## 8.1.0-canary.8
|
|
@@ -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
|
}
|
|
@@ -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": "
|
|
5
|
+
"version": "9.0.0-canary.54",
|
|
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": "^
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
17
|
-
"@graphcommerce/framer-next-pages": "^
|
|
18
|
-
"@graphcommerce/framer-scroller": "^
|
|
19
|
-
"@graphcommerce/framer-utils": "^
|
|
20
|
-
"@graphcommerce/graphql": "^
|
|
21
|
-
"@graphcommerce/image": "^
|
|
22
|
-
"@graphcommerce/magento-customer": "^
|
|
23
|
-
"@graphcommerce/magento-graphql": "^
|
|
24
|
-
"@graphcommerce/magento-store": "^
|
|
25
|
-
"@graphcommerce/next-ui": "^
|
|
26
|
-
"@graphcommerce/prettier-config-pwa": "^
|
|
27
|
-
"@graphcommerce/react-hook-form": "^
|
|
28
|
-
"@graphcommerce/typescript-config-pwa": "^
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.54",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.54",
|
|
17
|
+
"@graphcommerce/framer-next-pages": "^9.0.0-canary.54",
|
|
18
|
+
"@graphcommerce/framer-scroller": "^9.0.0-canary.54",
|
|
19
|
+
"@graphcommerce/framer-utils": "^9.0.0-canary.54",
|
|
20
|
+
"@graphcommerce/graphql": "^9.0.0-canary.54",
|
|
21
|
+
"@graphcommerce/image": "^9.0.0-canary.54",
|
|
22
|
+
"@graphcommerce/magento-customer": "^9.0.0-canary.54",
|
|
23
|
+
"@graphcommerce/magento-graphql": "^9.0.0-canary.54",
|
|
24
|
+
"@graphcommerce/magento-store": "^9.0.0-canary.54",
|
|
25
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.54",
|
|
26
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.54",
|
|
27
|
+
"@graphcommerce/react-hook-form": "^9.0.0-canary.54",
|
|
28
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.54",
|
|
29
29
|
"@lingui/core": "^4.2.1",
|
|
30
30
|
"@lingui/macro": "^4.2.1",
|
|
31
31
|
"@lingui/react": "^4.2.1",
|
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),
|