mirror of
https://github.com/vercel/commerce.git
synced 2025-03-14 22:42:33 +00:00
Added use-cart-actions hook
This commit is contained in:
parent
24f6ff792a
commit
21d5a8ea57
13
lib/bigcommerce/cart/use-cart-actions.tsx
Normal file
13
lib/bigcommerce/cart/use-cart-actions.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
import useAddItem from './use-add-item'
|
||||
import useRemoveItem from './use-remove-item'
|
||||
import useUpdateItem from './use-update-item'
|
||||
|
||||
// This hook is probably not going to be used, but it's here
|
||||
// to show how a commerce should be structuring it
|
||||
export default function useCartActions() {
|
||||
const addItem = useAddItem()
|
||||
const updateItem = useUpdateItem()
|
||||
const removeItem = useRemoveItem()
|
||||
|
||||
return { addItem, updateItem, removeItem }
|
||||
}
|
16
lib/commerce/cart/use-cart-actions.tsx
Normal file
16
lib/commerce/cart/use-cart-actions.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import type { Fetcher } from '..'
|
||||
import useAddItem from './use-add-item'
|
||||
import useRemoveItem from './use-remove-item'
|
||||
import useUpdateItem from './use-update-item'
|
||||
|
||||
// This hook is probably not going to be used, but it's here
|
||||
// to show how a commerce should be structuring it
|
||||
export default function useCartActions<T, Input>(
|
||||
fetcher: (fetch: Fetcher<T>, input: Input) => T | Promise<T>
|
||||
) {
|
||||
const addItem = useAddItem<T, Input>(fetcher)
|
||||
const updateItem = useUpdateItem<T, Input>(fetcher)
|
||||
const removeItem = useRemoveItem<T, Input>(fetcher)
|
||||
|
||||
return { addItem, updateItem, removeItem }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user