mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
23 lines
575 B
TypeScript
23 lines
575 B
TypeScript
import { useCallback, useMemo } from 'react'
|
|
|
|
export function emptyHook() {
|
|
const useEmptyHook = async (options: any = {}) => {
|
|
let wishlist = []
|
|
const localWishlist = localStorage.getItem('wishlist')
|
|
if (localWishlist) {
|
|
wishlist = JSON.parse(localWishlist)
|
|
if (!wishlist.includes(options.variantId)) {
|
|
wishlist.push(options.variantId)
|
|
}
|
|
} else {
|
|
wishlist.push(options.variantId)
|
|
}
|
|
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
|
return wishlist
|
|
}
|
|
|
|
return useEmptyHook
|
|
}
|
|
|
|
export default emptyHook
|