Remove normalizers from the hooks

This commit is contained in:
Luis Alvarez
2021-03-31 22:53:30 -06:00
parent 6d06d8b705
commit c9f13989ec
7 changed files with 13 additions and 32 deletions

View File

@@ -1,7 +1,6 @@
import { useMemo } from 'react'
import { SWRHook } from '@commerce/utils/types'
import useCart, { UseCart } from '@commerce/cart/use-cart'
import { normalizeCart } from '../lib/normalize'
import type { GetCartHook } from '../types/cart'
export default useCart as UseCart<typeof handler>
@@ -11,10 +10,6 @@ export const handler: SWRHook<GetCartHook> = {
url: '/api/bigcommerce/cart',
method: 'GET',
},
async fetcher({ input: { cartId }, options, fetch }) {
const data = cartId ? await fetch(options) : null
return data && normalizeCart(data)
},
useHook: ({ useData }) => (input) => {
const response = useData({
swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },