forked from crowetic/commerce
Updated use-cart types
This commit is contained in:
parent
444456d376
commit
89e7793d10
@ -1,7 +1,7 @@
|
|||||||
import type { responseInterface, ConfigInterface } from 'swr'
|
import type { responseInterface } from 'swr'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
import type { HookInput, HookFetcher, HookFetcherOptions } from '../utils/types'
|
import type { HookInput, HookFetcher, HookFetcherOptions } from '../utils/types'
|
||||||
import useData from '../utils/use-data'
|
import useData, { SwrOptions } from '../utils/use-data'
|
||||||
import { useCommerce } from '..'
|
import { useCommerce } from '..'
|
||||||
|
|
||||||
export type CartResponse<C> = responseInterface<C, Error> & {
|
export type CartResponse<C> = responseInterface<C, Error> & {
|
||||||
@ -12,11 +12,11 @@ export type CartInput = {
|
|||||||
cartId: string | undefined
|
cartId: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useCart<T>(
|
export default function useCart<Result>(
|
||||||
options: HookFetcherOptions,
|
options: HookFetcherOptions,
|
||||||
input: HookInput,
|
input: HookInput,
|
||||||
fetcherFn: HookFetcher<T | null, CartInput>,
|
fetcherFn: HookFetcher<Result, CartInput>,
|
||||||
swrOptions?: ConfigInterface<T | null>
|
swrOptions?: SwrOptions<Result, CartInput>
|
||||||
) {
|
) {
|
||||||
const { cartCookie } = useCommerce()
|
const { cartCookie } = useCommerce()
|
||||||
|
|
||||||
@ -27,5 +27,5 @@ export default function useCart<T>(
|
|||||||
|
|
||||||
const response = useData(options, input, fetcher, swrOptions)
|
const response = useData(options, input, fetcher, swrOptions)
|
||||||
|
|
||||||
return Object.assign(response, { isEmpty: true }) as CartResponse<T>
|
return Object.assign(response, { isEmpty: true }) as CartResponse<Result>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user