forked from crowetic/commerce
Fix cart item image error (#600)
This commit is contained in:
parent
647b06cb52
commit
ea1bbcf1bb
@ -3,7 +3,6 @@ import cn from 'classnames'
|
|||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import s from './CartItem.module.css'
|
import s from './CartItem.module.css'
|
||||||
import { Trash, Plus, Minus, Cross } from '@components/icons'
|
|
||||||
import { useUI } from '@components/ui/context'
|
import { useUI } from '@components/ui/context'
|
||||||
import type { LineItem } from '@commerce/types/cart'
|
import type { LineItem } from '@commerce/types/cart'
|
||||||
import usePrice from '@framework/product/use-price'
|
import usePrice from '@framework/product/use-price'
|
||||||
@ -18,6 +17,8 @@ type ItemOption = {
|
|||||||
valueId: number
|
valueId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const placeholderImg = '/product-img-placeholder.svg'
|
||||||
|
|
||||||
const CartItem = ({
|
const CartItem = ({
|
||||||
item,
|
item,
|
||||||
variant = 'default',
|
variant = 'default',
|
||||||
@ -91,8 +92,8 @@ const CartItem = ({
|
|||||||
className={s.productImage}
|
className={s.productImage}
|
||||||
width={150}
|
width={150}
|
||||||
height={150}
|
height={150}
|
||||||
src={item.variant.image!.url}
|
src={item.variant.image?.url || placeholderImg}
|
||||||
alt={item.variant.image!.altText}
|
alt={item.variant.image?.altText || "Product Image"}
|
||||||
unoptimized
|
unoptimized
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user