@graphcommerce/magento-cart-items 2.104.29 → 2.105.3

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
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.105.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-items@2.104.29...@graphcommerce/magento-cart-items@2.105.0) (2021-10-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **message-snackbar:** severity props ([c7be8a5](https://github.com/ho-nl/m2-pwa/commit/c7be8a51faf7a5937b7fab5bb352df2089ae4eea))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.104.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-items@2.104.0...@graphcommerce/magento-cart-items@2.104.1) (2021-09-27)
7
18
 
8
19
  **Note:** Version bump only for package @graphcommerce/magento-cart-items
@@ -2,11 +2,11 @@ import { Image } from '@graphcommerce/image'
2
2
  import { useDisplayInclTax } from '@graphcommerce/magento-cart'
3
3
  import { useProductLink } from '@graphcommerce/magento-product'
4
4
  import { Money } from '@graphcommerce/magento-store'
5
- import { UseStyles, responsiveVal } from '@graphcommerce/next-ui'
5
+ import { UseStyles, responsiveVal, MessageSnackbar } from '@graphcommerce/next-ui'
6
6
  import { Badge, makeStyles, Theme, Link } from '@material-ui/core'
7
7
  import clsx from 'clsx'
8
8
  import PageLink from 'next/link'
9
- import React, { PropsWithChildren } from 'react'
9
+ import React, { PropsWithChildren, useState } from 'react'
10
10
  import { CartItemFragment } from '../Api/CartItem.gql'
11
11
  import DeliveryLabel from '../DeliveryLabel/DeliveryLabel'
12
12
  import RemoveItemFromCartFab from '../RemoveItemFromCart/RemoveItemFromCartFab'
@@ -1,5 +1,5 @@
1
- import { useFormGqlMutationCart, ApolloCartErrorAlert } from '@graphcommerce/magento-cart'
2
- import { TextInputNumber } from '@graphcommerce/next-ui'
1
+ import { useFormGqlMutationCart } from '@graphcommerce/magento-cart'
2
+ import { Button, MessageSnackbar, TextInputNumber } from '@graphcommerce/next-ui'
3
3
  import { useFormAutoSubmit } from '@graphcommerce/react-hook-form'
4
4
  import React from 'react'
5
5
  import {
@@ -7,20 +7,26 @@ import {
7
7
  UpdateItemQuantityMutationVariables,
8
8
  } from './UpdateItemQuantity.gql'
9
9
 
10
- export type UpdateItemQuantityProps = Omit<UpdateItemQuantityMutationVariables, 'cartId'>
10
+ export type UpdateItemQuantityProps = Omit<UpdateItemQuantityMutationVariables, 'cartId'> & {
11
+ onError?: (err: any) => void
12
+ }
11
13
 
12
14
  export default function UpdateItemQuantity(props: UpdateItemQuantityProps) {
13
- const { uid, quantity } = props
15
+ const { uid, quantity, onError } = props
14
16
  const form = useFormGqlMutationCart(UpdateItemQuantityDocument, {
15
17
  defaultValues: { uid, quantity },
16
18
  mode: 'onChange',
17
19
  })
18
20
 
19
- const { muiRegister, required, handleSubmit, formState, error } = form
21
+ const { muiRegister, required, handleSubmit, formState, error, reset, getValues } = form
20
22
 
21
23
  const submit = handleSubmit(() => {})
22
24
  useFormAutoSubmit({ form, submit })
23
25
 
26
+ if (error && onError) {
27
+ onError(error)
28
+ }
29
+
24
30
  return (
25
31
  <form noValidate onSubmit={submit}>
26
32
  <TextInputNumber
@@ -32,7 +38,24 @@ export default function UpdateItemQuantity(props: UpdateItemQuantityProps) {
32
38
  {...muiRegister('quantity', { required: required.quantity })}
33
39
  helperText={formState.errors.quantity?.message}
34
40
  />
35
- <ApolloCartErrorAlert error={error} />
41
+
42
+ {error && (
43
+ <>
44
+ <MessageSnackbar
45
+ open={!!error}
46
+ variant='pill'
47
+ severity='error'
48
+ onClose={() => reset({ quantity })}
49
+ action={
50
+ <Button size='medium' variant='pill' color='secondary'>
51
+ Ok
52
+ </Button>
53
+ }
54
+ >
55
+ <>{error?.message}</>
56
+ </MessageSnackbar>
57
+ </>
58
+ )}
36
59
  </form>
37
60
  )
38
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-cart-items",
3
- "version": "2.104.29",
3
+ "version": "2.105.3",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
6
  "browserslist": [
@@ -14,21 +14,21 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@graphcommerce/browserslist-config-pwa": "^3.0.2",
17
- "@graphcommerce/eslint-config-pwa": "^3.0.7",
17
+ "@graphcommerce/eslint-config-pwa": "^3.0.8",
18
18
  "@graphcommerce/prettier-config-pwa": "^3.0.3",
19
19
  "@graphcommerce/typescript-config-pwa": "^3.1.1",
20
20
  "@playwright/test": "^1.15.2"
21
21
  },
22
22
  "dependencies": {
23
23
  "@apollo/client": "^3.4.16",
24
- "@graphcommerce/graphql": "^2.103.7",
25
- "@graphcommerce/image": "^2.104.10",
26
- "@graphcommerce/magento-cart": "^3.1.14",
27
- "@graphcommerce/magento-customer": "^3.1.1",
28
- "@graphcommerce/magento-product": "^3.0.29",
29
- "@graphcommerce/magento-store": "^3.0.25",
30
- "@graphcommerce/next-ui": "^3.5.0",
31
- "@graphcommerce/react-hook-form": "^2.102.8",
24
+ "@graphcommerce/graphql": "^2.103.8",
25
+ "@graphcommerce/image": "^2.104.11",
26
+ "@graphcommerce/magento-cart": "^3.2.2",
27
+ "@graphcommerce/magento-customer": "^3.1.5",
28
+ "@graphcommerce/magento-product": "^3.2.2",
29
+ "@graphcommerce/magento-store": "^3.0.28",
30
+ "@graphcommerce/next-ui": "^3.7.1",
31
+ "@graphcommerce/react-hook-form": "^2.102.9",
32
32
  "@graphql-typed-document-node/core": "^3.1.0",
33
33
  "@material-ui/core": "^4.12.3",
34
34
  "@material-ui/lab": "^4.0.0-alpha.60",
@@ -38,5 +38,5 @@
38
38
  "react": "^17.0.2",
39
39
  "react-dom": "^17.0.2"
40
40
  },
41
- "gitHead": "08f4dbe739a38ece2c47aa1e94c10f8397da27fa"
41
+ "gitHead": "99b31bb867bc0a28b1687fe2c7a67f67f0b1e8e3"
42
42
  }