Repository URL to install this package:
|
Version:
0.0.6 ▾
|
import * as tslib_1 from "tslib";
import { action, computed } from 'xmobx/mobx';
import { ObservableContainer } from '@skava/packages/libraries/observable-container';
import { updateCart } from '@skava/packages/core/cart/state/containers';
import { addPromoBindings, deletePromoBindings } from './bindings';
import { notifyAddPromoCode, notifyDeletePromoCode, isGetPromoSuccess } from './deps';
async function whenSuccessUpdateCart(response) {
if (isGetPromoSuccess(response)) {
await updateCart();
}
}
class PromoCodeContainer extends ObservableContainer {
async addPromoCode(promoCode) {
const response = await addPromoBindings(promoCode);
notifyAddPromoCode(response);
await whenSuccessUpdateCart(response);
}
async deletePromoCode(identifier) {
const response = await deletePromoBindings(identifier);
notifyDeletePromoCode(response);
await whenSuccessUpdateCart(response);
}
/**
* @alias promoCodeDetails
* @todo @@packages removed this
* ^ we will want to use the new `GetPromoCodeListQuery`
* and use `Query<>` to get them
*/
get promoCodeList() {
return [{ identifier: '1', value: 'eh' }];
// return cartContainer.cartDetails.promocodes
}
get canAddMorePromoCodes() {
return true;
// return this.promoCodeList.length >= 4
}
}
PromoCodeContainer.debugName = 'PromoCodeContainer';
tslib_1.__decorate([
action.bound
], PromoCodeContainer.prototype, "addPromoCode", null);
tslib_1.__decorate([
action.bound
], PromoCodeContainer.prototype, "deletePromoCode", null);
tslib_1.__decorate([
computed
], PromoCodeContainer.prototype, "canAddMorePromoCodes", null);
export { PromoCodeContainer };
//# sourceMappingURL=PromoCodeContainer.js.map