mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Minor changes
This commit is contained in:
@@ -10,9 +10,7 @@ const defaultOpts = {
|
||||
method: 'GET',
|
||||
}
|
||||
|
||||
type UseCartResponse = BigcommerceCart & Cart
|
||||
|
||||
export const fetcher: HookFetcher<UseCartResponse | null, CartInput> = (
|
||||
export const fetcher: HookFetcher<BigcommerceCart | null, CartInput> = (
|
||||
options,
|
||||
{ cartId },
|
||||
fetch
|
||||
@@ -22,7 +20,7 @@ export const fetcher: HookFetcher<UseCartResponse | null, CartInput> = (
|
||||
|
||||
export function extendHook(
|
||||
customFetcher: typeof fetcher,
|
||||
swrOptions?: SwrOptions<UseCartResponse | null, CartInput>
|
||||
swrOptions?: SwrOptions<BigcommerceCart | null, CartInput>
|
||||
) {
|
||||
const useCart = () => {
|
||||
const response = useCommerceCart(defaultOpts, [], customFetcher, {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import type { Cart as BigCommerceCart } from '../api/cart'
|
||||
import type { Cart as BigcommerceCart } from '../api/cart'
|
||||
import update from './immutability'
|
||||
|
||||
function normalizeProductOption(productOption: any) {
|
||||
@@ -68,7 +68,7 @@ export function normalizeProduct(productNode: any): Product {
|
||||
})
|
||||
}
|
||||
|
||||
export function normalizeCart(data: BigCommerceCart): Cart {
|
||||
export function normalizeCart(data: BigcommerceCart): Cart {
|
||||
const d: BaseCart = data && {
|
||||
id: data.id,
|
||||
customerId: String(data.customer_id),
|
||||
|
1
framework/bigcommerce/types.d.ts
vendored
Normal file
1
framework/bigcommerce/types.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
interface Cart extends BaseCart {}
|
@@ -25,7 +25,7 @@ const useResponse: UseResponse = (response, { descriptors, normalizer }) => {
|
||||
? {
|
||||
data: {
|
||||
get() {
|
||||
return normalizer(response.data)
|
||||
return response.data && normalizer(response.data)
|
||||
},
|
||||
enumerable: true,
|
||||
},
|
||||
|
Reference in New Issue
Block a user