Added wishlist button component

This commit is contained in:
Luis Alvarez
2020-10-26 17:13:34 -05:00
parent c2954d8e88
commit e91a6791d5
6 changed files with 79 additions and 9 deletions

View File

@@ -41,7 +41,7 @@ async function getCustomerWishlist({
const { data } = await config.storeApiFetch<
RecursivePartial<{ data: Wishlist[] }>
>(`/v3/wishlists/customer_id=${variables.customerId}`)
>(`/v3/wishlists?customer_id=${variables.customerId}`)
const wishlists = (data as RecursiveRequired<typeof data>) ?? []
const wishlist = wishlists[0]

View File

@@ -38,11 +38,14 @@ const addItem: WishlistHandlers['addItem'] = async ({
items: [parseWishlistItem(item)],
}
: {
name: 'Wishlist',
customer_id: customerId,
items: [parseWishlistItem(item)],
is_public: false,
}
),
}
const { data } = wishlist
? await config.storeApiFetch(`/v3/wishlists/${wishlist.id}/items`, options)
: await config.storeApiFetch('/v3/wishlists', options)

View File

@@ -75,7 +75,7 @@ const wishlistApi: BigcommerceApiHandler<Wishlist, WishlistHandlers> = async (
const { wishlistId, itemId, customerId } = req.body
// Return current wishlist info
if (req.method === 'GET' && wishlistId) {
if (req.method === 'GET') {
const body = { customerToken }
return await handlers['getWishlist']({ req, res, config, body })
}