mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
fix: Wishlist flow
This commit is contained in:
parent
5ce768866d
commit
6c060582ec
@ -6,11 +6,11 @@ export function emptyHook() {
|
||||
const localWishlist = localStorage.getItem('wishlist')
|
||||
if (localWishlist) {
|
||||
wishlist = JSON.parse(localWishlist)
|
||||
if (!wishlist.includes(options.variantId)) {
|
||||
wishlist.push(options.variantId)
|
||||
if (!wishlist.includes(options.productId)) {
|
||||
wishlist.push(options.productId)
|
||||
}
|
||||
} else {
|
||||
wishlist.push(options.variantId)
|
||||
wishlist.push(options.productId)
|
||||
}
|
||||
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
||||
return wishlist
|
||||
|
@ -11,7 +11,7 @@ export function emptyHook(options?: Options) {
|
||||
wishlist = wishlist.filter((p: string) => p !== id)
|
||||
}
|
||||
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
||||
return Promise.resolve()
|
||||
return wishlist
|
||||
}
|
||||
|
||||
return useEmptyHook
|
||||
|
@ -41,8 +41,9 @@ export function extendHook(
|
||||
const wishlist = JSON.parse(getWishlist)
|
||||
const items = wishlist.map((wishlist: string) => {
|
||||
const [product] = data.products.filter((p) => p.id === wishlist) as any
|
||||
const [variant] = product.variants
|
||||
return {
|
||||
variant_id: wishlist,
|
||||
variant_id: variant.id,
|
||||
product_id: wishlist,
|
||||
id: wishlist,
|
||||
product,
|
||||
|
Loading…
x
Reference in New Issue
Block a user