forked from crowetic/commerce
Minor changes
This commit is contained in:
parent
905d0324f0
commit
1588fcf6bb
@ -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,
|
||||
},
|
||||
|
@ -26,12 +26,6 @@
|
||||
"@framework": ["framework/bigcommerce"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"framework/types.d.ts",
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/*.js"
|
||||
],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||
"exclude": ["node_modules", "components/wishlist"]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user