mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
Updated mutation types
This commit is contained in:
@@ -3,17 +3,13 @@ import type { MutationHook } from '@commerce/utils/types'
|
||||
import { CommerceError } from '@commerce/utils/errors'
|
||||
import useAddItem, { UseAddItem } from '@commerce/cart/use-add-item'
|
||||
import { normalizeCart } from '../lib/normalize'
|
||||
import type {
|
||||
Cart,
|
||||
BigcommerceCart,
|
||||
CartItemBody,
|
||||
AddCartItemBody,
|
||||
} from '../types'
|
||||
import type { BigcommerceCart, AddItemHook } from '../types/cart'
|
||||
import useCart from './use-cart'
|
||||
|
||||
export default useAddItem as UseAddItem<typeof handler>
|
||||
|
||||
export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||
// export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||
export const handler: MutationHook<AddItemHook> = {
|
||||
fetchOptions: {
|
||||
url: '/api/bigcommerce/cart',
|
||||
method: 'POST',
|
||||
@@ -28,7 +24,7 @@ export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||
})
|
||||
}
|
||||
|
||||
const data = await fetch<BigcommerceCart, AddCartItemBody>({
|
||||
const data = await fetch<BigcommerceCart>({
|
||||
...options,
|
||||
body: { item },
|
||||
})
|
||||
|
@@ -45,7 +45,13 @@ export type CartItemBody = Core.CartItemBody & {
|
||||
|
||||
export type CartHooks = Core.CartHooks & {
|
||||
getCart: { data: Cart | null }
|
||||
addItem: { data: Cart; body: { item: CartItemBody } }
|
||||
addItem: {
|
||||
data: Cart
|
||||
body: { item: CartItemBody }
|
||||
input: CartItemBody
|
||||
fetchInput: CartItemBody
|
||||
actionInput: CartItemBody
|
||||
}
|
||||
updateItem: { data: Cart; body: { item: CartItemBody } }
|
||||
removeItem: { data: Cart | null }
|
||||
}
|
||||
|
Reference in New Issue
Block a user