UNPKG

shopperman

Version:

shopping cart ui for shopify stores

55 lines 2.14 kB
"use strict"; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); var mobx_1 = require("mobx"); /** * Cart item tracks meta-details about a product * - wraps a product instance * - keeps track of quantity in the cart */ var CartItem = /** @class */ (function () { function CartItem(options) { this.quantity = 0; Object.assign(this, options); } Object.defineProperty(CartItem.prototype, "value", { get: function () { var _a = this, quantity = _a.quantity, product = _a.product; var value = product.value; return value * quantity; }, enumerable: true, configurable: true }); Object.defineProperty(CartItem.prototype, "price", { get: function () { var _a = this, value = _a.value, currencyControl = _a.currencyControl, product = _a.product; return currencyControl.convertAndFormat(value, product.precision); }, enumerable: true, configurable: true }); CartItem.prototype.setQuantity = function (quantity) { this.quantity = quantity; }; __decorate([ mobx_1.observable ], CartItem.prototype, "quantity", void 0); __decorate([ mobx_1.computed ], CartItem.prototype, "value", null); __decorate([ mobx_1.computed ], CartItem.prototype, "price", null); __decorate([ mobx_1.action ], CartItem.prototype, "setQuantity", null); return CartItem; }()); exports.CartItem = CartItem; //# sourceMappingURL=cart-item.js.map