UNPKG

@salla.sa/twilight-components

Version:
57 lines (53 loc) 2.25 kB
/*! * Crafted with ❤ by Salla */ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client'; import { c as closeModals } from './functions.js'; const sallaLoyaltyProgramCss = ""; const SallaRewardAction = /*@__PURE__*/ proxyCustomElement(class SallaRewardAction extends HTMLElement { constructor() { super(); this.__registerHost(); this.actionClick = createEvent(this, "actionClick", 7); this.isShopNow = (prize) => { if (!(salla.config.get('store.features') || []).includes('loyalty-system-v2')) { return false; } return prize.key?.toLowerCase() === 'free_product'; }; this.handleClick = (e) => { if (salla.config.isGuest()) { closeModals(() => salla.event.dispatch('login::open')); return; } this.actionClick.emit(e); }; } render() { return (h("div", { key: '95d6e753d49c7cb69e6f5e25ef6ccf3f916f4022', class: "s-loyalty-program-rewards-modal-action" }, this.isShopNow(this.prize) ? (h("a", { href: this.prize.prize_url || salla.url.get(''), class: { 's-loyalty-program-rewards-action-base': true, 's-loyalty-program-rewards-action-on': true, } }, salla.lang.get('pages.loyalty_program.shop_now'))) : (h("button", { onClick: this.handleClick, class: { 's-loyalty-program-rewards-action-base': true, 's-loyalty-program-rewards-action-on': true, } }, salla.lang.get('pages.loyalty_program.redeem_reward'))))); } static get style() { return sallaLoyaltyProgramCss; } }, [0, "salla-reward-action", { "prize": [16] }]); function defineCustomElement() { if (typeof customElements === "undefined") { return; } const components = ["salla-reward-action"]; components.forEach(tagName => { switch (tagName) { case "salla-reward-action": if (!customElements.get(tagName)) { customElements.define(tagName, SallaRewardAction); } break; } }); } defineCustomElement(); export { SallaRewardAction as S, defineCustomElement as d };