Fix missing images

This commit is contained in:
cond0r 2021-04-08 14:10:17 +03:00
parent f20771a2c3
commit a2c963f73b
2 changed files with 6 additions and 4 deletions

View File

@ -34,7 +34,7 @@ const ProductCard: FC<Props> = ({
{product?.images && (
<Image
quality="85"
src={product.images[0].url || placeholderImg}
src={product.images[0]?.url || placeholderImg}
alt={product.name || 'Product Image'}
height={320}
width={320}
@ -70,7 +70,7 @@ const ProductCard: FC<Props> = ({
<Image
alt={product.name || 'Product Image'}
className={s.productImage}
src={product.images[0].url || placeholderImg}
src={product.images[0]?.url || placeholderImg}
height={540}
width={540}
quality="85"

View File

@ -12,6 +12,8 @@ import usePrice from '@framework/product/use-price'
import useAddItem from '@framework/cart/use-add-item'
import useRemoveItem from '@framework/wishlist/use-remove-item'
const placeholderImg = '/product-img-placeholder.svg'
interface Props {
product: Product
}
@ -58,10 +60,10 @@ const WishlistCard: FC<Props> = ({ product }) => {
<div className={cn(s.root, { 'opacity-75 pointer-events-none': removing })}>
<div className={`col-span-3 ${s.productBg}`}>
<Image
src={product.images[0].url}
src={product.images[0]?.url || placeholderImg}
width={400}
height={400}
alt={product.images[0].alt || 'Product Image'}
alt={product.images[0]?.alt || 'Product Image'}
/>
</div>