4
0
forked from crowetic/commerce

Make wishlist's useRemoveItem call in WishlistCard consistent with WishlistButton (#578)

This commit is contained in:
Tomek Niezgoda 2021-11-24 13:15:22 +01:00 committed by GitHub
parent d4d22a3ce7
commit e7fc93f9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -11,14 +11,16 @@ import type { Product } from '@commerce/types/product'
import usePrice from '@framework/product/use-price'
import useAddItem from '@framework/cart/use-add-item'
import useRemoveItem from '@framework/wishlist/use-remove-item'
import { Wishlist } from '@commerce/types/wishlist'
interface Props {
product: Product
item: Wishlist
}
const placeholderImg = '/product-img-placeholder.svg'
const WishlistCard: FC<Props> = ({ product }) => {
const WishlistCard: FC<Props> = ({ item }) => {
const product: Product = item.product
const { price } = usePrice({
amount: product.price?.value,
baseAmount: product.price?.retailPrice,
@ -40,7 +42,7 @@ const WishlistCard: FC<Props> = ({ product }) => {
try {
// If this action succeeds then there's no need to do `setRemoving(true)`
// because the component will be removed from the view
await removeItem({ id: product.id! })
await removeItem({ id: item.id! })
} catch (error) {
setRemoving(false)
}

View File

@ -69,7 +69,7 @@ export default function Wishlist() {
{data &&
// @ts-ignore Shopify - Fix this types
data.items?.map((item) => (
<WishlistCard key={item.id} product={item.product! as any} />
<WishlistCard key={item.id} item={item!} />
))}
</div>
)}