@graphcommerce/magento-product-grouped 9.1.0-canary.44 → 9.1.0-canary.45
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 +6 -1
- package/GroupedProducts/GroupedProductActionCard.tsx +25 -27
- package/GroupedProducts/GroupedProducts.tsx +8 -14
- package/graphql/fragments/GroupedProduct.graphql +6 -0
- package/graphql/fragments/GroupedProductItem.graphql +11 -0
- package/package.json +13 -13
- package/GroupedProduct.graphql +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.1.0-canary.45
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f915f65`](https://github.com/graphcommerce-org/graphcommerce/commit/f915f655f5965bab1d50eca9b275199c02e7b7d1) - Make sure the default quantity is selected on the product page for grouped products. Products are sorted correctly and create a separate GroupedProductItem fragment for easier etensibility. ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
3
9
|
## 9.1.0-canary.44
|
|
4
10
|
|
|
5
11
|
## 9.1.0-canary.43
|
|
@@ -113,7 +119,6 @@
|
|
|
113
119
|
### Patch Changes
|
|
114
120
|
|
|
115
121
|
- [#1752](https://github.com/graphcommerce-org/graphcommerce/pull/1752) [`2a6a4d9ec`](https://github.com/graphcommerce-org/graphcommerce/commit/2a6a4d9ecfa1b58a66ba9b9d00016d6feda9aa95) - Updated dependencies to latest versions, except for nextjs; Solve tons of peer dependency issues.
|
|
116
|
-
|
|
117
122
|
- Updated the @mui/material package
|
|
118
123
|
- Removed dependencies on react-hook-form-mui and @playwright/test
|
|
119
124
|
- Upgraded dependencies including type-fest and graphql-mesh
|
|
@@ -2,21 +2,18 @@ import { Image } from '@graphcommerce/image'
|
|
|
2
2
|
import type { AddToCartItemSelector } from '@graphcommerce/magento-product'
|
|
3
3
|
import {
|
|
4
4
|
AddProductsToCartQuantity,
|
|
5
|
-
|
|
5
|
+
ProductPagePrice,
|
|
6
6
|
useFormAddProductsToCart,
|
|
7
7
|
} from '@graphcommerce/magento-product'
|
|
8
8
|
import type { ActionCardProps } from '@graphcommerce/next-ui'
|
|
9
|
-
import { ActionCard, actionCardImageSizes
|
|
9
|
+
import { ActionCard, actionCardImageSizes } from '@graphcommerce/next-ui'
|
|
10
10
|
import { Link } from '@mui/material'
|
|
11
|
-
import type {
|
|
11
|
+
import type { GroupedProductItemFragment } from '../graphql/fragments/GroupedProductItem.gql'
|
|
12
12
|
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type GroupedProductActionCardProps = GroupedProductItem &
|
|
18
|
-
Omit<ActionCardProps, 'value' | 'image' | 'price' | 'title' | 'action'> &
|
|
19
|
-
AddToCartItemSelector
|
|
13
|
+
export type GroupedProductActionCardProps = {
|
|
14
|
+
item: GroupedProductItemFragment
|
|
15
|
+
} & AddToCartItemSelector &
|
|
16
|
+
Omit<ActionCardProps, 'value' | 'image' | 'price' | 'title' | 'action'>
|
|
20
17
|
|
|
21
18
|
const typographySizes = {
|
|
22
19
|
small: 'body2',
|
|
@@ -25,23 +22,16 @@ const typographySizes = {
|
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
export function GroupedProductActionCard(props: GroupedProductActionCardProps) {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
name,
|
|
31
|
-
small_image,
|
|
32
|
-
price_range,
|
|
33
|
-
url_key,
|
|
34
|
-
sx = [],
|
|
35
|
-
size = 'large',
|
|
36
|
-
index = 0,
|
|
37
|
-
sku,
|
|
38
|
-
url_rewrites,
|
|
39
|
-
...rest
|
|
40
|
-
} = props
|
|
41
|
-
|
|
25
|
+
const { item, sx = [], size = 'large', index = 0, ...rest } = props
|
|
26
|
+
const { product } = item
|
|
42
27
|
const { control, register } = useFormAddProductsToCart()
|
|
43
|
-
|
|
28
|
+
|
|
29
|
+
if (!product?.sku) return null
|
|
30
|
+
|
|
31
|
+
const { uid, name, small_image, url_key, sku, url_rewrites } = product
|
|
44
32
|
const hasUrl = (url_rewrites ?? []).length > 0
|
|
33
|
+
const qty = item.qty ?? 0
|
|
34
|
+
|
|
45
35
|
return (
|
|
46
36
|
<>
|
|
47
37
|
<input type='hidden' {...register(`cartItems.${index}.sku`)} value={sku} />
|
|
@@ -126,12 +116,20 @@ export function GroupedProductActionCard(props: GroupedProductActionCardProps) {
|
|
|
126
116
|
secondaryAction={
|
|
127
117
|
<AddProductsToCartQuantity
|
|
128
118
|
size='small'
|
|
129
|
-
defaultValue={1}
|
|
130
119
|
index={index}
|
|
120
|
+
defaultValue={qty}
|
|
131
121
|
onMouseDown={(e) => e.stopPropagation()}
|
|
122
|
+
inputProps={{ min: 0 }}
|
|
123
|
+
/>
|
|
124
|
+
}
|
|
125
|
+
price={
|
|
126
|
+
<ProductPagePrice
|
|
127
|
+
index={index}
|
|
128
|
+
product={product}
|
|
129
|
+
defaultValue={qty ?? 0}
|
|
130
|
+
variant='total'
|
|
132
131
|
/>
|
|
133
132
|
}
|
|
134
|
-
price={<ProductListPrice {...price_range.minimum_price} />}
|
|
135
133
|
{...rest}
|
|
136
134
|
/>
|
|
137
135
|
</>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ActionCardLayout, filterNonNullableKeys } from '@graphcommerce/next-ui'
|
|
1
|
+
import { ActionCardLayout, filterNonNullableKeys, nonNullable } from '@graphcommerce/next-ui'
|
|
2
2
|
import { useMemo } from 'react'
|
|
3
|
-
import type { GroupedProductFragment } from '../GroupedProduct.gql'
|
|
3
|
+
import type { GroupedProductFragment } from '../graphql/fragments/GroupedProduct.gql'
|
|
4
4
|
import { GroupedProductActionCard } from './GroupedProductActionCard'
|
|
5
5
|
|
|
6
6
|
export type GroupedProductsProps = {
|
|
@@ -9,21 +9,15 @@ export type GroupedProductsProps = {
|
|
|
9
9
|
|
|
10
10
|
export function GroupedProducts(props: GroupedProductsProps) {
|
|
11
11
|
const { product } = props
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...item.product,
|
|
17
|
-
value: item.product.sku ?? '',
|
|
18
|
-
index: i,
|
|
19
|
-
}))
|
|
20
|
-
}, [product])
|
|
21
|
-
if (!productItems) return null
|
|
12
|
+
|
|
13
|
+
const items = filterNonNullableKeys(product.items, ['position', 'product']).sort(
|
|
14
|
+
(a, b) => a.position - b.position,
|
|
15
|
+
)
|
|
22
16
|
|
|
23
17
|
return (
|
|
24
18
|
<ActionCardLayout>
|
|
25
|
-
{
|
|
26
|
-
<GroupedProductActionCard {
|
|
19
|
+
{items.map((item, index) => (
|
|
20
|
+
<GroupedProductActionCard index={index} item={item} key={item.position} size='medium' />
|
|
27
21
|
))}
|
|
28
22
|
</ActionCardLayout>
|
|
29
23
|
)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-product-grouped",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.1.0-canary.
|
|
5
|
+
"version": "9.1.0-canary.45",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.
|
|
17
|
-
"@graphcommerce/graphql": "^9.1.0-canary.
|
|
18
|
-
"@graphcommerce/image": "^9.1.0-canary.
|
|
19
|
-
"@graphcommerce/magento-cart": "^9.1.0-canary.
|
|
20
|
-
"@graphcommerce/magento-product": "^9.1.0-canary.
|
|
21
|
-
"@graphcommerce/magento-product-simple": "^9.1.0-canary.
|
|
22
|
-
"@graphcommerce/magento-product-virtual": "^9.1.0-canary.
|
|
23
|
-
"@graphcommerce/magento-store": "^9.1.0-canary.
|
|
24
|
-
"@graphcommerce/next-ui": "^9.1.0-canary.
|
|
25
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
|
26
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.45",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.45",
|
|
17
|
+
"@graphcommerce/graphql": "^9.1.0-canary.45",
|
|
18
|
+
"@graphcommerce/image": "^9.1.0-canary.45",
|
|
19
|
+
"@graphcommerce/magento-cart": "^9.1.0-canary.45",
|
|
20
|
+
"@graphcommerce/magento-product": "^9.1.0-canary.45",
|
|
21
|
+
"@graphcommerce/magento-product-simple": "^9.1.0-canary.45",
|
|
22
|
+
"@graphcommerce/magento-product-virtual": "^9.1.0-canary.45",
|
|
23
|
+
"@graphcommerce/magento-store": "^9.1.0-canary.45",
|
|
24
|
+
"@graphcommerce/next-ui": "^9.1.0-canary.45",
|
|
25
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.45",
|
|
26
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.45",
|
|
27
27
|
"@lingui/core": "^4.2.1",
|
|
28
28
|
"@lingui/macro": "^4.2.1",
|
|
29
29
|
"@lingui/react": "^4.2.1",
|