forked from crowetic/commerce
Moved the fetcher to its own file
This commit is contained in:
parent
c4870a05e8
commit
75d485d35a
@ -1,10 +1,5 @@
|
|||||||
import { FetcherError } from '@commerce/utils/errors'
|
import { FetcherError } from '@commerce/utils/errors'
|
||||||
import type { Fetcher } from '@commerce/utils/types'
|
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) {
|
async function getText(res: Response) {
|
||||||
try {
|
try {
|
||||||
@ -43,15 +38,4 @@ const fetcher: Fetcher = async ({
|
|||||||
throw await getError(res)
|
throw await getError(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const bigcommerceProvider = {
|
export default fetcher
|
||||||
locale: 'en-us',
|
|
||||||
cartCookie: 'bc_cartId',
|
|
||||||
fetcher,
|
|
||||||
cartNormalizer: normalizeCart,
|
|
||||||
cart: { useCart },
|
|
||||||
wishlist: { useWishlist },
|
|
||||||
customer: { useCustomer },
|
|
||||||
products: { useSearch },
|
|
||||||
}
|
|
||||||
|
|
||||||
export type BigcommerceProvider = typeof bigcommerceProvider
|
|
17
framework/bigcommerce/provider.ts
Normal file
17
framework/bigcommerce/provider.ts
Normal 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
|
Loading…
x
Reference in New Issue
Block a user