/** * Hook to provide all kinds of data for the business logic attached to the bag. */ import { type BagItemActionMetadata, type BagItemDenormalized } from '@farfetch/blackout-redux'; import type { Bag, BagItem, BagQueryBase, Config, DeleteBagItemQuery, PostBagItemData } from '@farfetch/blackout-client'; import type { UseBagOptions } from './types/index.js'; /** * Provides Redux actions and state access, as well as handlers for dealing with * bag business logic. It will fetch bag data from the current user's bag. * A note of attention regarding sending metadata: The hook distinguishes between * 2 types of metadata: bag item metadata and bag action metadata. Bag item metadata * can be sent to the add/update endpoints to set specific bag item metadata and bag * action metadata are used to add context to the action that was performed and can be * used by redux middlewares like analytics to enhance tracking of bag events and this * metadata cannot be sent to the endpoints. Since the hook already have a specific metadata * parameter in its actions, to avoid a breaking change the same parameter is used to specify * both kinds of metadata values but an additional option `internalMetadataList` was added * to filter out the metadata properties that should not be sent to the bag endpoints. * By default it is set to the currently used bag action metadata: 'from', 'affiliation', * 'coupon', 'value' and 'position'. If you need to add more internal metadata parameters * or have an internal metadata parameter be sent to the bag endpoints, pass an appropriate * `internalMetadataList` to have the correct set of metadata parameters being sent in the * appropriate cases. * * @returns All the handlers, state, actions and relevant data needed to manage any bag operation. */ declare const useBag: (options?: UseBagOptions) => { isLoading: boolean; error: import("@farfetch/blackout-client").BlackoutError | null; isFetched: boolean; actions: { fetch: (query?: BagQueryBase, config?: Config) => Promise; reset: () => void; addItem: (productId: PostBagItemData['productId'], { quantity, sizeId, productAggregatorId, }: { quantity: PostBagItemData['quantity']; sizeId: PostBagItemData['size']; productAggregatorId?: PostBagItemData['productAggregatorId']; }, metadata?: PostBagItemData['metadata'], config?: Config | undefined) => Promise; updateItem: (bagItemId: BagItem['id'], { quantity, sizeId, }: { quantity?: number | undefined; sizeId?: number | undefined; }, metadata?: BagItemActionMetadata, config?: Config | undefined) => Promise | undefined; removeItem: (bagItemId: BagItem['id'], query?: DeleteBagItemQuery, metadata?: BagItemActionMetadata, config?: Config) => Promise; }; data: { count: number | undefined; isEmpty: boolean; items: BagItemDenormalized[]; id: string; '@controls'?: { [key: string]: import("@farfetch/blackout-client").HypermediaLink; } | undefined; promocodes: string[]; bagSummary: { currency: string; currencySymbol: string; dateCreated: string; dateUpdated: string; grandTotal: number; subTotalAmount: number; subTotalAmountExclTaxes: number; totalDiscount: number; totalShippingFee: number; totalTaxes: number; totalProductPromotionDiscount: number; formattedGrandTotal: string; formattedSubTotalAmount: string; formattedSubTotalAmountExclTaxes: string; formattedTotalDiscount: string; formattedTotalShippingFee: string; formattedTotalTaxes: string; formattedTotalProductPromotionDiscount: string; taxType: string; }; hadUnavailableItems: boolean; } | undefined; }; export default useBag;