diff --git a/framework/bigcommerce/customer/get-customer-wishlist.ts b/framework/bigcommerce/customer/get-customer-wishlist.ts index a3c7413cc..e854ff933 100644 --- a/framework/bigcommerce/customer/get-customer-wishlist.ts +++ b/framework/bigcommerce/customer/get-customer-wishlist.ts @@ -68,7 +68,7 @@ async function getCustomerWishlist({ const productsById = graphqlData.products.reduce<{ [k: number]: ProductEdge }>((prods, p) => { - prods[p.node.entityId] = p + prods[Number(p.node.entityId)] = p as any return prods }, {}) // Populate the wishlist items with the graphql products diff --git a/framework/bigcommerce/product/get-product.ts b/framework/bigcommerce/product/get-product.ts index 3624a9cca..7d77eb194 100644 --- a/framework/bigcommerce/product/get-product.ts +++ b/framework/bigcommerce/product/get-product.ts @@ -3,6 +3,7 @@ import setProductLocaleMeta from '../api/utils/set-product-locale-meta' import { productInfoFragment } from '../api/fragments/product' import { BigcommerceConfig, getConfig } from '../api' import { normalizeProduct } from '@framework/lib/normalize' +import type { Product } from '@commerce/types' export const getProductQuery = /* GraphQL */ ` query getProduct( diff --git a/framework/bigcommerce/provider.tsx b/framework/bigcommerce/provider.tsx index 6fd02e304..e8ac29cf5 100644 --- a/framework/bigcommerce/provider.tsx +++ b/framework/bigcommerce/provider.tsx @@ -107,7 +107,7 @@ const useWishlist: HookHandler< const { data: customer } = useCustomer() const response = useData({ input: [ - ['customerId', customer?.id], + ['customerId', (customer as any)?.id], ['includeProducts', input.includeProducts], ], swrOptions: { diff --git a/framework/bigcommerce/wishlist/use-add-item.tsx b/framework/bigcommerce/wishlist/use-add-item.tsx index 6e7d9de41..eb961951a 100644 --- a/framework/bigcommerce/wishlist/use-add-item.tsx +++ b/framework/bigcommerce/wishlist/use-add-item.tsx @@ -1,19 +1,23 @@ import { useCallback } from 'react' import { HookFetcher } from '@commerce/utils/types' import { CommerceError } from '@commerce/utils/errors' -import useWishlistAddItem from '@commerce/wishlist/use-add-item' +import useWishlistAddItem, { + AddItemInput, +} from '@commerce/wishlist/use-add-item' +import { UseWishlistInput } from '@commerce/wishlist/use-wishlist' import type { ItemBody, AddItemBody } from '../api/wishlist' import useCustomer from '../customer/use-customer' -import useWishlist, { UseWishlistOptions, Wishlist } from './use-wishlist' +import useWishlist from './use-wishlist' +import type { BigcommerceProvider } from '..' const defaultOpts = { url: '/api/bigcommerce/wishlist', method: 'POST', } -export type AddItemInput = ItemBody +// export type AddItemInput = ItemBody -export const fetcher: HookFetcher = ( +export const fetcher: HookFetcher = ( options, { item }, fetch @@ -27,13 +31,13 @@ export const fetcher: HookFetcher = ( } export function extendHook(customFetcher: typeof fetcher) { - const useAddItem = (opts?: UseWishlistOptions) => { + const useAddItem = (opts?: UseWishlistInput) => { const { data: customer } = useCustomer() const { revalidate } = useWishlist(opts) const fn = useWishlistAddItem(defaultOpts, customFetcher) return useCallback( - async function addItem(input: AddItemInput) { + async function addItem(input: AddItemInput) { if (!customer) { // A signed customer is required in order to have a wishlist throw new CommerceError({ diff --git a/framework/bigcommerce/wishlist/use-remove-item.tsx b/framework/bigcommerce/wishlist/use-remove-item.tsx index 86614a21a..d00b3e78b 100644 --- a/framework/bigcommerce/wishlist/use-remove-item.tsx +++ b/framework/bigcommerce/wishlist/use-remove-item.tsx @@ -4,7 +4,7 @@ import { CommerceError } from '@commerce/utils/errors' import useWishlistRemoveItem from '@commerce/wishlist/use-remove-item' import type { RemoveItemBody } from '../api/wishlist' import useCustomer from '../customer/use-customer' -import useWishlist, { UseWishlistOptions, Wishlist } from './use-wishlist' +import useWishlist from './use-wishlist' const defaultOpts = { url: '/api/bigcommerce/wishlist', @@ -15,7 +15,7 @@ export type RemoveItemInput = { id: string | number } -export const fetcher: HookFetcher = ( +export const fetcher: HookFetcher = ( options, { itemId }, fetch @@ -28,10 +28,10 @@ export const fetcher: HookFetcher = ( } export function extendHook(customFetcher: typeof fetcher) { - const useRemoveItem = (opts?: UseWishlistOptions) => { + const useRemoveItem = (opts?: any) => { const { data: customer } = useCustomer() const { revalidate } = useWishlist(opts) - const fn = useWishlistRemoveItem( + const fn = useWishlistRemoveItem( defaultOpts, customFetcher ) diff --git a/framework/commerce/wishlist/use-add-item.tsx b/framework/commerce/wishlist/use-add-item.tsx index f6c069f2b..d9b513694 100644 --- a/framework/commerce/wishlist/use-add-item.tsx +++ b/framework/commerce/wishlist/use-add-item.tsx @@ -1,4 +1,11 @@ import useAction from '../utils/use-action' +import type { CartItemBody } from '../types' + +// Input expected by the action returned by the `useAddItem` hook +// export interface AddItemInput { +// includeProducts?: boolean +// } +export type AddItemInput = T const useAddItem = useAction diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 3d2971eed..83aeaa54c 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -61,7 +61,7 @@ export default function Slug({ return router.isFallback ? (

Loading...

// TODO (BC) Add Skeleton Views ) : ( - + ) } diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index a3f25d0e7..6de798411 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -44,7 +44,7 @@ export default function Wishlist() { ) : ( data && data.items?.map((item) => ( - + )) )}