import { BaseBlackcart, ILearnMoreModalConfig, IMoneyData, IValidatorCart, IViolationMessage } from '@blackcart/base'; /** * @interface IBlackcartProps * @property {string} shopDomain - store shopify domain that is registered in * Blackcart system during onboarding process (e.g. my-store.myshopify.com) * @property {IValidatorCart} cart - Initial cart state; * @property {function} clearCart - callback function that is called when we * request you to clear the cart. For example, when we redirect a customer from * Blackcart Checkout with completed order we request to clear the cart. * @property {string} selectedCurrency - Current storefront selected currency in * ISO format (USD, CAD...); * @property {boolean} isProduction - default to true. If set to false the * library can initialize even if you have not set Blackcart program to Live * mode via Merchant Portal * @property {boolean} useModal - default to false. Indicates if a Javascript modal * will be used on a storefront. Initiates a modal component in the constructor method. * @property {ILearnMoreModalConfig} modalConfig - if useModal set to true, the configuration for * Javascript modal can be provided. If not, the default one will be used. * @property {function} moneyFormatter - default to international money formatting. Can be provided * a custom function. All prices that are rendered by Blackcart will be formatted with these rules; */ export interface IBlackcartProps { shopDomain: string; cart: IValidatorCart; clearCart: () => void; selectedCurrency: string; isProduction?: boolean; useModal?: boolean; modalConfig?: ILearnMoreModalConfig; moneyFormatter?: (value: number) => string; } /** * @interface IBlackcartData * @property {boolean} isInitializing - Blackcart initialization is asynchronous process. * indicates the state of initialization. * @property {function} isTBYBQualifiedCart -Getter to get the validated * state of the current TBYB cart; * @returns {boolean} * @property {function} isTBYBItem - Checks if the provided variant a valid TBYB item in a cart. * @property {string} variantId - variant id of a cart item to check; * @returns boolean * @property {function} cartViolations - returns a violation * type, message and description in case the cart is invalid for TBYB * @returns {IViolationMessage | null} * @property {function} setCart - must be called everytime cart has been updated; * @property {IValidatorCart} newCart - an updated cart; * @property {BaseBlackcart} blackcart - instance of BaseBlackcart class; * @property {IMoneyData | null} payTodayTotal - parsed money amount that a customer * needs to pay on checkout for current cart; * @property {IMoneyData | null} deposit - represents a deposit amount in case of * valid TBYB cart; * @property {IValidatorCart} bcCart - returns the current instance of TBYB cart that * has validated TBYB line items; * @property {function} setCurrency - Must be called every time the storefront * currency changes by a user action; * @property {string} newCurrency - selected currency in ISO format * @property {function} showBlackcartModal - used to display pure Javascript Info modal if * useModal flag is set to true; * @property {EventTarget} eventTrigger - Optional. If provided, returns focus * to the trigger element after modal is dismissed; * @property {function} goToBlackcartCheckout - redirects to Blackcart checkout if * current cart is qualified for TBYB; */ export interface IBlackcartData { bcCart?: IValidatorCart; deposit?: IMoneyData | null; goToBlackcartCheckout?: () => void; isInitializing: boolean; isTBYBQualifiedCart: () => boolean; isTBYBItem: (variantId: string) => boolean; cartViolations: () => IViolationMessage | null; setCart: (newCart: IValidatorCart) => void; baseBlackcart?: BaseBlackcart; payTodayTotal?: IMoneyData | null; setCurrency?: (newCurrency: string) => void; showBlackcartModal?: (eventTrigger?: EventTarget) => void; } export declare type IBlackcartContext = IBlackcartProps & IBlackcartData;