This commit is contained in:
Darren Ethier 2020-02-28 06:51:30 -05:00 committed by GitHub
parent 69ea94378b
commit 6b110d00f2
2 changed files with 17 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/** @typedef { import('@woocommerce/type-defs/hooks').StoreCartItems } StoreCartItems */
/** @typedef { import('@woocommerce/type-defs/hooks').StoreCartItem } StoreCartItem */
/**
* External dependencies
@ -14,10 +14,11 @@ import { useStoreCart } from './use-store-cart';
/**
* This is a custom hook for loading the Store API /cart/ endpoint and
* actions for removing or changing item quantity.
* See also: https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/master/src/RestApi/StoreApi
*
* @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/master/src/RestApi/StoreApi
*
* @param {string} cartItemKey Key for a cart item.
* @return {StoreCartItems} An object exposing data and actions relating to cart items.
* @return {StoreCartItem} An object exposing data and actions relating to cart items.
*/
export const useStoreCartItem = ( cartItemKey ) => {
const { cartItems, cartIsLoading } = useStoreCart();

View File

@ -1,3 +1,7 @@
/**
* @typedef {import('./cart').CartData} CartData
*/
/**
* @typedef {Object} StoreCart
*
@ -24,14 +28,15 @@
*/
/**
* @typedef {Object} StoreCartItems
* @typedef {Object} StoreCartItem
*
* @property {boolean} isLoading True when cart items are being loaded.
* @property {Array} cartItems An array of items in the cart.
* @property {Function} isItemQuantityPending Callback for determining if a cart item
* is currently updating (i.e. remoe / change
* quantity).
* @property {Function} removeItemFromCart Callback for removing a cart item.
* @property {boolean} isLoading True when cart items are being
* loaded.
* @property {CartData} cartData A cart item from the data store.
* @property {Function} isPending Callback for determining if a cart
* item is currently updating (i.e.
* remove / change quantity).
* @property {Function} removeItem Callback for removing a cart item.
*/
export {};
export {};