forked from crowetic/commerce
add single module for useCart
This commit is contained in:
parent
939bc388bb
commit
48e4cef4e7
@ -1,5 +1,5 @@
|
|||||||
import { HookFetcher, HookDeps } from '@lib/commerce/utils/types'
|
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'
|
import type { Cart } from '../api/cart'
|
||||||
|
|
||||||
const defaultOpts = {
|
const defaultOpts = {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import { HookFetcher } from '@lib/commerce/utils/types'
|
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 type { ItemBody, AddItemBody } from '../api/cart'
|
||||||
import { Cart, useCart } from '.'
|
import { Cart, useCart } from '.'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import { HookFetcher } from '@lib/commerce/utils/types'
|
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 type { RemoveItemBody } from '../api/cart'
|
||||||
import { Cart, useCart } from '.'
|
import { Cart, useCart } from '.'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
import { HookFetcher } from '@lib/commerce/utils/types'
|
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 type { ItemBody, UpdateItemBody } from '../api/cart'
|
||||||
import { fetcher as removeFetcher } from './use-remove-item'
|
import { fetcher as removeFetcher } from './use-remove-item'
|
||||||
import { Cart, useCart } from '.'
|
import { Cart, useCart } from '.'
|
||||||
|
@ -7,7 +7,7 @@ export type CartResponse<C> = responseInterface<C, Error> & {
|
|||||||
isEmpty: boolean
|
isEmpty: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCart<T>(
|
export default function useCart<T>(
|
||||||
deps: [string | undefined, string | undefined, ...HookDeps[]],
|
deps: [string | undefined, string | undefined, ...HookDeps[]],
|
||||||
fetcherFn: HookFetcher<T, HookDeps[]>,
|
fetcherFn: HookFetcher<T, HookDeps[]>,
|
||||||
swrOptions?: ConfigInterface<T | null>
|
swrOptions?: ConfigInterface<T | null>
|
Loading…
x
Reference in New Issue
Block a user