@graphcommerce/magento-cart 4.3.4 → 4.4.1

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,30 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1499](https://github.com/graphcommerce-org/graphcommerce/pull/1499) [`d205b037f`](https://github.com/graphcommerce-org/graphcommerce/commit/d205b037fee82b8c03993f2c586f477e826093bf) Thanks [@paales](https://github.com/paales)! - Unified and simplified the customer authentication error handling
8
+
9
+ - Updated dependencies [[`d205b037f`](https://github.com/graphcommerce-org/graphcommerce/commit/d205b037fee82b8c03993f2c586f477e826093bf)]:
10
+ - @graphcommerce/magento-customer@4.5.1
11
+
12
+ ## 4.4.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#1492](https://github.com/graphcommerce-org/graphcommerce/pull/1492) [`bed806ddd`](https://github.com/graphcommerce-org/graphcommerce/commit/bed806dddd7e025806a69798ef9587aa165d392f) Thanks [@mikekeehnen](https://github.com/mikekeehnen)! - Removed useExtractCustomerErrors hook and implemented error handling via HttpLink Error
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`ffec8800a`](https://github.com/graphcommerce-org/graphcommerce/commit/ffec8800a50ff2fe9b9fc5feeb5a0a878b573f0e), [`bed806ddd`](https://github.com/graphcommerce-org/graphcommerce/commit/bed806dddd7e025806a69798ef9587aa165d392f)]:
21
+ - @graphcommerce/react-hook-form@3.2.1
22
+ - @graphcommerce/graphql@3.2.0
23
+ - @graphcommerce/magento-customer@4.5.0
24
+ - @graphcommerce/ecommerce-ui@1.0.17
25
+ - @graphcommerce/magento-graphql@3.0.13
26
+ - @graphcommerce/magento-store@4.2.8
27
+
3
28
  ## 4.3.4
4
29
 
5
30
  ### Patch Changes
@@ -1,46 +1,32 @@
1
- import { ApolloErrorAlert, ApolloErrorAlertProps } from '@graphcommerce/ecommerce-ui'
2
- import { useCustomerSession } from '@graphcommerce/magento-customer'
1
+ import {
2
+ ApolloCustomerErrorAlert,
3
+ ApolloCustomerErrorAlertProps,
4
+ } from '@graphcommerce/magento-customer'
3
5
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
4
- import { i18n } from '@lingui/core'
5
6
  import { Trans } from '@lingui/react'
6
7
  import { Button } from '@mui/material'
7
- import Link from 'next/link'
8
8
  import { useClearCurrentCartId } from '../../hooks/useClearCurrentCartId'
9
9
 
10
- export type ApolloCartErrorAlertProps = ApolloErrorAlertProps
10
+ export type ApolloCartErrorAlertProps = ApolloCustomerErrorAlertProps
11
11
 
12
12
  export function ApolloCartErrorAlert(props: ApolloCartErrorAlertProps) {
13
- const { error } = props
13
+ const { error, graphqlErrorAlertProps } = props
14
14
  const clear = useClearCurrentCartId()
15
- const { token } = useCustomerSession()
16
-
17
- let action: JSX.Element | undefined
18
15
 
19
16
  const [, noSuchEntity] = graphqlErrorByCategory({ category: 'graphql-no-such-entity', error })
20
- action = noSuchEntity ? (
21
- <Button onClick={clear}>
22
- <Trans id='Reset Cart' />
23
- </Button>
24
- ) : undefined
25
-
26
- const [, authorizationError] = graphqlErrorByCategory({
27
- category: 'graphql-authorization',
28
- error,
29
- mask: token
30
- ? i18n._(/* i18n */ `Please reauthenticate and try again`)
31
- : i18n._(/* i18n */ `You must sign in to continue`),
32
- })
33
-
34
- action =
35
- authorizationError && clear ? (
36
- <Link href='/account/signin' passHref>
37
- <Button>
38
- <Trans id='Sign in' />
39
- </Button>
40
- </Link>
41
- ) : (
42
- action
43
- )
44
17
 
45
- return <ApolloErrorAlert {...props} graphqlErrorAlertProps={{ action }} />
18
+ return (
19
+ <ApolloCustomerErrorAlert
20
+ {...props}
21
+ graphqlErrorAlertProps={{
22
+ action: noSuchEntity ? (
23
+ <Button onClick={clear}>
24
+ <Trans id='Reset Cart' />
25
+ </Button>
26
+ ) : (
27
+ graphqlErrorAlertProps?.action
28
+ ),
29
+ }}
30
+ />
31
+ )
46
32
  }
@@ -1,29 +1,34 @@
1
- import { ApolloErrorFullPage, ApolloErrorFullPageProps } from '@graphcommerce/ecommerce-ui'
1
+ import {
2
+ ApolloCustomerErrorFullPage,
3
+ ApolloCustomerErrorFullPageProps,
4
+ } from '@graphcommerce/magento-customer'
2
5
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
6
  import { iconSadFace, IconSvg } from '@graphcommerce/next-ui'
4
7
  import { Trans } from '@lingui/react'
5
8
  import { Button } from '@mui/material'
6
9
  import { useClearCurrentCartId } from '../../hooks/useClearCurrentCartId'
7
10
 
8
- export type ApolloCartErrorFullPageProps = Omit<ApolloErrorFullPageProps, 'icon'>
11
+ export type ApolloCartErrorFullPageProps = Omit<ApolloCustomerErrorFullPageProps, 'icon'>
9
12
 
10
13
  export function ApolloCartErrorFullPage(props: ApolloCartErrorFullPageProps) {
11
- const { error, ...passedProps } = props
14
+ const { error, button } = props
12
15
  const clear = useClearCurrentCartId()
13
16
 
14
17
  const [, noSuchEntity] = graphqlErrorByCategory({ category: 'graphql-no-such-entity', error })
15
- const action = noSuchEntity ? (
16
- <Button onClick={clear}>
17
- <Trans id='Reset Cart' />
18
- </Button>
19
- ) : undefined
20
18
 
21
19
  return (
22
- <ApolloErrorFullPage
23
- error={error}
20
+ <ApolloCustomerErrorFullPage
21
+ {...props}
24
22
  icon={<IconSvg src={iconSadFace} size='xxl' />}
25
- button={action}
26
- {...passedProps}
23
+ button={
24
+ noSuchEntity ? (
25
+ <Button onClick={clear}>
26
+ <Trans id='Reset Cart' />
27
+ </Button>
28
+ ) : (
29
+ button
30
+ )
31
+ }
27
32
  />
28
33
  )
29
34
  }
@@ -1,22 +1,32 @@
1
- import { ApolloErrorSnackbarProps, ApolloErrorSnackbar } from '@graphcommerce/ecommerce-ui'
1
+ import {
2
+ ApolloCustomerErrorSnackbar,
3
+ ApolloCustomerErrorSnackbarProps,
4
+ } from '@graphcommerce/magento-customer'
2
5
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
6
  import { Trans } from '@lingui/react'
4
7
  import { Button } from '@mui/material'
5
- import React from 'react'
6
8
  import { useClearCurrentCartId } from '../../hooks/useClearCurrentCartId'
7
9
 
8
- export type ApolloCartErrorSnackbarProps = Omit<ApolloErrorSnackbarProps, 'action'>
10
+ export type ApolloCartErrorSnackbarProps = ApolloCustomerErrorSnackbarProps
9
11
 
10
12
  export function ApolloCartErrorSnackbar(props: ApolloCartErrorSnackbarProps) {
11
- const { error, ...passedProps } = props
13
+ const { error, action } = props
12
14
  const clear = useClearCurrentCartId()
13
15
 
14
16
  const [, noSuchEntity] = graphqlErrorByCategory({ category: 'graphql-no-such-entity', error })
15
- const action = noSuchEntity ? (
16
- <Button onClick={clear} variant='pill' color='secondary'>
17
- <Trans id='Reset Cart' />
18
- </Button>
19
- ) : undefined
20
17
 
21
- return <ApolloErrorSnackbar error={error} action={action} {...passedProps} />
18
+ return (
19
+ <ApolloCustomerErrorSnackbar
20
+ {...props}
21
+ action={
22
+ noSuchEntity ? (
23
+ <Button onClick={clear} variant='pill' color='secondary'>
24
+ <Trans id='Reset Cart' />
25
+ </Button>
26
+ ) : (
27
+ action
28
+ )
29
+ }
30
+ />
31
+ )
22
32
  }
@@ -1,5 +1,5 @@
1
1
  import { useMutation, useQuery } from '@graphcommerce/graphql'
2
- import { useCustomerSession, useExtractCustomerErrors } from '@graphcommerce/magento-customer'
2
+ import { useCustomerSession } from '@graphcommerce/magento-customer'
3
3
  import { useEffect } from 'react'
4
4
  import { CustomerCartDocument } from './CustomerCart.gql'
5
5
  import { UseMergeCustomerCartDocument } from './UseMergeCustomerCart.gql'
@@ -15,9 +15,8 @@ import { useCurrentCartId } from './useCurrentCartId'
15
15
  export function useMergeCustomerCart() {
16
16
  const sourceCartId = useCurrentCartId()
17
17
  const assignCurrentCartId = useAssignCurrentCartId()
18
- const [merge, { error }] = useMutation(UseMergeCustomerCartDocument, { errorPolicy: 'all' })
18
+ const [merge] = useMutation(UseMergeCustomerCartDocument, { errorPolicy: 'all' })
19
19
 
20
- useExtractCustomerErrors({ error })
21
20
  const { loggedIn } = useCustomerSession()
22
21
  const destinationCartId = useQuery(CustomerCartDocument, {
23
22
  skip: !loggedIn,
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": "4.3.4",
5
+ "version": "4.4.1",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,16 +18,16 @@
18
18
  "@playwright/test": "^1.21.1"
19
19
  },
20
20
  "dependencies": {
21
- "@graphcommerce/ecommerce-ui": "1.0.16",
21
+ "@graphcommerce/ecommerce-ui": "1.0.17",
22
22
  "@graphcommerce/framer-next-pages": "3.2.2",
23
23
  "@graphcommerce/framer-scroller": "2.1.14",
24
- "@graphcommerce/graphql": "3.1.3",
24
+ "@graphcommerce/graphql": "3.2.0",
25
25
  "@graphcommerce/image": "3.1.6",
26
- "@graphcommerce/magento-customer": "4.4.2",
27
- "@graphcommerce/magento-graphql": "3.0.12",
28
- "@graphcommerce/magento-store": "4.2.7",
26
+ "@graphcommerce/magento-customer": "4.5.1",
27
+ "@graphcommerce/magento-graphql": "3.0.13",
28
+ "@graphcommerce/magento-store": "4.2.8",
29
29
  "@graphcommerce/next-ui": "4.8.3",
30
- "@graphcommerce/react-hook-form": "3.2.0"
30
+ "@graphcommerce/react-hook-form": "3.2.1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@lingui/react": "^3.13.2",