Moved the fetcher to its own file

This commit is contained in:
Luis Alvarez 2021-02-15 18:50:52 -05:00
parent c4870a05e8
commit 75d485d35a
2 changed files with 18 additions and 17 deletions

View File

@ -1,10 +1,5 @@
import { FetcherError } from '@commerce/utils/errors'
import type { Fetcher } from '@commerce/utils/types'
import { normalizeCart } from './lib/normalize'
import { handler as useCart } from './cart/use-cart'
import { handler as useWishlist } from './wishlist/use-wishlist'
import { handler as useCustomer } from './customer/use-customer'
import { handler as useSearch } from './product/use-search'
async function getText(res: Response) {
try {
@ -43,15 +38,4 @@ const fetcher: Fetcher = async ({
throw await getError(res)
}
export const bigcommerceProvider = {
locale: 'en-us',
cartCookie: 'bc_cartId',
fetcher,
cartNormalizer: normalizeCart,
cart: { useCart },
wishlist: { useWishlist },
customer: { useCustomer },
products: { useSearch },
}
export type BigcommerceProvider = typeof bigcommerceProvider
export default fetcher

View File

@ -0,0 +1,17 @@
import { handler as useCart } from './cart/use-cart'
import { handler as useWishlist } from './wishlist/use-wishlist'
import { handler as useCustomer } from './customer/use-customer'
import { handler as useSearch } from './product/use-search'
import fetcher from './fetcher'
export const bigcommerceProvider = {
locale: 'en-us',
cartCookie: 'bc_cartId',
fetcher,
cart: { useCart },
wishlist: { useWishlist },
customer: { useCustomer },
products: { useSearch },
}
export type BigcommerceProvider = typeof bigcommerceProvider