4
0
forked from crowetic/commerce

Minor changes

This commit is contained in:
Luis Alvarez 2021-01-25 15:03:59 -05:00
parent 905d0324f0
commit 1588fcf6bb
5 changed files with 7 additions and 14 deletions

View File

@ -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, {

View File

@ -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
View File

@ -0,0 +1 @@
interface Cart extends BaseCart {}

View File

@ -25,7 +25,7 @@ const useResponse: UseResponse = (response, { descriptors, normalizer }) => {
? {
data: {
get() {
return normalizer(response.data)
return response.data && normalizer(response.data)
},
enumerable: true,
},

View File

@ -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"]
}