Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const tslib_1 = require("tslib");

const mobx_1 = require("xmobx/mobx");

class ProductPieceState {
  constructor(props) {
    this.product = {};
    this.variantData = {};

    if (props.item) {
      this.product = props.item;
    }

    if (props.variantConfig) {
      this.variantConfig = props.variantConfig;
    }
  }

  setItem(key, value) {
    this[key] = value;
  }

  updateVariantData(value) {
    this.variantData = this.variantConfig[value];
    this.product.variant = this.variantData.variant;
  }

  swapImages(product) {
    const imageToShift = this.product.images.shift();
    this.product.images.push(imageToShift);
  }

}

tslib_1.__decorate([mobx_1.observable], ProductPieceState.prototype, "product", void 0);

tslib_1.__decorate([mobx_1.observable], ProductPieceState.prototype, "variantData", void 0);

tslib_1.__decorate([mobx_1.action.bound], ProductPieceState.prototype, "setItem", null);

tslib_1.__decorate([mobx_1.action.bound], ProductPieceState.prototype, "updateVariantData", null);

tslib_1.__decorate([mobx_1.action.bound], ProductPieceState.prototype, "swapImages", null);

exports.ProductPieceState = ProductPieceState; //# sourceMappingURL=state.js.map