Skip to content

Commit

Permalink
Make wishlist's useRemoveItem call in WishlistCard consistent with Wi…
Browse files Browse the repository at this point in the history
…shlistButton (vercel#578)
  • Loading branch information
tniezg authored Nov 24, 2021
1 parent d4d22a3 commit e7fc93f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions components/wishlist/WishlistCard/WishlistCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pages/wishlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
)}
Expand Down

0 comments on commit e7fc93f

Please sign in to comment.