Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / @skava-features/header   js

Repository URL to install this package:

Version: 0.1.7 

/ dist / src / state / cart / container.d.ts

/// <reference types="react" />
import ObservableContainer from 'src/bootstrapper/connectData/ObservableContainer';
import { OneProduct } from 'src/state/__product';
import { listContainer } from 'state/list/container';
import { CartInfoType, CartProductType } from 'src/state/__product/typings';
import { UpdateBagResponse, AddToBagResponse, SaveForLater, CartDetailsTypes } from './types';
import { getListItems as GetListItemsResponse, Cart, CartBuyInfo, CartProduct, CartInfo, AddToBagInput } from '@skava/graphql-bindings';
/**
 * @description there are a few ways we can do this relational data
 *
 * @example 1. since we have stores for Product already and can store the api data there
 *             because those state-tree stores already have simplified transforms
 *
 * @example 2. even just importing Catalog/Product or /ProductDisplay/Product, can extend it easily
 *             then just do .create(apiData).toJSON() and it would be transformed
 *
 * @example 3. or you can do the same transforms in this store
 *
 */
declare class CartContainer extends ObservableContainer {
    static debugName: string;
    cartDetails: CartDetailsTypes;
    /**
     * @todo need to take save for later out of cart
     */
    saveForLaterProduct: OneProduct[];
    cartCount: number;
    saveListItemsId: Array<{
        listId: string | number;
        productId: string | number;
    }>;
    saveListId: string;
    _shouldShowPlaceHolderOnRender: boolean;
    fetched: {
        hasFetchedSaveForLater: boolean;
        hasFetchedCart: boolean;
    };
    /**
     * @example this.fetchCartApi = this.fetchCartApi.bind(this) === fetchCart = () => {}
     * @description debug, fetch cart, update view
     */
    constructor();
    /**
     * @public
     * @type {Action}
     * @see CartApi
     *
     * @param {Object} params object (in this case I think it is ProductDetails???)
     * return value is not used unless the view needs it
     *
     * @description this is the interface provided to the views/components
     *              we can use this to call CartApi
     *              and CartApi class can use
     */
    handleAddToCartResponse(addToCartResponse: AddToBagResponse, viewCartResponse: Cart): boolean;
    addToBag(item: OneProduct | AddToBagInput, transformOneProduct?: boolean): Promise<boolean>;
    /**
     * @public
     * @alias readCart
     * @alias updateCart
     *
     * @todo - this is being used in a component that is unmounted... -.-
     * @todo this alias is wrong since it's a real api call I didn't know
     * @todo @michael import user in here to connect with credentials
     *                or connect credentials at api level
     */
    checkIfQuantityLimitExceedError(props: {
        responseStatus: string;
        response: UpdateBagResponse;
    }): void;
    checkAndSetUpdateError(response: UpdateBagResponse): void;
    updateBag(cartProductId: string, args: unknown): Promise<UpdateBagResponse>;
    /**
     * @name cry :,(
     * @description @todo needs a clean
     */
    deleteItemFromBag(cartProductId: string | number, isFromSaveForLater: boolean): Promise<any>;
    preFillZipCode(zipCode: string): void;
    fetchZipcode(): Promise<void>;
    /**
     * @todo needs typings
     */
    calculateShippingAndTax(params: {
        postalCode: string;
    }): Promise<any>;
    /**
     * @description this does not return bag this is VIEWING the bag
     */
    checkAndSetViewCartError(response: Cart, isFromInit: boolean): void;
    viewCart(isFromInit?: boolean): Promise<Cart>;
    resetCart(): Promise<Cart>;
    /**
     * @description on the checkout page,
     *              to edit the cart,
     *              we store the state in local storage,
     *              then we go to the homepage,
     *              check if the local storage key is true
     *              if so, open the cart, and remove the temporary local storage state
     *
     * @todo need to add a check in oneRouter.update to check if it is navigating to base_path (.startsWith('/')
     * @todo after that need to change oneRouter.replace to oneRouter.update
     */
    handleEditBag(): void;
    /**
     * @deprecated
     */
    handleMount: () => void;
    /**
     * @deprecated
     */
    handleUnMount: () => void;
    /**
     * !!!!!!! theey do not eveen belong iin a class
     * @todo needs to be in state/list
     */
    /**
     * @todo move to deps
     */
    transformSaveForLaterItems: (item: GetListItemsResponse) => SaveForLater;
    /**
     * @todo move to deps
     */
    transformListId: (listId: {
        listItemId: string;
        identifier: string;
    }) => {
        listId: string;
        productId: string;
    };
    fetchSaveListItems(saveForLaterListId: string): Promise<any>;
    fetchSavedForLaterInner(productInfo: SaveForLater[]): Promise<void>;
    fetchSaveForLater(): Promise<this>;
    /**
     * used by @see ShippingEstimationForm
     */
    fetchGeocode(zipcode: string): Promise<any>;
    /**
     * @todo @@training split this up, use exotic
     */
    addToSaveList(productInfo: any): Promise<any>;
    removeFromSavedList(productInfo: {
        productId: string;
        skuId: string;
    }, isFromMoveToCart?: boolean): Promise<void>;
    updateFrom(response: Cart): void;
    update(obj: Cart): void;
    findCartItemById(id: string): any;
    updateCartInfo(cartinfo: CartInfo): void;
    readonly listStore: typeof listContainer;
    readonly productIds: any[];
    readonly cartTotal: any;
    readonly products: CartProductType[];
    /**
     * @todo @see /__todo/index.savedforlater
     */
    readonly giftproducts: CartProduct[];
    readonly apiState: import("@skava/graphql-bindings").CartState;
    readonly buyinfo: CartBuyInfo;
    readonly cartinfo: CartInfoType;
    readonly math: import("@skava/graphql-bindings").Math;
    readonly userinfo: import("@skava/graphql-bindings").CartUserInfo[];
    readonly total: any;
    readonly grandTotal: any;
    readonly subTotal: any;
    readonly shouldShowPlaceHolderOnRender: boolean;
}
declare const cartContainer: CartContainer;
declare const updateCart: (isFromInit?: boolean) => Promise<Cart>;
declare const addToBag: (item: any, transformOneProduct?: boolean) => Promise<boolean>, updateBag: (cartProductId: string, args: unknown) => Promise<UpdateBagResponse>, deleteItemFromBag: (cartProductId: import("react").ReactText, isFromSaveForLater: boolean) => Promise<any>, calculateShippingAndTax: (params: {
    postalCode: string;
}) => Promise<any>;
export { updateCart, updateBag, deleteItemFromBag, cartContainer, calculateShippingAndTax, addToBag, addToBag as connectAction, };
export default cartContainer;