@graphcommerce/magento-cart 8.1.0-canary.3 → 8.1.0-canary.5

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,6 +1,66 @@
1
1
  # Change Log
2
2
 
3
- ## 8.1.0-canary.3
3
+ ## 8.1.0-canary.5
4
+
5
+ ## 8.0.6-canary.4
6
+
7
+ ## 8.0.6-canary.3
8
+
9
+ ## 8.0.6-canary.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+ ([@FrankHarland](https://github.com/FrankHarland))
15
+
16
+ - [#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.
17
+ ([@FrankHarland](https://github.com/FrankHarland))
18
+
19
+ ## 8.0.6-canary.1
20
+
21
+ ## 8.0.6-canary.0
22
+
23
+ ## 8.0.5
24
+
25
+ ## 8.0.5-canary.10
26
+
27
+ ## 8.0.5-canary.9
28
+
29
+ ## 8.0.5-canary.8
30
+
31
+ ## 8.0.5-canary.7
32
+
33
+ ## 8.0.5-canary.6
34
+
35
+ ## 8.0.5-canary.5
36
+
37
+ ## 8.0.5-canary.4
38
+
39
+ ## 8.0.5-canary.3
40
+
41
+ ## 8.0.5-canary.2
42
+
43
+ ## 8.0.5-canary.1
44
+
45
+ ## 8.0.5-canary.0
46
+
47
+ ## 8.0.4
48
+
49
+ ### Patch Changes
50
+
51
+ - [#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.
52
+ ([@paales](https://github.com/paales))
53
+
54
+ ## 8.0.4-canary.1
55
+
56
+ ## 8.0.4-canary.0
57
+
58
+ ### Patch Changes
59
+
60
+ - [#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.
61
+ ([@paales](https://github.com/paales))
62
+
63
+ ## 8.0.3
4
64
 
5
65
  ### Patch Changes
6
66
 
@@ -10,7 +70,26 @@
10
70
  - [#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
71
  ([@paales](https://github.com/paales))
12
72
 
13
- ## 8.1.0-canary.2
73
+ - [#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
74
+ ([@paales](https://github.com/paales))
75
+
76
+ ## 8.0.3-canary.6
77
+
78
+ ## 8.0.3-canary.5
79
+
80
+ ## 8.0.3-canary.4
81
+
82
+ ## 8.0.3-canary.3
83
+
84
+ ## 8.0.3-canary.2
85
+
86
+ ### Patch Changes
87
+
88
+ - [#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.
89
+ ([@paales](https://github.com/paales))
90
+
91
+ - [#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.
92
+ ([@paales](https://github.com/paales))
14
93
 
15
94
  ## 8.0.3-canary.1
16
95
 
@@ -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 &&
@@ -4,7 +4,6 @@ fragment CartStartCheckout on Cart @injectable {
4
4
  ...Money
5
5
  }
6
6
  }
7
-
8
7
  items {
9
8
  errors {
10
9
  message
@@ -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?: (e: React.MouseEvent<HTMLButtonElement>, cart: CartStartCheckoutFragment) => void
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, { allowUrl: true })
24
+ const { data } = useCartQuery(GetCartSummaryDocument)
25
25
  const { href: historyHref, onClick: historyOnClick } = useHistoryLink({
26
26
  href: '/checkout',
27
27
  })
@@ -11,7 +11,7 @@ fragment CartTotals on Cart
11
11
  ...Money
12
12
  }
13
13
  }
14
- # https://github.com/magento/magento2/pull/31322
14
+ # todo: https://github.com/magento/magento2/pull/31322
15
15
  available_shipping_methods {
16
16
  carrier_code
17
17
  method_code
@@ -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
- { ...options, onBeforeSubmit },
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.3",
5
+ "version": "8.1.0-canary.5",
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.3",
16
- "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.3",
17
- "@graphcommerce/framer-next-pages": "^8.1.0-canary.3",
18
- "@graphcommerce/framer-scroller": "^8.1.0-canary.3",
19
- "@graphcommerce/framer-utils": "^8.1.0-canary.3",
20
- "@graphcommerce/graphql": "^8.1.0-canary.3",
21
- "@graphcommerce/image": "^8.1.0-canary.3",
22
- "@graphcommerce/magento-customer": "^8.1.0-canary.3",
23
- "@graphcommerce/magento-graphql": "^8.1.0-canary.3",
24
- "@graphcommerce/magento-store": "^8.1.0-canary.3",
25
- "@graphcommerce/next-ui": "^8.1.0-canary.3",
26
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.3",
27
- "@graphcommerce/react-hook-form": "^8.1.0-canary.3",
28
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.3",
15
+ "@graphcommerce/ecommerce-ui": "^8.1.0-canary.5",
16
+ "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.5",
17
+ "@graphcommerce/framer-next-pages": "^8.1.0-canary.5",
18
+ "@graphcommerce/framer-scroller": "^8.1.0-canary.5",
19
+ "@graphcommerce/framer-utils": "^8.1.0-canary.5",
20
+ "@graphcommerce/graphql": "^8.1.0-canary.5",
21
+ "@graphcommerce/image": "^8.1.0-canary.5",
22
+ "@graphcommerce/magento-customer": "^8.1.0-canary.5",
23
+ "@graphcommerce/magento-graphql": "^8.1.0-canary.5",
24
+ "@graphcommerce/magento-store": "^8.1.0-canary.5",
25
+ "@graphcommerce/next-ui": "^8.1.0-canary.5",
26
+ "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.5",
27
+ "@graphcommerce/react-hook-form": "^8.1.0-canary.5",
28
+ "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.5",
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/hooks/useSignInForm'
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/hooks/useSignInForm'
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: {