@ikas/loyalty-widget-renderer 1.0.0-alpha.83 → 1.0.0-alpha.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/build/locales.d.ts +20 -0
  2. package/build/models/index.js +1 -1
  3. package/build/models/mini-mode/index.d.ts +1 -0
  4. package/build/models/mini-mode/index.js +1 -1
  5. package/build/models/types/index.d.ts +1 -0
  6. package/build/renderer/components/product-filter-card/index.d.ts +13 -0
  7. package/build/renderer/components/product-filter-card/index.js +1 -0
  8. package/build/renderer/components/product-filter-card/style.d.ts +10 -0
  9. package/build/renderer/components/product-filter-card/style.js +1 -0
  10. package/build/renderer/index.js +1 -1
  11. package/build/renderer/screens/gift-product-selection-screen/index.js +1 -1
  12. package/build/renderer/screens/gift-product-selection-screen/style.d.ts +3 -1
  13. package/build/renderer/screens/gift-product-selection-screen/style.js +1 -1
  14. package/build/renderer/screens/loyalty-level-screen/index.js +1 -1
  15. package/build/renderer/screens/main-screen/earning-methods-section/index.js +1 -1
  16. package/build/renderer/screens/main-screen/program-info-section/index.js +1 -1
  17. package/build/renderer/screens/main-screen/spending-methods-section/index.js +1 -1
  18. package/build/renderer/utils/locales/de.json.js +1 -1
  19. package/build/renderer/utils/locales/en.json.js +1 -1
  20. package/build/renderer/utils/locales/fr.json.js +1 -1
  21. package/build/renderer/utils/locales/nl.json.js +1 -1
  22. package/build/renderer/utils/locales/tr.json.js +1 -1
  23. package/build/renderer/utils/loyalty-details.d.ts +8 -0
  24. package/build/renderer/utils/loyalty-details.js +1 -1
  25. package/build/storefront-widget-script-injector.iife.js +1 -1
  26. package/build/storefront-widget-script-injector.iife.js.map +1 -1
  27. package/build/utils.d.ts +9 -0
  28. package/build/utils.js +1 -1
  29. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { TFunction } from "i18next";
2
2
  import { LoyaltyWidgetViewModel } from "models";
3
+ import { LoyaltyProgramFilter } from "models/common";
3
4
  import { LoyaltyProgramEarningMethod } from "models/loyalty-program-earning-method";
4
5
  import { LoyaltyProgramFilterTypeEnum } from "models/types";
5
6
  export type FilterDetail = {
@@ -9,4 +10,11 @@ export type FilterDetail = {
9
10
  };
10
11
  export declare const getFilterDetails: (viewModel: LoyaltyWidgetViewModel, filterType: LoyaltyProgramFilterTypeEnum, idList: string[]) => FilterDetail[];
11
12
  export declare const getFreeProductName: (viewModel: LoyaltyWidgetViewModel, productId: string) => string | undefined;
13
+ /**
14
+ * PRODUCT_AND_VARIANT filtrelerindeki ürünlerin viewModel.products'ta bulunup bulunamadığını kontrol eder.
15
+ * Eğer PRODUCT_AND_VARIANT filtresi yoksa true döner (ürün bilgisine bağımlı değil).
16
+ * Eğer varsa, en az bir ürünün çözülebilir olmasını gerektirir.
17
+ */
18
+ export declare const hasResolvableProductFilters: (viewModel: LoyaltyWidgetViewModel, filters: LoyaltyProgramFilter[]) => boolean;
19
+ export declare const getEarningMethodConditionList: (t: TFunction, earningMethod: LoyaltyProgramEarningMethod, viewModel: LoyaltyWidgetViewModel) => string[];
12
20
  export declare const getEarningMethodDescriptionV2: (t: TFunction, earningMethod: LoyaltyProgramEarningMethod, viewModel: LoyaltyWidgetViewModel) => string | undefined;
@@ -1 +1 @@
1
- import{__spreadArray as e}from'./../../ext/tslib/tslib.es6.mjs.js';import{LoyaltyProgramFilterTypeEnum as n,EarningMethodTypeEnum as r,LoyaltyProgramPointEarningTypeEnum as t}from"../../models/types/index.js";var i=function(e,r,t){if(!t||0===t.length)return[];var i=[];return t.forEach(function(t){var a="";switch(r){case n.CATEGORY:case n.DYNAMIC_CATEGORY:if(e.categories){var o=e.categories.find(function(e){return e.id===t});o&&(a=o.name)}break;case n.PRODUCT_AND_VARIANT:if(e.products){var s=e.products.find(function(e){return e.id===t});s&&(a=s.name)}break;case n.PRODUCT_BRAND:if(e.brands){var c=e.brands.find(function(e){return e.id===t});c&&(a=c.name)}break;case n.PRODUCT_TAG:if(e.tags){var d=e.tags.find(function(e){return e.id===t});d&&(a=d.name)}}a?i.push({type:r,name:a,id:t}):i.push({type:r,name:t,id:t})}),i},a=function(e,n){if(e.products){var r=e.products.find(function(e){return e.id===n});return r?r.name:void 0}},o=function(a,o,s){var c,d;switch(o.methodType){case r.CUSTOMER_REGISTER:case r.CUSTOMER_REVIEW:case r.ENABLE_SUBSCRIPTION:return a("earningMethods.xPoints",{points:o.pointsEarned});case r.ORDER_CREATE:var u=e(e([],(null===(c=o.productSettings)||void 0===c?void 0:c.productFilters)||[],!0),(null===(d=o.orderSettings)||void 0===d?void 0:d.productFilters)||[],!0),E=u.reduce(function(e,n){return e.concat(i(s,n.type,n.idList))},[]),R=E.map(function(e){switch(e.type){case n.CATEGORY:case n.DYNAMIC_CATEGORY:return a("earningMethods.ORDER_CREATE.BASE.genericCategory",{category:e.name});case n.PRODUCT_AND_VARIANT:return a("earningMethods.ORDER_CREATE.BASE.genericProduct",{product:e.name});case n.PRODUCT_BRAND:return a("earningMethods.ORDER_CREATE.BASE.genericBrand",{brand:e.name});case n.PRODUCT_TAG:return a("earningMethods.ORDER_CREATE.BASE.genericTag",{tag:e.name});default:return e.name}}).filter(Boolean).join(", "),m=o.orderSettings||{},A=m.minOrderAmount,f=m.maxOrderAmount,T="number"==typeof f&&f>0,p="";switch("number"==typeof A&&A>0?p=a("earningMethods.ORDER_CREATE.BASE.descriptionStaticMinimum",{amount:s.formatCurrency(A)}):T&&(p=a("earningMethods.ORDER_CREATE.BASE.descriptionStaticMaximum",{amount:s.formatCurrency(f)})),o.pointEarningType){case t.DYNAMIC_ORDER_AMOUNT:return(C=[R,p,a("earningMethods.ORDER_CREATE.RECEIVE_POINTS_ON_SPEND.description",{amount:s.formatCurrency(o.amountPerPointsEarned||0),points:o.pointsEarned})].filter(Boolean)).join(" ");case t.STATIC:var C;return 0===(C=[R,p].filter(Boolean)).length?void u.length:!p&&R?a("earningMethods.ORDER_CREATE.BASE.descriptionWithFilter",{filter:R}):C.join(", ")}break;default:return""}};export{o as getEarningMethodDescriptionV2,i as getFilterDetails,a as getFreeProductName};
1
+ import{__spreadArray as n}from'./../../ext/tslib/tslib.es6.mjs.js';import{LoyaltyProgramFilterTypeEnum as t,EarningMethodTypeEnum as r,LoyaltyProgramPointEarningTypeEnum as e}from"../../models/types/index.js";var i=function(n,r,e){var i;if(!e||0===e.length)return[];if(r===t.PRODUCT_AND_VARIANT){var o=e.find(function(n){return n.startsWith("p:")}),a=e.find(function(n){return n.startsWith("v:")});if(!o)return[];var u=o.slice(2),c=a?a.slice(2):null,d=null===(i=n.products)||void 0===i?void 0:i.find(function(n){return n.id===u});if(!d)return[];var s=d.name;if(c&&d.variants){var E=d.variants.find(function(n){return n.id===c});(null==E?void 0:E.variantText)&&(s="".concat(d.name," (").concat(E.variantText,")"))}return[{type:r,name:s,id:u}]}var R=[];return e.forEach(function(e){var i="";switch(r){case t.CATEGORY:case t.DYNAMIC_CATEGORY:if(n.categories){var o=n.categories.find(function(n){return n.id===e});o&&(i=o.name)}break;case t.PRODUCT_BRAND:if(n.brands){var a=n.brands.find(function(n){return n.id===e});a&&(i=a.name)}break;case t.PRODUCT_TAG:if(n.tags){var u=n.tags.find(function(n){return n.id===e});u&&(i=u.name)}}i&&R.push({type:r,name:i,id:e})}),R},o=function(n,t){if(n.products){var r=n.products.find(function(n){return n.id===t});return r?r.name:void 0}},a=function(n,r){var e=r.filter(function(n){return n.type===t.PRODUCT_AND_VARIANT});return 0===e.length||e.some(function(t){var r,e,i=null===(r=t.idList)||void 0===r?void 0:r.find(function(n){return n.startsWith("p:")});if(!i)return!1;var o=i.slice(2);return null===(e=n.products)||void 0===e?void 0:e.some(function(n){return n.id===o})})},u=function(o,a,u){var c,d,s,E=function(n){return n.filter(function(n){return n.type!==t.PRODUCT_AND_VARIANT}).map(function(n){switch(n.type){case t.CATEGORY:case t.DYNAMIC_CATEGORY:return o("earningMethods.ORDER_CREATE.BASE.descriptionOnlyCategory",{category:n.name});case t.PRODUCT_BRAND:return o("earningMethods.ORDER_CREATE.BASE.descriptionOnlyBrand",{brand:n.name});case t.PRODUCT_TAG:return o("earningMethods.ORDER_CREATE.BASE.descriptionOnlyTag",{tag:n.name});default:return n.name}}).filter(Boolean)};switch(a.methodType){case r.BUY_PRODUCT:return E(n([],(null===(c=a.productSettings)||void 0===c?void 0:c.productFilters)||[],!0).reduce(function(n,t){return n.concat(i(u,t.type,t.idList))},[]));case r.ORDER_CREATE:var R=n(n([],(null===(d=a.productSettings)||void 0===d?void 0:d.productFilters)||[],!0),(null===(s=a.orderSettings)||void 0===s?void 0:s.productFilters)||[],!0).reduce(function(n,t){return n.concat(i(u,t.type,t.idList))},[]),f=[];f.push.apply(f,E(R));var p=a.orderSettings||{},m=p.minOrderAmount,A=p.maxOrderAmount;return"number"==typeof m&&m>0&&f.push(o("earningMethods.ORDER_CREATE.BASE.descriptionStaticMinimum",{amount:u.formatCurrency(m)})),"number"==typeof A&&A>0&&f.push(o("earningMethods.ORDER_CREATE.BASE.descriptionStaticMaximum",{amount:u.formatCurrency(A)})),a.pointEarningType===e.DYNAMIC_ORDER_AMOUNT&&f.push(o("earningMethods.ORDER_CREATE.RECEIVE_POINTS_ON_SPEND.description",{amount:u.formatCurrency(a.amountPerPointsEarned||0),points:a.pointsEarned})),f;default:return[]}},c=function(o,a,u){var c,d,s,E=function(n){return n.filter(function(n){return n.type!==t.PRODUCT_AND_VARIANT}).map(function(n){switch(n.type){case t.CATEGORY:case t.DYNAMIC_CATEGORY:return o("earningMethods.ORDER_CREATE.BASE.genericCategory",{category:n.name});case t.PRODUCT_BRAND:return o("earningMethods.ORDER_CREATE.BASE.genericBrand",{brand:n.name});case t.PRODUCT_TAG:return o("earningMethods.ORDER_CREATE.BASE.genericTag",{tag:n.name});default:return n.name}}).filter(Boolean).join(", ")};switch(a.methodType){case r.CUSTOMER_REGISTER:case r.CUSTOMER_REVIEW:case r.ENABLE_SUBSCRIPTION:return o("earningMethods.xPoints",{points:a.pointsEarned});case r.BUY_PRODUCT:var R=E(n([],(null===(c=a.productSettings)||void 0===c?void 0:c.productFilters)||[],!0).reduce(function(n,t){return n.concat(i(u,t.type,t.idList))},[]));return R||void 0;case r.ORDER_CREATE:var f=n(n([],(null===(d=a.productSettings)||void 0===d?void 0:d.productFilters)||[],!0),(null===(s=a.orderSettings)||void 0===s?void 0:s.productFilters)||[],!0),p=E(f.reduce(function(n,t){return n.concat(i(u,t.type,t.idList))},[])),m=a.orderSettings||{},A=m.minOrderAmount,l=m.maxOrderAmount,T="number"==typeof l&&l>0,C="";switch("number"==typeof A&&A>0?C=o("earningMethods.ORDER_CREATE.BASE.descriptionStaticMinimum",{amount:u.formatCurrency(A)}):T&&(C=o("earningMethods.ORDER_CREATE.BASE.descriptionStaticMaximum",{amount:u.formatCurrency(l)})),a.pointEarningType){case e.DYNAMIC_ORDER_AMOUNT:return(O=[p,C,o("earningMethods.ORDER_CREATE.RECEIVE_POINTS_ON_SPEND.description",{amount:u.formatCurrency(a.amountPerPointsEarned||0),points:a.pointsEarned})].filter(Boolean)).join(" ");case e.STATIC:var O;return 0===(O=[p,C].filter(Boolean)).length?void f.length:!C&&p?o("earningMethods.ORDER_CREATE.BASE.descriptionWithFilter",{filter:p}):O.join(", ")}break;default:return""}};export{u as getEarningMethodConditionList,c as getEarningMethodDescriptionV2,i as getFilterDetails,o as getFreeProductName,a as hasResolvableProductFilters};