@graphcommerce/magento-product-downloadable 4.0.58 → 4.1.0

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,21 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1642](https://github.com/graphcommerce-org/graphcommerce/pull/1642) [`ad63ebf4e`](https://github.com/graphcommerce-org/graphcommerce/commit/ad63ebf4e33bfb0e5c9e5e68ab69b14775f3f8a8) Thanks [@paales](https://github.com/paales)! - Introduced `<AddProductsToCartForm/>`, which is allows for adding all product types to the cart with a single react-hook-form form.
8
+
9
+ Which allows you to fully compose the form on the product page without having to modify the page.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`ad63ebf4e`](https://github.com/graphcommerce-org/graphcommerce/commit/ad63ebf4e33bfb0e5c9e5e68ab69b14775f3f8a8), [`b6bf2c941`](https://github.com/graphcommerce-org/graphcommerce/commit/b6bf2c94197ddacbf8f1fc0d352cd0d46e096f30)]:
14
+ - @graphcommerce/magento-product@4.6.0
15
+ - @graphcommerce/magento-store@4.3.0
16
+ - @graphcommerce/next-ui@4.27.0
17
+ - @graphcommerce/magento-cart@4.8.4
18
+
3
19
  ## 4.0.58
4
20
 
5
21
  ### Patch Changes
@@ -1,11 +1,9 @@
1
1
  fragment ProductPageDownloadableQueryFragment on Query {
2
2
  typeProducts: products(filter: { url_key: { eq: $urlKey } }) {
3
- ...ProductSpecs
4
3
  items {
5
4
  __typename
6
5
  uid
7
6
  ... on DownloadableProduct {
8
- ...ProductCustomizable
9
7
  downloadable_product_links {
10
8
  price
11
9
  sample_url
@@ -0,0 +1,18 @@
1
+ fragment DownloadableProductOptions on DownloadableProduct {
2
+ __typename
3
+ uid
4
+ ... on DownloadableProduct {
5
+ downloadable_product_links {
6
+ price
7
+ sample_url
8
+ sort_order
9
+ title
10
+ uid
11
+ }
12
+ downloadable_product_samples {
13
+ title
14
+ sort_order
15
+ sample_url
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,45 @@
1
+ import { useFormAddProductsToCart } from '@graphcommerce/magento-product'
2
+ import { Money } from '@graphcommerce/magento-store'
3
+ import {
4
+ ActionCard,
5
+ ActionCardListForm,
6
+ ActionCardProps,
7
+ filterNonNullableKeys,
8
+ } from '@graphcommerce/next-ui'
9
+ import { useMemo } from 'react'
10
+ import { DownloadableProductOptionsFragment } from './DownloadableProductOptions.gql'
11
+
12
+ type DownloadableProductOptionsProps = {
13
+ product: DownloadableProductOptionsFragment
14
+ index?: number
15
+ }
16
+
17
+ export function DownloadableProductOptions(props: DownloadableProductOptionsProps) {
18
+ const { product, index = 0 } = props
19
+ const { control } = useFormAddProductsToCart()
20
+
21
+ const items = useMemo(
22
+ () =>
23
+ filterNonNullableKeys(product.downloadable_product_links, ['title']).map((item) => {
24
+ const newItem: ActionCardProps = {
25
+ value: item.uid,
26
+ title: item.title,
27
+ price: <Money value={item.price} />,
28
+ }
29
+ return newItem
30
+ }),
31
+ [product.downloadable_product_links],
32
+ )
33
+
34
+ return (
35
+ <ActionCardListForm
36
+ size='medium'
37
+ required
38
+ errorMessage='Please select an option'
39
+ control={control}
40
+ name={`cartItems.${index}.selected_options.0`}
41
+ render={ActionCard}
42
+ items={items}
43
+ />
44
+ )
45
+ }
@@ -0,0 +1 @@
1
+ export * from './DownloadableProductOptions'
@@ -0,0 +1,9 @@
1
+ query DownloadableProductPage($urlKey: String) {
2
+ typeProducts: products(filter: { url_key: { eq: $urlKey } }) {
3
+ items {
4
+ __typename
5
+ uid
6
+ ...DownloadableProductOptions
7
+ }
8
+ }
9
+ }
package/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './DownloadableProductPage.gql'
2
2
  export * from './ProductListItemDownloadable'
3
3
  export * from './ProductListItemDownloadable.gql'
4
+ export * from './components/DownloadableProductOptions'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-product-downloadable",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.0.58",
5
+ "version": "4.1.0",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,8 +19,10 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@graphcommerce/graphql": "3.4.8",
22
- "@graphcommerce/magento-cart": "4.8.3",
23
- "@graphcommerce/magento-product": "4.5.10"
22
+ "@graphcommerce/magento-cart": "4.8.4",
23
+ "@graphcommerce/magento-product": "4.6.0",
24
+ "@graphcommerce/magento-store": "4.3.0",
25
+ "@graphcommerce/next-ui": "4.27.0"
24
26
  },
25
27
  "peerDependencies": {
26
28
  "@lingui/react": "^3.13.2",