@graphcommerce/magento-product 4.6.0 → 4.6.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,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1660](https://github.com/graphcommerce-org/graphcommerce/pull/1660) [`48e6522bb`](https://github.com/graphcommerce-org/graphcommerce/commit/48e6522bb9424d4bd77fd77c68065f5625f3ec8d) Thanks [@paales](https://github.com/paales)! - Forward onChange handler for AddProductsToCartButton
8
+
9
+ * [#1660](https://github.com/graphcommerce-org/graphcommerce/pull/1660) [`37b1980a0`](https://github.com/graphcommerce-org/graphcommerce/commit/37b1980a04a4a3d77663b404ae83539620cf65b9) Thanks [@paales](https://github.com/paales)! - Do not static build old product pages when the new product page is used an vice versa
10
+
11
+ * Updated dependencies [[`e5048c5ec`](https://github.com/graphcommerce-org/graphcommerce/commit/e5048c5ec52b83dbe70a246ffdcea65b55a884c6)]:
12
+ - @graphcommerce/ecommerce-ui@1.5.1
13
+ - @graphcommerce/magento-cart@4.8.5
14
+
3
15
  ## 4.6.0
4
16
 
5
17
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import { Button, ButtonProps } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/react'
3
- import { SxProps, Theme } from '@mui/material'
3
+ import { SxProps, Theme, useEventCallback } from '@mui/material'
4
4
  import { useFormAddProductsToCart } from './AddProductsToCartForm'
5
5
 
6
6
  export type AddProductsToCartButtonProps = {
@@ -22,7 +22,14 @@ export type AddProductsToCartButtonProps = {
22
22
 
23
23
  export function AddProductsToCartButton(props: AddProductsToCartButtonProps) {
24
24
  const { formState, setValue } = useFormAddProductsToCart()
25
- const { loading, sku, index = 0 } = props
25
+ const { loading, sku, index = 0, disabled, onClick } = props
26
+
27
+ const clickHandler: NonNullable<AddProductsToCartButtonProps['onClick']> = useEventCallback(
28
+ (e) => {
29
+ setValue(`cartItems.${index}.sku`, sku)
30
+ onClick?.(e)
31
+ },
32
+ )
26
33
 
27
34
  return (
28
35
  <Button
@@ -31,9 +38,9 @@ export function AddProductsToCartButton(props: AddProductsToCartButtonProps) {
31
38
  variant='pill'
32
39
  size='large'
33
40
  {...props}
34
- disabled={Boolean(formState.errors.cartItems?.[index].sku?.message)}
41
+ disabled={Boolean(formState.errors.cartItems?.[index].sku?.message) || disabled}
35
42
  loading={formState.isSubmitting || loading}
36
- onClick={() => setValue(`cartItems.${index}.sku`, sku)}
43
+ onClick={clickHandler}
37
44
  >
38
45
  <Trans id='Add to Cart' />
39
46
  </Button>
@@ -3,12 +3,12 @@ import { useFormAddProductsToCart } from './AddProductsToCartForm'
3
3
 
4
4
  type AddToCartQuantityProps = Omit<
5
5
  NumberFieldElementProps,
6
- 'error' | 'required' | 'inputProps' | 'inputRef' | 'helperText' | 'name'
6
+ 'error' | 'required' | 'inputProps' | 'helperText' | 'name' | 'control' | 'name'
7
7
  > & { index?: number }
8
8
 
9
9
  export function AddProductsToCartQuantity(props: AddToCartQuantityProps) {
10
10
  const { index = 0 } = props
11
- const { formState, control } = useFormAddProductsToCart()
11
+ const { control } = useFormAddProductsToCart()
12
12
 
13
13
  return (
14
14
  <NumberFieldElement
@@ -17,10 +17,9 @@ export function AddProductsToCartQuantity(props: AddToCartQuantityProps) {
17
17
  {...props}
18
18
  required
19
19
  inputProps={{ min: 1 }}
20
- defaultValue='1'
20
+ defaultValue={1}
21
21
  control={control}
22
22
  name={`cartItems.${index}.quantity`}
23
- helperText={formState.isSubmitted && formState.errors.cartItems?.[index].quantity?.message}
24
23
  />
25
24
  )
26
25
  }
@@ -11,7 +11,7 @@ export type ProductTypenames = NonNullable<
11
11
  export async function getProductStaticPaths(
12
12
  client: ApolloClient<NormalizedCacheObject>,
13
13
  locale: string,
14
- typename: ProductTypenames,
14
+ typename?: ProductTypenames,
15
15
  ) {
16
16
  const query = client.query({
17
17
  query: ProductStaticPathsDocument,
@@ -25,7 +25,7 @@ export async function getProductStaticPaths(
25
25
  const paths: Return['paths'] = (await Promise.all(pages))
26
26
  .map((q) => q.data.products?.items)
27
27
  .flat(1)
28
- .filter((item) => item?.__typename === typename)
28
+ .filter((item) => (typename ? item?.__typename === typename : true))
29
29
  .map((p) => ({ params: { url: `${p?.url_key}` }, locale }))
30
30
 
31
31
  return process.env.VERCEL_ENV !== 'production' ? paths.slice(0, 1) : paths
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-product",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.6.0",
5
+ "version": "4.6.1",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,12 +19,12 @@
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/ecommerce-ui": "1.5.0",
22
+ "@graphcommerce/ecommerce-ui": "1.5.1",
23
23
  "@graphcommerce/framer-scroller": "2.1.39",
24
24
  "@graphcommerce/graphql": "3.4.8",
25
25
  "@graphcommerce/graphql-mesh": "4.2.0",
26
26
  "@graphcommerce/image": "3.1.9",
27
- "@graphcommerce/magento-cart": "4.8.4",
27
+ "@graphcommerce/magento-cart": "4.8.5",
28
28
  "@graphcommerce/magento-store": "4.3.0",
29
29
  "@graphcommerce/next-ui": "4.27.0",
30
30
  "schema-dts": "^1.1.0"