@graphcommerce/magento-product-downloadable 9.1.0-canary.17 → 9.1.0-canary.19
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 +12 -0
- package/README.md +6 -0
- package/components/DownloadableAccountMenuItem/DownloadableAccountMenuItem.tsx +2 -0
- package/components/DownloadableProductOptions/DownloadableProductOptions.tsx +15 -9
- package/components/DownloadsPage/DownloadsPage.tsx +2 -2
- package/components/ProductListItemDownloadable/ProductListItemDownloadable.tsx +1 -1
- package/graphql/fragments/DownloadableItemsLinks.graphql +5 -0
- package/graphql/fragments/DownloadableProductLinks.graphql +7 -0
- package/graphql/fragments/DownloadableProductSamples.graphql +5 -0
- package/graphql/index.ts +11 -0
- package/{DownloadableCartItem → graphql/inject}/DownloadableCartItem.graphql +6 -1
- package/graphql/inject/DownloadableCreditMemoItem.graphql +6 -0
- package/graphql/inject/DownloadableInvoiceItem.graphql +5 -0
- package/graphql/inject/DownloadableOrderItem.graphql +5 -0
- package/graphql/inject/ProductPageItemDownloadable.graphql +12 -0
- package/index.ts +1 -2
- package/package.json +12 -12
- package/plugins/DownloadableCartItemActionCard.tsx +25 -12
- package/plugins/DownloadableCreditMemoItem.tsx +34 -0
- package/plugins/DownloadableInvoiceItem.tsx +34 -0
- package/plugins/DownloadableOrderItem.tsx +30 -0
- package/plugins/DownloadableProductPagePrice.tsx +12 -9
- package/plugins/Downloadable_cartItemToCartItemInput.ts +3 -7
- package/components/DownloadableCartItemOptions/DownloadableCartItemOptions.tsx +0 -39
- package/components/DownloadableProductOptions/DownloadableProductOptions.graphql +0 -18
- /package/{components/DownloadableAccountMenuItem → graphql/inject}/DownloadableAccountMenuItem.graphql +0 -0
- /package/{components/ProductListItemDownloadable → graphql/inject}/ProductListItemDownloadable.graphql +0 -0
- /package/{components/DownloadsPage → graphql/queries}/DownloadsPage.graphql +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 9.1.0-canary.19
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`6b2b44c`](https://github.com/graphcommerce-org/graphcommerce/commit/6b2b44ca853279144d7768067f3462d4d4bf0af1) - Implement the Cart options as priceModifiers so the logic can be somewhat re-used for multiple locations ([@paales](https://github.com/paales))
|
8
|
+
|
9
|
+
- [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`2409514`](https://github.com/graphcommerce-org/graphcommerce/commit/240951428ac0bdc11649f4190b6d51c004680b34) - Order/Invoice/CreditMemo and Shipment views ([@paales](https://github.com/paales))
|
10
|
+
|
11
|
+
- [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`ef441bf`](https://github.com/graphcommerce-org/graphcommerce/commit/ef441bf44a23519e395f4b2143465a5e46bf2e7e) - Support for links_purchased_separately and links_title ([@paales](https://github.com/paales))
|
12
|
+
|
13
|
+
## 9.1.0-canary.18
|
14
|
+
|
3
15
|
## 9.1.0-canary.17
|
4
16
|
|
5
17
|
## 9.1.0-canary.16
|
package/README.md
CHANGED
@@ -20,6 +20,8 @@ export function DownloadableAccountMenuItem(props: StoreCreditAccountMenuItemPro
|
|
20
20
|
const items = filterNonNullableKeys(downloadable?.items)
|
21
21
|
const count = items.length
|
22
22
|
|
23
|
+
if (!count) return null
|
24
|
+
|
23
25
|
return (
|
24
26
|
<AccountMenuItem
|
25
27
|
href='/account/downloads'
|
@@ -11,19 +11,26 @@ import {
|
|
11
11
|
} from '@graphcommerce/next-ui'
|
12
12
|
import { Box, Link } from '@mui/material'
|
13
13
|
import { useMemo } from 'react'
|
14
|
-
import type {
|
14
|
+
import type { ProductPageItemDownloadableFragment } from '../../graphql'
|
15
15
|
|
16
16
|
export type DownloadableProductOptionsProps = AddToCartItemSelector & {
|
17
|
-
product:
|
17
|
+
product: ProductPageItemDownloadableFragment
|
18
18
|
}
|
19
19
|
|
20
20
|
export function DownloadableProductOptions(props: DownloadableProductOptionsProps) {
|
21
21
|
const { product, index = 0 } = props
|
22
22
|
const { control } = useFormAddProductsToCart()
|
23
23
|
|
24
|
+
const {
|
25
|
+
links_purchased_separately,
|
26
|
+
links_title,
|
27
|
+
downloadable_product_links,
|
28
|
+
downloadable_product_samples,
|
29
|
+
} = product
|
30
|
+
|
24
31
|
const options = useMemo(
|
25
32
|
() =>
|
26
|
-
filterNonNullableKeys(
|
33
|
+
filterNonNullableKeys(downloadable_product_links, ['title']).map((item) => {
|
27
34
|
const newItem: ActionCardProps = {
|
28
35
|
value: item.uid,
|
29
36
|
title: item.title,
|
@@ -32,10 +39,10 @@ export function DownloadableProductOptions(props: DownloadableProductOptionsProp
|
|
32
39
|
}
|
33
40
|
return newItem
|
34
41
|
}),
|
35
|
-
[
|
42
|
+
[downloadable_product_links],
|
36
43
|
)
|
37
44
|
|
38
|
-
const samples = filterNonNullableKeys(
|
45
|
+
const samples = filterNonNullableKeys(downloadable_product_samples, [
|
39
46
|
'sort_order',
|
40
47
|
'title',
|
41
48
|
'sample_url',
|
@@ -44,14 +51,13 @@ export function DownloadableProductOptions(props: DownloadableProductOptionsProp
|
|
44
51
|
return (
|
45
52
|
<>
|
46
53
|
<Box>
|
47
|
-
<SectionHeader labelLeft=
|
54
|
+
<SectionHeader labelLeft={links_title} />
|
48
55
|
<ActionCardListForm
|
49
|
-
multiple
|
56
|
+
multiple={links_purchased_separately !== 1}
|
50
57
|
size='medium'
|
51
58
|
required
|
52
|
-
errorMessage='Please select an option'
|
53
59
|
control={control}
|
54
|
-
name={`cartItems.${index}.
|
60
|
+
name={`cartItems.${index}.selected_options_record.downloadable`}
|
55
61
|
render={ActionCard}
|
56
62
|
items={options}
|
57
63
|
/>
|
@@ -22,7 +22,7 @@ import { i18n } from '@lingui/core'
|
|
22
22
|
import { t, Trans } from '@lingui/macro'
|
23
23
|
import { Box, Container, Link, Typography } from '@mui/material'
|
24
24
|
import React from 'react'
|
25
|
-
import { DownloadsPageDocument } from '
|
25
|
+
import { DownloadsPageDocument } from '../../graphql/queries/DownloadsPage.gql'
|
26
26
|
|
27
27
|
export type DownloadsPageProps = Record<string, unknown>
|
28
28
|
type DownloadsGetStaticProps = GetStaticProps<Record<string, unknown>, DownloadsPageProps>
|
@@ -57,7 +57,7 @@ export function DownloadsPage() {
|
|
57
57
|
</LayoutTitle>
|
58
58
|
|
59
59
|
<Box>
|
60
|
-
<SectionContainer labelLeft={<Trans id='
|
60
|
+
<SectionContainer labelLeft={<Trans id='Downloads'>Downloads</Trans>}>
|
61
61
|
<Box
|
62
62
|
sx={{
|
63
63
|
display: 'grid',
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ProductListItemProps } from '@graphcommerce/magento-product'
|
2
2
|
import { ProductListItem } from '@graphcommerce/magento-product'
|
3
|
-
import type { ProductListItemDownloadableFragment } from '
|
3
|
+
import type { ProductListItemDownloadableFragment } from '../../graphql'
|
4
4
|
|
5
5
|
export type ProductListItemDownloadableProps = ProductListItemDownloadableFragment &
|
6
6
|
ProductListItemProps
|
package/graphql/index.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
export * from './fragments/DownloadableItemsLinks.gql'
|
2
|
+
export * from './fragments/DownloadableProductLinks.gql'
|
3
|
+
export * from './fragments/DownloadableProductSamples.gql'
|
4
|
+
export * from './inject/DownloadableAccountMenuItem.gql'
|
5
|
+
export * from './inject/DownloadableCartItem.gql'
|
6
|
+
export * from './inject/DownloadableCreditMemoItem.gql'
|
7
|
+
export * from './inject/DownloadableInvoiceItem.gql'
|
8
|
+
export * from './inject/DownloadableOrderItem.gql'
|
9
|
+
export * from './inject/ProductListItemDownloadable.gql'
|
10
|
+
export * from './inject/ProductPageItemDownloadable.gql'
|
11
|
+
export * from './queries/DownloadsPage.gql'
|
@@ -2,7 +2,6 @@ fragment DownloadableCartItem on DownloadableCartItem @inject(into: ["CartItem"]
|
|
2
2
|
customizable_options {
|
3
3
|
...SelectedCustomizableOption
|
4
4
|
}
|
5
|
-
|
6
5
|
links {
|
7
6
|
uid
|
8
7
|
price
|
@@ -14,4 +13,10 @@ fragment DownloadableCartItem on DownloadableCartItem @inject(into: ["CartItem"]
|
|
14
13
|
sort_order
|
15
14
|
title
|
16
15
|
}
|
16
|
+
product {
|
17
|
+
__typename
|
18
|
+
... on DownloadableProduct {
|
19
|
+
links_title
|
20
|
+
}
|
21
|
+
}
|
17
22
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
fragment ProductPageItemDownloadable on DownloadableProduct @inject(into: ["ProductPageItem"]) {
|
2
|
+
__typename
|
3
|
+
uid
|
4
|
+
downloadable_product_links {
|
5
|
+
...DownloadableProductLinks
|
6
|
+
}
|
7
|
+
downloadable_product_samples {
|
8
|
+
...DownloadableProductSamples
|
9
|
+
}
|
10
|
+
links_purchased_separately
|
11
|
+
links_title
|
12
|
+
}
|
package/index.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
export * from './components/ProductListItemDownloadable/ProductListItemDownloadable'
|
2
|
-
export * from './components/ProductListItemDownloadable/ProductListItemDownloadable.gql'
|
3
2
|
export * from './components/DownloadableProductOptions'
|
4
3
|
export * from './components/DownloadableAccountMenuItem/DownloadableAccountMenuItem'
|
5
|
-
export * from './components/DownloadableAccountMenuItem/DownloadableAccountMenuItem.gql'
|
6
4
|
export * from './components/DownloadsPage/DownloadsPage'
|
5
|
+
export * from './graphql'
|
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": "9.1.0-canary.
|
5
|
+
"version": "9.1.0-canary.19",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -12,17 +12,17 @@
|
|
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/magento-cart": "^9.1.0-canary.
|
19
|
-
"@graphcommerce/magento-cart-items": "^9.1.0-canary.
|
20
|
-
"@graphcommerce/magento-customer": "^9.1.0-canary.
|
21
|
-
"@graphcommerce/magento-product": "^9.1.0-canary.
|
22
|
-
"@graphcommerce/magento-store": "^9.1.0-canary.
|
23
|
-
"@graphcommerce/next-ui": "^9.1.0-canary.
|
24
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
25
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.19",
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.19",
|
17
|
+
"@graphcommerce/graphql": "^9.1.0-canary.19",
|
18
|
+
"@graphcommerce/magento-cart": "^9.1.0-canary.19",
|
19
|
+
"@graphcommerce/magento-cart-items": "^9.1.0-canary.19",
|
20
|
+
"@graphcommerce/magento-customer": "^9.1.0-canary.19",
|
21
|
+
"@graphcommerce/magento-product": "^9.1.0-canary.19",
|
22
|
+
"@graphcommerce/magento-store": "^9.1.0-canary.19",
|
23
|
+
"@graphcommerce/next-ui": "^9.1.0-canary.19",
|
24
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.19",
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.19",
|
26
26
|
"@lingui/core": "^4.2.1",
|
27
27
|
"@lingui/macro": "^4.2.1",
|
28
28
|
"@lingui/react": "^4.2.1",
|
@@ -1,13 +1,10 @@
|
|
1
1
|
import {
|
2
|
-
|
2
|
+
selectedCustomizableOptionsModifiers,
|
3
3
|
type CartItemActionCardProps,
|
4
4
|
} from '@graphcommerce/magento-cart-items'
|
5
|
-
import {
|
5
|
+
import type { PriceModifier } from '@graphcommerce/magento-store'
|
6
6
|
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
7
|
-
import { filterNonNullableKeys
|
8
|
-
import { Box } from '@mui/material'
|
9
|
-
import React from 'react'
|
10
|
-
import { DownloadableCartItemOptions } from '../components/DownloadableCartItemOptions/DownloadableCartItemOptions'
|
7
|
+
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
11
8
|
|
12
9
|
export const config: PluginConfig = {
|
13
10
|
type: 'component',
|
@@ -15,16 +12,32 @@ export const config: PluginConfig = {
|
|
15
12
|
}
|
16
13
|
|
17
14
|
export function CartItemActionCard(props: PluginProps<CartItemActionCardProps>) {
|
18
|
-
const { Prev, ...rest } = props
|
15
|
+
const { Prev, priceModifiers = [], ...rest } = props
|
16
|
+
|
17
|
+
if (
|
18
|
+
rest.cartItem.__typename !== 'DownloadableCartItem' ||
|
19
|
+
rest.cartItem.product.__typename !== 'DownloadableProduct'
|
20
|
+
)
|
21
|
+
return <Prev priceModifiers={priceModifiers} {...rest} />
|
22
|
+
|
23
|
+
const downloadableModifier: PriceModifier = {
|
24
|
+
key: 'downloadable',
|
25
|
+
label: rest.cartItem.product.links_title,
|
26
|
+
items: filterNonNullableKeys(rest.cartItem.links).map((link) => ({
|
27
|
+
key: link.uid,
|
28
|
+
label: link.title,
|
29
|
+
amount: link.price,
|
30
|
+
})),
|
31
|
+
}
|
19
32
|
|
20
33
|
return (
|
21
34
|
<Prev
|
22
35
|
{...rest}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
36
|
+
priceModifiers={[
|
37
|
+
...priceModifiers,
|
38
|
+
downloadableModifier,
|
39
|
+
...selectedCustomizableOptionsModifiers(rest.cartItem),
|
40
|
+
]}
|
28
41
|
/>
|
29
42
|
)
|
30
43
|
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { CreditMemoItemProps } from '@graphcommerce/magento-customer'
|
2
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
3
|
+
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
4
|
+
import { Trans } from '@lingui/macro'
|
5
|
+
|
6
|
+
export const config: PluginConfig = {
|
7
|
+
type: 'component',
|
8
|
+
module: '@graphcommerce/magento-customer',
|
9
|
+
}
|
10
|
+
|
11
|
+
export function CreditMemoItem(props: PluginProps<CreditMemoItemProps>) {
|
12
|
+
const { Prev, ...rest } = props
|
13
|
+
|
14
|
+
if (rest.item.__typename !== 'DownloadableCreditMemoItem') return <Prev {...rest} />
|
15
|
+
|
16
|
+
return (
|
17
|
+
<Prev
|
18
|
+
{...rest}
|
19
|
+
priceModifiers={[
|
20
|
+
...(rest.priceModifiers ?? []),
|
21
|
+
{
|
22
|
+
key: 'downloadable-links',
|
23
|
+
label: <Trans id='Downloads'>Downloads</Trans>,
|
24
|
+
items: filterNonNullableKeys(rest.item.downloadable_links)
|
25
|
+
.sort((a, b) => a.sort_order - b.sort_order)
|
26
|
+
.map((link) => ({
|
27
|
+
key: link.uid,
|
28
|
+
label: link.title,
|
29
|
+
})),
|
30
|
+
},
|
31
|
+
]}
|
32
|
+
/>
|
33
|
+
)
|
34
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { InvoiceItemProps } from '@graphcommerce/magento-customer'
|
2
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
3
|
+
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
4
|
+
import { Trans } from '@lingui/macro'
|
5
|
+
|
6
|
+
export const config: PluginConfig = {
|
7
|
+
type: 'component',
|
8
|
+
module: '@graphcommerce/magento-customer',
|
9
|
+
}
|
10
|
+
|
11
|
+
export function InvoiceItem(props: PluginProps<InvoiceItemProps>) {
|
12
|
+
const { Prev, ...rest } = props
|
13
|
+
|
14
|
+
if (rest.item.__typename !== 'DownloadableInvoiceItem') return <Prev {...rest} />
|
15
|
+
|
16
|
+
return (
|
17
|
+
<Prev
|
18
|
+
{...rest}
|
19
|
+
priceModifiers={[
|
20
|
+
...(rest.priceModifiers ?? []),
|
21
|
+
{
|
22
|
+
key: 'downloadable-links',
|
23
|
+
label: <Trans id='Downloads'>Downloads</Trans>,
|
24
|
+
items: filterNonNullableKeys(rest.item.downloadable_links)
|
25
|
+
.sort((a, b) => a.sort_order - b.sort_order)
|
26
|
+
.map((link) => ({
|
27
|
+
key: link.uid,
|
28
|
+
label: link.title,
|
29
|
+
})),
|
30
|
+
},
|
31
|
+
]}
|
32
|
+
/>
|
33
|
+
)
|
34
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import type { OrderItemProps } from '@graphcommerce/magento-customer'
|
2
|
+
import type { PriceModifier } from '@graphcommerce/magento-store'
|
3
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
4
|
+
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
5
|
+
|
6
|
+
export const config: PluginConfig = {
|
7
|
+
type: 'component',
|
8
|
+
module: '@graphcommerce/magento-customer',
|
9
|
+
}
|
10
|
+
|
11
|
+
export function OrderItem(props: PluginProps<OrderItemProps>) {
|
12
|
+
const { Prev, ...rest } = props
|
13
|
+
|
14
|
+
if (rest.item.__typename !== 'DownloadableOrderItem') return <Prev {...rest} />
|
15
|
+
|
16
|
+
return (
|
17
|
+
<Prev
|
18
|
+
{...rest}
|
19
|
+
priceModifiers={[
|
20
|
+
...(rest.priceModifiers ?? []),
|
21
|
+
...filterNonNullableKeys(rest.item.downloadable_links)
|
22
|
+
.sort((a, b) => a.sort_order - b.sort_order)
|
23
|
+
.map<PriceModifier>((link) => ({
|
24
|
+
key: link.uid,
|
25
|
+
label: link.title,
|
26
|
+
})),
|
27
|
+
]}
|
28
|
+
/>
|
29
|
+
)
|
30
|
+
}
|
@@ -5,8 +5,8 @@ import {
|
|
5
5
|
type ProductPagePriceProps,
|
6
6
|
} from '@graphcommerce/magento-product'
|
7
7
|
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
8
|
-
import
|
9
|
-
import type {
|
8
|
+
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
9
|
+
import type { ProductPageItemDownloadableFragment } from '../graphql'
|
10
10
|
|
11
11
|
export const config: PluginConfig = {
|
12
12
|
type: 'component',
|
@@ -16,11 +16,11 @@ export const config: PluginConfig = {
|
|
16
16
|
function isDownloadableProduct(
|
17
17
|
product:
|
18
18
|
| ProductPagePriceProps['product']
|
19
|
-
| (ProductPagePriceProps['product'] &
|
20
|
-
): product is ProductPagePriceProps['product'] &
|
19
|
+
| (ProductPagePriceProps['product'] & ProductPageItemDownloadableFragment),
|
20
|
+
): product is ProductPagePriceProps['product'] & ProductPageItemDownloadableFragment {
|
21
21
|
return (
|
22
22
|
product.__typename === 'DownloadableProduct' &&
|
23
|
-
Array.isArray((product as
|
23
|
+
Array.isArray((product as ProductPageItemDownloadableFragment).downloadable_product_links)
|
24
24
|
)
|
25
25
|
}
|
26
26
|
|
@@ -32,13 +32,16 @@ export function ProductPagePrice(
|
|
32
32
|
const form = useFormAddProductsToCart()
|
33
33
|
const selectedOptions = useWatch({
|
34
34
|
control: form.control,
|
35
|
-
name: `cartItems.${index}.
|
35
|
+
name: `cartItems.${index}.selected_options_record.downloadable`,
|
36
36
|
})
|
37
37
|
|
38
|
-
if (!isDownloadableProduct(product)
|
38
|
+
if (!isDownloadableProduct(product) || !selectedOptions)
|
39
|
+
return <Prev product={product} index={index} {...rest} />
|
39
40
|
|
40
|
-
const selectedLinks = product.downloadable_product_links
|
41
|
-
selectedOptions
|
41
|
+
const selectedLinks = filterNonNullableKeys(product.downloadable_product_links).filter((link) =>
|
42
|
+
Array.isArray(selectedOptions)
|
43
|
+
? selectedOptions.includes(link.uid)
|
44
|
+
: selectedOptions === link.uid,
|
42
45
|
)
|
43
46
|
|
44
47
|
const totalPrice = selectedLinks?.reduce((acc, link) => acc + (link?.price ?? 0), 0) ?? 0
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { CartItemInput } from '@graphcommerce/graphql-mesh'
|
2
1
|
import { type cartItemToCartItemInput as cartItemToCartItemInputType } from '@graphcommerce/magento-cart-items'
|
3
2
|
import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
|
4
3
|
import { filterNonNullableKeys, isTypename } from '@graphcommerce/next-ui'
|
@@ -22,15 +21,12 @@ export const cartItemToCartItemInput: FunctionPlugin<typeof cartItemToCartItemIn
|
|
22
21
|
const links = filterNonNullableKeys(cartItem.links, ['title', 'price'])
|
23
22
|
const productLinks = filterNonNullableKeys(product.downloadable_product_links, ['title', 'price'])
|
24
23
|
|
25
|
-
const
|
24
|
+
const downloadable: string[] = []
|
26
25
|
|
27
26
|
productLinks.forEach((link) => {
|
28
27
|
const linkIndex = links.findIndex((l) => l.uid === link.uid)
|
29
|
-
if (linkIndex !== -1)
|
28
|
+
if (linkIndex !== -1) downloadable.push(link.uid)
|
30
29
|
})
|
31
30
|
|
32
|
-
return {
|
33
|
-
...result,
|
34
|
-
selected_options,
|
35
|
-
} satisfies CartItemInput
|
31
|
+
return { ...result, selected_options_record: { ...result.selected_options_record, downloadable } }
|
36
32
|
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
SelectedCustomizableOptions,
|
3
|
-
type CartItemActionCardProps,
|
4
|
-
} from '@graphcommerce/magento-cart-items'
|
5
|
-
import { Money } from '@graphcommerce/magento-store'
|
6
|
-
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
7
|
-
import { Box } from '@mui/material'
|
8
|
-
import React from 'react'
|
9
|
-
|
10
|
-
export function DownloadableCartItemOptions(props: CartItemActionCardProps) {
|
11
|
-
const { cartItem } = props
|
12
|
-
|
13
|
-
if (cartItem.__typename !== 'DownloadableCartItem') return null
|
14
|
-
|
15
|
-
const links = filterNonNullableKeys(cartItem.links, ['title', 'price'])
|
16
|
-
|
17
|
-
return (
|
18
|
-
<>
|
19
|
-
<Box
|
20
|
-
sx={(theme) => ({
|
21
|
-
display: 'grid',
|
22
|
-
gridTemplateColumns: 'auto auto',
|
23
|
-
gap: theme.spacings.xs,
|
24
|
-
})}
|
25
|
-
>
|
26
|
-
{links.map((link) => (
|
27
|
-
<React.Fragment key={link.uid}>
|
28
|
-
<span>{link.title}</span>
|
29
|
-
<Box>
|
30
|
-
<Money value={link.price} currency={cartItem.prices?.price.currency} />
|
31
|
-
</Box>
|
32
|
-
</React.Fragment>
|
33
|
-
))}
|
34
|
-
</Box>
|
35
|
-
|
36
|
-
<SelectedCustomizableOptions {...cartItem} />
|
37
|
-
</>
|
38
|
-
)
|
39
|
-
}
|
@@ -1,18 +0,0 @@
|
|
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
|
-
}
|
File without changes
|
File without changes
|
File without changes
|