diff --git a/lib/bigcommerce/api/cart/index.ts b/lib/bigcommerce/api/cart/index.ts index 8c307dda8..f0c8afb2a 100644 --- a/lib/bigcommerce/api/cart/index.ts +++ b/lib/bigcommerce/api/cart/index.ts @@ -35,6 +35,11 @@ export type Cart = { base_amount: number discount_amount: number cart_amount: number + redirect_urls: { + cart_url: string + checkout_url: string + embedded_checkout_url: string + } line_items: { custom_items: any[] digital_items: any[] diff --git a/lib/bigcommerce/api/customers.ts b/lib/bigcommerce/api/customers.ts index 0ac75e3b6..a70f0a5b4 100644 --- a/lib/bigcommerce/api/customers.ts +++ b/lib/bigcommerce/api/customers.ts @@ -5,8 +5,16 @@ import createApiHandler, { import isAllowedMethod from './utils/is-allowed-method' import { BigcommerceApiError } from './utils/errors' +type Body = Partial | undefined + export type Customer = any +export type AddCustomerBody = { item: any } + +export type CartHandlers = { + addItem: BigcommerceHandler> +} + const METHODS = ['POST'] const customersApi: BigcommerceApiHandler = async ( diff --git a/lib/commerce/cart/use-add-item.tsx b/lib/commerce/cart/use-add-item.tsx index 5445f9e11..9ff7306f4 100644 --- a/lib/commerce/cart/use-add-item.tsx +++ b/lib/commerce/cart/use-add-item.tsx @@ -1,5 +1,5 @@ import { useCallback } from 'react' -import { HookFetcher, HookFetcherOptions } from '../utils/types' +import type { HookFetcher, HookFetcherOptions } from '../utils/types' import { useCommerce } from '..' export default function useAddItem( diff --git a/lib/commerce/cart/use-cart-actions.tsx b/lib/commerce/cart/use-cart-actions.tsx index f95219a9d..3ba4b2e1a 100644 --- a/lib/commerce/cart/use-cart-actions.tsx +++ b/lib/commerce/cart/use-cart-actions.tsx @@ -1,4 +1,4 @@ -import type { Fetcher } from '..' +import type { HookFetcher, HookFetcherOptions } from '../utils/types' import useAddItem from './use-add-item' import useRemoveItem from './use-remove-item' import useUpdateItem from './use-update-item' @@ -6,11 +6,12 @@ import useUpdateItem from './use-update-item' // This hook is probably not going to be used, but it's here // to show how a commerce should be structuring it export default function useCartActions( - fetcher: (fetch: Fetcher, input: Input) => T | Promise + options: HookFetcherOptions, + fetcher: HookFetcher ) { - const addItem = useAddItem(fetcher) - const updateItem = useUpdateItem(fetcher) - const removeItem = useRemoveItem(fetcher) + const addItem = useAddItem(options, fetcher) + const updateItem = useUpdateItem(options, fetcher) + const removeItem = useRemoveItem(options, fetcher) return { addItem, updateItem, removeItem } } diff --git a/lib/commerce/cart/use-remove-item.tsx b/lib/commerce/cart/use-remove-item.tsx index 66aa370dd..66076dacc 100644 --- a/lib/commerce/cart/use-remove-item.tsx +++ b/lib/commerce/cart/use-remove-item.tsx @@ -1,5 +1,5 @@ import { useCallback } from 'react' -import { HookFetcher, HookFetcherOptions } from '../utils/types' +import type { HookFetcher, HookFetcherOptions } from '../utils/types' import { useCommerce } from '..' export default function useRemoveItem( diff --git a/lib/commerce/cart/use-update-item.tsx b/lib/commerce/cart/use-update-item.tsx index ac9344a74..18eb80399 100644 --- a/lib/commerce/cart/use-update-item.tsx +++ b/lib/commerce/cart/use-update-item.tsx @@ -1,5 +1,5 @@ import { useCallback } from 'react' -import { HookFetcher, HookFetcherOptions } from '../utils/types' +import type { HookFetcher, HookFetcherOptions } from '../utils/types' import { useCommerce } from '..' export default function useUpdateItem(