mirror of
https://github.com/vercel/commerce.git
synced 2025-04-29 14:27:50 +00:00
Updated cart hook
This commit is contained in:
parent
b1e6aa25b5
commit
ec1377850e
@ -7,9 +7,14 @@ import {
|
|||||||
export type Cart = any
|
export type Cart = any
|
||||||
|
|
||||||
export const CartProvider: FC = ({ children }) => {
|
export const CartProvider: FC = ({ children }) => {
|
||||||
return <CommerceCartProvider query="">{children}</CommerceCartProvider>
|
return <CommerceCartProvider url="/api/cart">{children}</CommerceCartProvider>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCart() {
|
export function useCart() {
|
||||||
return useCommerceCart<Cart>()
|
const cart = useCommerceCart<Cart>()
|
||||||
|
|
||||||
|
// TODO: Do something to make this prop work
|
||||||
|
cart.isEmpty = true
|
||||||
|
|
||||||
|
return cart
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,9 @@ const CartProvider: FC<CartProviderProps> = ({ children, query, url }) => {
|
|||||||
const { fetcher } = useCommerce()
|
const { fetcher } = useCommerce()
|
||||||
const cartId = getCartCookie()
|
const cartId = getCartCookie()
|
||||||
const response = useSWR(() => (cartId ? [url, query] : null), fetcher)
|
const response = useSWR(() => (cartId ? [url, query] : null), fetcher)
|
||||||
// TODO: Do something to make this prop work
|
|
||||||
const isEmpty = true
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CartContext.Provider value={{ ...response, isEmpty }}>
|
<CartContext.Provider value={{ ...response, isEmpty: true }}>
|
||||||
{children}
|
{children}
|
||||||
</CartContext.Provider>
|
</CartContext.Provider>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user