4
0
forked from crowetic/commerce

add single module for useCart

This commit is contained in:
Luis Alvarez 2020-10-09 17:21:39 -05:00
parent 939bc388bb
commit 48e4cef4e7
5 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import { HookFetcher, HookDeps } from '@lib/commerce/utils/types'
import { useCart as useCommerceCart } from '@lib/commerce/cart'
import useCommerceCart from '@lib/commerce/cart/use-cart'
import type { Cart } from '../api/cart'
const defaultOpts = {

View File

@ -1,6 +1,6 @@
import { useCallback } from 'react'
import { HookFetcher } from '@lib/commerce/utils/types'
import { default as useCartAddItem } from '@lib/commerce/cart/use-add-item'
import useCartAddItem from '@lib/commerce/cart/use-add-item'
import type { ItemBody, AddItemBody } from '../api/cart'
import { Cart, useCart } from '.'

View File

@ -1,6 +1,6 @@
import { useCallback } from 'react'
import { HookFetcher } from '@lib/commerce/utils/types'
import { default as useCartRemoveItem } from '@lib/commerce/cart/use-remove-item'
import useCartRemoveItem from '@lib/commerce/cart/use-remove-item'
import type { RemoveItemBody } from '../api/cart'
import { Cart, useCart } from '.'

View File

@ -1,7 +1,7 @@
import { useCallback } from 'react'
import debounce from 'lodash.debounce'
import { HookFetcher } from '@lib/commerce/utils/types'
import { default as useCartUpdateItem } from '@lib/commerce/cart/use-update-item'
import useCartUpdateItem from '@lib/commerce/cart/use-update-item'
import type { ItemBody, UpdateItemBody } from '../api/cart'
import { fetcher as removeFetcher } from './use-remove-item'
import { Cart, useCart } from '.'

View File

@ -7,7 +7,7 @@ export type CartResponse<C> = responseInterface<C, Error> & {
isEmpty: boolean
}
export function useCart<T>(
export default function useCart<T>(
deps: [string | undefined, string | undefined, ...HookDeps[]],
fetcherFn: HookFetcher<T, HookDeps[]>,
swrOptions?: ConfigInterface<T | null>