@graphcommerce/magento-cart-items 3.1.15 → 3.1.17

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.
@@ -4,13 +4,15 @@ fragment CartItem on CartItemInterface @injectable {
4
4
  product {
5
5
  uid
6
6
  ...ProductLink
7
+ sku
7
8
  name
8
9
  url_key
10
+ sku
9
11
  thumbnail {
10
- url
11
- label
12
+ ...ProductImage
12
13
  }
13
14
  }
15
+
14
16
  prices {
15
17
  discounts {
16
18
  amount {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.1.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`2b5451395`](https://github.com/graphcommerce-org/graphcommerce/commit/2b5451395dc1173de55d18d08968866e561f90ab), [`e76df6dc3`](https://github.com/graphcommerce-org/graphcommerce/commit/e76df6dc37c11c793a5d008ba36932d17dc23855), [`c4ed376e2`](https://github.com/graphcommerce-org/graphcommerce/commit/c4ed376e2c72b16b34704d7d1ca69c074de172ba), [`78d7d51cb`](https://github.com/graphcommerce-org/graphcommerce/commit/78d7d51cb1551601d3a4756cd1f2157a49ff93b9), [`0bd9ea582`](https://github.com/graphcommerce-org/graphcommerce/commit/0bd9ea58230dde79c5fe2cdb07e9860151460270)]:
8
+ - @graphcommerce/magento-product@4.8.0
9
+ - @graphcommerce/next-ui@4.29.0
10
+ - @graphcommerce/magento-cart@4.9.1
11
+ - @graphcommerce/magento-customer@4.12.1
12
+ - @graphcommerce/magento-store@4.3.3
13
+
14
+ ## 3.1.16
15
+
16
+ ### Patch Changes
17
+
18
+ - [#1675](https://github.com/graphcommerce-org/graphcommerce/pull/1675) [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6) Thanks [@paales](https://github.com/paales)! - Added crosssel functionality
19
+
20
+ - Updated dependencies [[`9e630670f`](https://github.com/graphcommerce-org/graphcommerce/commit/9e630670ff6c952ab7b938d890b5509804985cf3), [`cf3518499`](https://github.com/graphcommerce-org/graphcommerce/commit/cf351849999ad6fe73ce2bb258098a7dd301d517), [`2e9fa5984`](https://github.com/graphcommerce-org/graphcommerce/commit/2e9fa5984a07ff14fc1b3a4f62189a26e8e3ecdd), [`adf13069a`](https://github.com/graphcommerce-org/graphcommerce/commit/adf13069af6460c960276b402237371c12fc6dec), [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6), [`8a34f8081`](https://github.com/graphcommerce-org/graphcommerce/commit/8a34f808186274a6fe1d4f309472f1a9c6d00efd), [`3dde492ad`](https://github.com/graphcommerce-org/graphcommerce/commit/3dde492ad3a49d96481eeb7453fb305d0017b1a5)]:
21
+ - @graphcommerce/next-ui@4.28.1
22
+ - @graphcommerce/graphql@3.5.0
23
+ - @graphcommerce/magento-cart@4.9.0
24
+ - @graphcommerce/magento-customer@4.12.0
25
+ - @graphcommerce/magento-product@4.7.3
26
+ - @graphcommerce/magento-store@4.3.2
27
+ - @graphcommerce/image@3.1.10
28
+
3
29
  ## 3.1.15
4
30
 
5
31
  ### Patch Changes
@@ -0,0 +1,64 @@
1
+ import { Image } from '@graphcommerce/image'
2
+ import { Money } from '@graphcommerce/magento-store'
3
+ import { ActionCard, ActionCardProps, responsiveVal } from '@graphcommerce/next-ui'
4
+ import { CartItemFragment } from '../../Api/CartItem.gql'
5
+ import { RemoveItemFromCartFab } from '../../RemoveItemFromCart/RemoveItemFromCartFab'
6
+ import { UpdateItemQuantity } from '../../UpdateItemQuantity/UpdateItemQuantity'
7
+
8
+ export type ActionCartItemProps = Omit<
9
+ ActionCardProps,
10
+ 'value' | 'image' | 'price' | 'title' | 'action'
11
+ >
12
+
13
+ export const productImageSizes = {
14
+ small: responsiveVal(50, 60),
15
+ medium: responsiveVal(60, 80),
16
+ large: responsiveVal(80, 100),
17
+ }
18
+
19
+ export function ActionCartItem(props: CartItemFragment & ActionCartItemProps) {
20
+ const {
21
+ uid,
22
+ quantity,
23
+ prices,
24
+ product: { name, thumbnail },
25
+ sx = [],
26
+ details,
27
+ size = 'medium',
28
+ ...cardProps
29
+ } = props
30
+
31
+ return (
32
+ <ActionCard
33
+ {...cardProps}
34
+ value={uid}
35
+ size={size}
36
+ sx={[{}, ...(Array.isArray(sx) ? sx : [sx])]}
37
+ image={
38
+ thumbnail?.url && (
39
+ <Image
40
+ src={thumbnail?.url}
41
+ width={50}
42
+ height={50}
43
+ sx={{
44
+ width: productImageSizes[size],
45
+ height: productImageSizes[size],
46
+ display: 'block',
47
+ borderRadius: 1,
48
+ }}
49
+ sizes={productImageSizes[size]}
50
+ />
51
+ )
52
+ }
53
+ price={<Money {...prices?.row_total_including_tax} />}
54
+ title={name}
55
+ details={
56
+ <>
57
+ {details}
58
+ <UpdateItemQuantity uid={uid} quantity={quantity} />
59
+ </>
60
+ }
61
+ action={<RemoveItemFromCartFab uid={uid} />}
62
+ />
63
+ )
64
+ }
@@ -0,0 +1,16 @@
1
+ fragment SelectedCustomizableOption on SelectedCustomizableOption {
2
+ customizable_option_uid
3
+ is_required
4
+ label
5
+ type
6
+ values {
7
+ customizable_option_value_uid
8
+ label
9
+ price {
10
+ type
11
+ units
12
+ value
13
+ }
14
+ value
15
+ }
16
+ }
@@ -0,0 +1,36 @@
1
+ import { Money } from '@graphcommerce/magento-store'
2
+ import { filterNonNullableKeys, nonNullable } from '@graphcommerce/next-ui'
3
+ import { Typography } from '@mui/material'
4
+ import { CartItem_ConfigurableCartItem_Fragment } from '../../Api/CartItem.gql'
5
+ import { ActionCartItemProps } from '../ActionCartItem/ActionCartItem'
6
+ import { SelectedCustomizableOptionFragment } from './SelectedCustomizableOption.gql'
7
+
8
+ type ConfigurableActionCartItemProps = {
9
+ customizable_options?: (SelectedCustomizableOptionFragment | null | undefined)[] | null
10
+ }
11
+
12
+ export function SelectedCustomizableOptions(props: ConfigurableActionCartItemProps) {
13
+ const { customizable_options } = props
14
+
15
+ const options = filterNonNullableKeys(customizable_options, [])
16
+
17
+ if (!options.length) return null
18
+
19
+ return (
20
+ <>
21
+ {options.map((option) => (
22
+ <Typography variant='body2' component='div' key={option.customizable_option_uid}>
23
+ <Typography variant='subtitle2' component='span'>
24
+ {option.label}
25
+ </Typography>
26
+ {option.values.filter(nonNullable).map((value) => (
27
+ <span key={value.customizable_option_value_uid}>
28
+ {value.price.value > 0 && <Money value={value.price.value} />} {value?.label}
29
+ {value?.value}
30
+ </span>
31
+ ))}
32
+ </Typography>
33
+ ))}
34
+ </>
35
+ )
36
+ }
@@ -0,0 +1,2 @@
1
+ export * from './SelectedCustomizableOption.gql'
2
+ export * from './SelectedCustomizableOptions'
package/index.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  export * from './Api/CartItem.gql'
2
2
  export * from './Api/CartItems.gql'
3
-
4
3
  export * from './CartItem/CartItem'
5
- export * from './CartItem/CartItemOptionDropdown'
6
4
  export * from './CartItems/CartItems'
7
- export * from './DeliveryLabel/DeliveryLabel'
5
+ export * from './components/ActionCartItem/ActionCartItem'
6
+ export * from './components/SelectedCustomizableOptions/SelectedCustomizableOptions'
8
7
  export * from './RemoveItemFromCart/RemoveItemFromCartFab'
9
8
  export * from './UpdateItemQuantity/UpdateItemQuantity'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-cart-items",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "3.1.15",
5
+ "version": "3.1.17",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,13 +18,13 @@
18
18
  "@playwright/test": "^1.21.1"
19
19
  },
20
20
  "dependencies": {
21
- "@graphcommerce/graphql": "3.4.8",
22
- "@graphcommerce/image": "3.1.9",
23
- "@graphcommerce/magento-cart": "4.8.7",
24
- "@graphcommerce/magento-customer": "4.11.7",
25
- "@graphcommerce/magento-product": "4.7.2",
26
- "@graphcommerce/magento-store": "4.3.1",
27
- "@graphcommerce/next-ui": "4.28.0",
21
+ "@graphcommerce/graphql": "3.5.0",
22
+ "@graphcommerce/image": "3.1.10",
23
+ "@graphcommerce/magento-cart": "4.9.1",
24
+ "@graphcommerce/magento-customer": "4.12.1",
25
+ "@graphcommerce/magento-product": "4.8.0",
26
+ "@graphcommerce/magento-store": "4.3.3",
27
+ "@graphcommerce/next-ui": "4.29.0",
28
28
  "@graphcommerce/react-hook-form": "3.3.5"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,58 +0,0 @@
1
- import { extendableComponent } from '@graphcommerce/next-ui'
2
- import { Box, MenuItem, Select, SelectProps, SxProps, Theme } from '@mui/material'
3
-
4
- export type CartItemOptionDropdownProps = {
5
- label: string
6
- sx?: SxProps<Theme>
7
- } & Pick<SelectProps, 'onChange'>
8
-
9
- const compName = 'CartItem' as const
10
- const parts = ['root', 'label', 'select'] as const
11
- const { classes } = extendableComponent(compName, parts)
12
-
13
- export function CartItemOptionDropdown(props: CartItemOptionDropdownProps) {
14
- const { onChange, label, sx = [] } = props
15
-
16
- return (
17
- <Box
18
- className={classes.root}
19
- sx={[(theme) => ({ marginRight: theme.spacings.xs }), ...(Array.isArray(sx) ? sx : [sx])]}
20
- >
21
- <Box
22
- className={classes.label}
23
- sx={(theme) => ({
24
- letterSpacing: 1,
25
- textTransform: 'uppercase',
26
- fontWeight: 500,
27
- color: theme.palette.text.disabled,
28
- })}
29
- >
30
- {label}
31
- </Box>
32
- <Select
33
- value={1}
34
- onChange={onChange}
35
- className={classes.select}
36
- sx={(theme) => ({
37
- padding: `${theme.spacings.xxs} ${theme.spacings.xxs}`,
38
- border: `1px solid ${theme.palette.divider}`,
39
- borderRadius: '8px',
40
- minWidth: 120,
41
- '&:before': {
42
- borderBottom: 'none',
43
- },
44
- '&:hover, &:active, &:focus': {
45
- '&:before': {
46
- borderBottom: 'none',
47
- },
48
- background: theme.palette.grey['100'],
49
- },
50
- })}
51
- >
52
- <MenuItem value={1}>One</MenuItem>
53
- <MenuItem value={2}>Two</MenuItem>
54
- <MenuItem value={3}>Three</MenuItem>
55
- </Select>
56
- </Box>
57
- )
58
- }
@@ -1,68 +0,0 @@
1
- import { extendableComponent } from '@graphcommerce/next-ui'
2
- import { Box, IconButton, Popover, SxProps, Theme } from '@mui/material'
3
- import React from 'react'
4
-
5
- export type DeliveryLabelProps = { sx?: SxProps<Theme> }
6
-
7
- const name = 'DeliveryLabel' as const
8
- const parts = ['root', 'labelContainer', 'label', 'popover'] as const
9
- const { classes } = extendableComponent(name, parts)
10
-
11
- export function DeliveryLabel(props: DeliveryLabelProps) {
12
- const { sx = [] } = props
13
- const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null)
14
-
15
- const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
16
- setAnchorEl(event.currentTarget)
17
- }
18
- const handleClose = () => setAnchorEl(null)
19
-
20
- const open = Boolean(anchorEl)
21
-
22
- return (
23
- <Box
24
- className={classes.root}
25
- sx={[{ display: 'inline-block' }, ...(Array.isArray(sx) ? sx : [sx])]}
26
- >
27
- <IconButton
28
- component='button'
29
- className={classes.labelContainer}
30
- sx={{ padding: '5px' }}
31
- onClick={handleClick}
32
- size='large'
33
- >
34
- <Box
35
- className={classes.label}
36
- sx={{
37
- borderRadius: '100%',
38
- width: 10,
39
- height: 10,
40
- background: '#01D26A', // TODO: order statuses. green, yellow, red
41
- }}
42
- />
43
- </IconButton>
44
- <Popover
45
- id={open ? 'simple-popover' : undefined}
46
- open={open}
47
- anchorEl={anchorEl}
48
- onClose={handleClose}
49
- anchorOrigin={{
50
- vertical: 'bottom',
51
- horizontal: 'center',
52
- }}
53
- transformOrigin={{
54
- vertical: 'top',
55
- horizontal: 'center',
56
- }}
57
- className={classes.popover}
58
- sx={{
59
- '& > .MuiPaper-root': {
60
- padding: '6px',
61
- },
62
- }}
63
- >
64
- Ordered before <b>23:00</b>, delivery <b>tomorrow</b>
65
- </Popover>
66
- </Box>
67
- )
68
- }