mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
21 lines
523 B
TypeScript
21 lines
523 B
TypeScript
type Options = {
|
|
includeProducts?: boolean
|
|
}
|
|
|
|
export function emptyHook(options?: Options) {
|
|
const useEmptyHook = async ({ id }: { id: string | number }) => {
|
|
let wishlist = []
|
|
const localWishlist = localStorage.getItem('wishlist')
|
|
if (localWishlist) {
|
|
wishlist = JSON.parse(localWishlist)
|
|
wishlist = wishlist.filter((p: string) => p !== id)
|
|
}
|
|
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
|
return Promise.resolve()
|
|
}
|
|
|
|
return useEmptyHook
|
|
}
|
|
|
|
export default emptyHook
|