@commercelayer/react-components
Version:
The Official Commerce Layer React Components
17 lines (16 loc) • 1.12 kB
TypeScript
import type { createOrder, OrderState, addToCart } from '../reducers/OrderReducer';
type TAddToCartParams = Omit<Parameters<typeof addToCart>[number], 'buyNowMode' | 'state' | 'dispatch' | 'setLocalOrder' | 'errors' | 'checkoutUrl' | 'persistKey' | 'config'>;
type TCreateCartParams = Pick<Parameters<typeof createOrder>[number], 'orderAttributes' | 'orderMetadata'>;
interface TReturnOrder extends Omit<OrderState, 'loading' | 'include' | 'includeLoaded' | 'withoutIncludes' | 'orderId'> {
/** Refetch the current order and update the context */
reloadOrder: () => Promise<OrderState['order']>;
/** Allow to add a SKU or a Bundle to the order stored in the context */
addToCart: (params: TAddToCartParams) => ReturnType<typeof addToCart>;
/** Allow to create a new order and store it in the OrderContainer context */
createOrder: (params: TCreateCartParams) => Promise<string | undefined>;
}
/**
* React Hook that provides access to the order context stored in the `<OrderContainer>` component.
**/
export declare function useOrderContainer(): TReturnOrder;
export default useOrderContainer;