shopperman
Version:
shopping cart ui for shopify stores
64 lines • 2.64 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
/**
* Represent a single ecommerce product
*/
var Product = /** @class */ (function () {
function Product(_a) {
var precision = _a.precision, attributes = _a.attributes, options = __rest(_a, ["precision", "attributes"]);
this.precision = null;
this.attributes = {};
Object.assign(this, options);
this.setPrecision(precision);
this.setAttributes(attributes);
}
Object.defineProperty(Product.prototype, "price", {
get: function () {
var _a = this, currencyControl = _a.currencyControl, value = _a.value, precision = _a.precision;
return currencyControl.convertAndFormat(value, precision);
},
enumerable: true,
configurable: true
});
Product.prototype.setPrecision = function (precision) {
this.precision = precision;
};
Product.prototype.setAttributes = function (attributes) {
if (attributes === void 0) { attributes = {}; }
this.attributes = attributes;
};
__decorate([
mobx_1.observable
], Product.prototype, "precision", void 0);
__decorate([
mobx_1.observable
], Product.prototype, "attributes", void 0);
__decorate([
mobx_1.computed
], Product.prototype, "price", null);
__decorate([
mobx_1.action
], Product.prototype, "setPrecision", null);
__decorate([
mobx_1.action
], Product.prototype, "setAttributes", null);
return Product;
}());
exports.Product = Product;
//# sourceMappingURL=product.js.map