@graphcommerce/magento-cart 8.1.0-canary.3 → 8.1.0-canary.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 +83 -2
- package/components/CartAgreementsForm/CartAgreementsForm.tsx +2 -3
- package/components/CartStartCheckout/CartStartCheckout.graphql +0 -1
- package/components/CartStartCheckout/CartStartCheckout.tsx +5 -2
- package/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx +2 -2
- package/components/CartSummary/CartSummary.tsx +1 -1
- package/components/CartTotals/CartTotals.graphql +1 -1
- package/hooks/useFormGqlMutationCart.ts +13 -6
- package/package.json +15 -15
- package/plugins/useSignInFormMergeCart.ts +2 -2
- package/typePolicies.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 8.1.0-canary.
|
|
3
|
+
## 8.1.0-canary.6
|
|
4
|
+
|
|
5
|
+
## 8.1.0-canary.5
|
|
6
|
+
|
|
7
|
+
## 8.0.6-canary.4
|
|
8
|
+
|
|
9
|
+
## 8.0.6-canary.3
|
|
10
|
+
|
|
11
|
+
## 8.0.6-canary.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
|
|
16
|
+
([@FrankHarland](https://github.com/FrankHarland))
|
|
17
|
+
|
|
18
|
+
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders.
|
|
19
|
+
([@FrankHarland](https://github.com/FrankHarland))
|
|
20
|
+
|
|
21
|
+
## 8.0.6-canary.1
|
|
22
|
+
|
|
23
|
+
## 8.0.6-canary.0
|
|
24
|
+
|
|
25
|
+
## 8.0.5
|
|
26
|
+
|
|
27
|
+
## 8.0.5-canary.10
|
|
28
|
+
|
|
29
|
+
## 8.0.5-canary.9
|
|
30
|
+
|
|
31
|
+
## 8.0.5-canary.8
|
|
32
|
+
|
|
33
|
+
## 8.0.5-canary.7
|
|
34
|
+
|
|
35
|
+
## 8.0.5-canary.6
|
|
36
|
+
|
|
37
|
+
## 8.0.5-canary.5
|
|
38
|
+
|
|
39
|
+
## 8.0.5-canary.4
|
|
40
|
+
|
|
41
|
+
## 8.0.5-canary.3
|
|
42
|
+
|
|
43
|
+
## 8.0.5-canary.2
|
|
44
|
+
|
|
45
|
+
## 8.0.5-canary.1
|
|
46
|
+
|
|
47
|
+
## 8.0.5-canary.0
|
|
48
|
+
|
|
49
|
+
## 8.0.4
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- [#2221](https://github.com/graphcommerce-org/graphcommerce/pull/2221) [`0ba1fdc`](https://github.com/graphcommerce-org/graphcommerce/commit/0ba1fdc9a2d005f47cd1725fe723e77da4cc5b9d) - After a user just logged in the checkout, the useFormGqlMutationCart would still run even though the cart was locked.
|
|
54
|
+
([@paales](https://github.com/paales))
|
|
55
|
+
|
|
56
|
+
## 8.0.4-canary.1
|
|
57
|
+
|
|
58
|
+
## 8.0.4-canary.0
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- [#2221](https://github.com/graphcommerce-org/graphcommerce/pull/2221) [`0ba1fdc`](https://github.com/graphcommerce-org/graphcommerce/commit/0ba1fdc9a2d005f47cd1725fe723e77da4cc5b9d) - After a user just logged in the checkout, the useFormGqlMutationCart would still run even though the cart was locked.
|
|
63
|
+
([@paales](https://github.com/paales))
|
|
64
|
+
|
|
65
|
+
## 8.0.3
|
|
4
66
|
|
|
5
67
|
### Patch Changes
|
|
6
68
|
|
|
@@ -10,7 +72,26 @@
|
|
|
10
72
|
- [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process.
|
|
11
73
|
([@paales](https://github.com/paales))
|
|
12
74
|
|
|
13
|
-
|
|
75
|
+
- [#2207](https://github.com/graphcommerce-org/graphcommerce/pull/2207) [`9876b13`](https://github.com/graphcommerce-org/graphcommerce/commit/9876b139b2c12c860a16af97eddea761d1059110) - Remove redundant query on the success page for logged in customers
|
|
76
|
+
([@paales](https://github.com/paales))
|
|
77
|
+
|
|
78
|
+
## 8.0.3-canary.6
|
|
79
|
+
|
|
80
|
+
## 8.0.3-canary.5
|
|
81
|
+
|
|
82
|
+
## 8.0.3-canary.4
|
|
83
|
+
|
|
84
|
+
## 8.0.3-canary.3
|
|
85
|
+
|
|
86
|
+
## 8.0.3-canary.2
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`d67c89d`](https://github.com/graphcommerce-org/graphcommerce/commit/d67c89d464a60f0e2618dab670b63a39f6291341) - Deprecate the allowUrl option for useCartQuery, it was already enabled by default and should never be set to false.
|
|
91
|
+
([@paales](https://github.com/paales))
|
|
92
|
+
|
|
93
|
+
- [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process.
|
|
94
|
+
([@paales](https://github.com/paales))
|
|
14
95
|
|
|
15
96
|
## 8.0.3-canary.1
|
|
16
97
|
|
|
@@ -2,10 +2,10 @@ import { CheckboxElement } from '@graphcommerce/ecommerce-ui'
|
|
|
2
2
|
import { useQuery } from '@graphcommerce/graphql'
|
|
3
3
|
import { extendableComponent, FormDiv } from '@graphcommerce/next-ui'
|
|
4
4
|
import {
|
|
5
|
+
FormPersist,
|
|
5
6
|
useForm,
|
|
6
7
|
useFormCompose,
|
|
7
8
|
UseFormComposeOptions,
|
|
8
|
-
useFormPersist,
|
|
9
9
|
} from '@graphcommerce/react-hook-form'
|
|
10
10
|
import { i18n } from '@lingui/core'
|
|
11
11
|
import { Box, Link, SxProps, Theme } from '@mui/material'
|
|
@@ -39,8 +39,6 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
|
39
39
|
console.log(values)
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
useFormPersist({ form, name: 'PaymentAgreementsForm' })
|
|
43
|
-
|
|
44
42
|
useFormCompose({ form, step, submit, key: 'PaymentAgreementsForm' })
|
|
45
43
|
|
|
46
44
|
if (data?.checkoutAgreements?.length === 0) return null
|
|
@@ -50,6 +48,7 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
|
|
|
50
48
|
className={classes.form}
|
|
51
49
|
sx={[(theme) => ({ pt: theme.spacings.md }), ...(Array.isArray(sx) ? sx : [sx])]}
|
|
52
50
|
>
|
|
51
|
+
<FormPersist form={form} name='PaymentAgreementsForm' />
|
|
53
52
|
<form noValidate onSubmit={submit} name='cartAgreements'>
|
|
54
53
|
<Box className={classes.formInner} sx={{ typography: 'body1', display: 'inline-block' }}>
|
|
55
54
|
{data?.checkoutAgreements &&
|
|
@@ -5,12 +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 = CartStartCheckoutFragment & {
|
|
8
|
+
export type CartStartCheckoutProps = Partial<CartStartCheckoutFragment> & {
|
|
9
9
|
children?: React.ReactNode
|
|
10
10
|
sx?: SxProps<Theme>
|
|
11
11
|
buttonProps?: ButtonProps<'button'>
|
|
12
12
|
disabled?: boolean
|
|
13
|
-
onStart?: (
|
|
13
|
+
onStart?: (
|
|
14
|
+
e: React.MouseEvent<HTMLButtonElement>,
|
|
15
|
+
cart: Partial<CartStartCheckoutFragment>,
|
|
16
|
+
) => void
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const name = 'CartStartCheckout' as const
|
|
@@ -4,13 +4,13 @@ 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 = CartStartCheckoutFragment & {
|
|
7
|
+
export type CartStartCheckoutLinkOrButtonProps = Partial<CartStartCheckoutFragment> & {
|
|
8
8
|
children?: React.ReactNode
|
|
9
9
|
sx?: SxProps<Theme>
|
|
10
10
|
disabled?: boolean
|
|
11
11
|
onStart?: (
|
|
12
12
|
e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement>,
|
|
13
|
-
cart: CartStartCheckoutFragment
|
|
13
|
+
cart: Partial<CartStartCheckoutFragment>,
|
|
14
14
|
) => void
|
|
15
15
|
linkOrButtonProps?: LinkOrButtonProps
|
|
16
16
|
}
|
|
@@ -21,7 +21,7 @@ const { classes } = extendableComponent<OwnerState, typeof compName, typeof part
|
|
|
21
21
|
export function CartSummary(props: CartSummaryProps) {
|
|
22
22
|
const { children, editable, sx = [] } = props
|
|
23
23
|
|
|
24
|
-
const { data } = useCartQuery(GetCartSummaryDocument
|
|
24
|
+
const { data } = useCartQuery(GetCartSummaryDocument)
|
|
25
25
|
const { href: historyHref, onClick: historyOnClick } = useHistoryLink({
|
|
26
26
|
href: '/checkout',
|
|
27
27
|
})
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { MutationHookOptions, TypedDocumentNode } from '@graphcommerce/graphql'
|
|
1
|
+
import { MutationHookOptions, TypedDocumentNode, useApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import {
|
|
3
3
|
useFormGqlMutation,
|
|
4
4
|
UseFormGqlMutationReturn,
|
|
5
5
|
UseFormGraphQlOptions,
|
|
6
6
|
} from '@graphcommerce/react-hook-form'
|
|
7
|
+
import { CurrentCartIdDocument } from './CurrentCartId.gql'
|
|
7
8
|
import { useCartIdCreate } from './useCartIdCreate'
|
|
8
9
|
|
|
9
10
|
export function useFormGqlMutationCart<
|
|
@@ -15,14 +16,20 @@ export function useFormGqlMutationCart<
|
|
|
15
16
|
operationOptions?: MutationHookOptions<Q, V>,
|
|
16
17
|
): UseFormGqlMutationReturn<Q, V> {
|
|
17
18
|
const cartId = useCartIdCreate()
|
|
19
|
+
const client = useApolloClient()
|
|
18
20
|
|
|
19
|
-
const onBeforeSubmit = async (variables: V) => {
|
|
20
|
-
const vars = { ...variables, cartId: await cartId() }
|
|
21
|
-
return options.onBeforeSubmit ? options.onBeforeSubmit(vars) : vars
|
|
22
|
-
}
|
|
23
21
|
const result = useFormGqlMutation<Q, V>(
|
|
24
22
|
document,
|
|
25
|
-
{
|
|
23
|
+
{
|
|
24
|
+
...options,
|
|
25
|
+
onBeforeSubmit: async (variables) => {
|
|
26
|
+
const vars = { ...variables, cartId: await cartId() }
|
|
27
|
+
|
|
28
|
+
const res = client.cache.readQuery({ query: CurrentCartIdDocument })
|
|
29
|
+
if (res?.currentCartId?.locked) return false
|
|
30
|
+
return options.onBeforeSubmit ? options.onBeforeSubmit(vars) : vars
|
|
31
|
+
},
|
|
32
|
+
},
|
|
26
33
|
{ errorPolicy: 'all', ...operationOptions },
|
|
27
34
|
)
|
|
28
35
|
|
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.6",
|
|
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.6",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.6",
|
|
17
|
+
"@graphcommerce/framer-next-pages": "^8.1.0-canary.6",
|
|
18
|
+
"@graphcommerce/framer-scroller": "^8.1.0-canary.6",
|
|
19
|
+
"@graphcommerce/framer-utils": "^8.1.0-canary.6",
|
|
20
|
+
"@graphcommerce/graphql": "^8.1.0-canary.6",
|
|
21
|
+
"@graphcommerce/image": "^8.1.0-canary.6",
|
|
22
|
+
"@graphcommerce/magento-customer": "^8.1.0-canary.6",
|
|
23
|
+
"@graphcommerce/magento-graphql": "^8.1.0-canary.6",
|
|
24
|
+
"@graphcommerce/magento-store": "^8.1.0-canary.6",
|
|
25
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.6",
|
|
26
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.6",
|
|
27
|
+
"@graphcommerce/react-hook-form": "^8.1.0-canary.6",
|
|
28
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.6",
|
|
29
29
|
"@lingui/core": "^4.2.1",
|
|
30
30
|
"@lingui/macro": "^4.2.1",
|
|
31
31
|
"@lingui/react": "^4.2.1",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useApolloClient } from '@graphcommerce/graphql'
|
|
2
|
-
import type { useSignInForm } from '@graphcommerce/magento-customer
|
|
2
|
+
import type { useSignInForm } from '@graphcommerce/magento-customer'
|
|
3
3
|
import type { MethodPlugin } from '@graphcommerce/next-config'
|
|
4
4
|
import { cartLock, readCartId, useAssignCurrentCartId } from '../hooks'
|
|
5
5
|
import { CustomerCartDocument } from '../hooks/CustomerCart.gql'
|
|
6
6
|
import { MergeCartsDocument } from '../hooks/MergeCarts.gql'
|
|
7
7
|
|
|
8
8
|
export const func = 'useSignInForm'
|
|
9
|
-
export const exported = '@graphcommerce/magento-customer
|
|
9
|
+
export const exported = '@graphcommerce/magento-customer'
|
|
10
10
|
|
|
11
11
|
const useSignInFormMergeCart: MethodPlugin<typeof useSignInForm> = (useSignInForm, options) => {
|
|
12
12
|
const client = useApolloClient()
|
package/typePolicies.ts
CHANGED
|
@@ -9,6 +9,9 @@ export const cartTypePolicies: StrictTypedTypePolicies = {
|
|
|
9
9
|
CartPrices: {
|
|
10
10
|
merge: (exiting, incoming, { mergeObjects }) => mergeObjects(exiting, incoming),
|
|
11
11
|
},
|
|
12
|
+
CartItemPrices: {
|
|
13
|
+
merge: (exiting, incoming, { mergeObjects }) => mergeObjects(exiting, incoming),
|
|
14
|
+
},
|
|
12
15
|
Cart: {
|
|
13
16
|
fields: {
|
|
14
17
|
shipping_addresses: {
|