@ordergroove/offers 2.28.3-alpha-PR-686-10.9 → 2.28.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordergroove/offers",
3
- "version": "2.28.3-alpha-PR-686-10.9+358ba164",
3
+ "version": "2.28.3",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -45,7 +45,7 @@
45
45
  "throttle-debounce": "^2.1.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@ordergroove/offers-templates": "^0.4.17"
48
+ "@ordergroove/offers-templates": "^0.4.18"
49
49
  },
50
- "gitHead": "358ba1648b0a66ac275dc06975961e1397b35813"
50
+ "gitHead": "f5425ec1d89d94d95278980364c65ccaf33b9352"
51
51
  }
package/src/core/utils.ts CHANGED
@@ -110,7 +110,7 @@ export const getFirstSellingPlan = (frequencies = []) => frequencies?.[0] || nul
110
110
  export const hasShopifySellingPlans = (sellingPlans = [], frequenciesEveryPeriod = []) =>
111
111
  !!(platform?.shopify_selling_plans && sellingPlans.length && frequenciesEveryPeriod.length);
112
112
 
113
- export const mapFrequencyToSellingPlan = (sellingPlans = [], frequenciesEveryPeriod = [], frequency) => {
113
+ export const mapFrequencyToSellingPlan = (sellingPlans, frequenciesEveryPeriod, frequency) => {
114
114
  if (sellingPlans.length !== frequenciesEveryPeriod.length) {
115
115
  return null;
116
116
  }
@@ -123,17 +123,3 @@ export const mapFrequencyToSellingPlan = (sellingPlans = [], frequenciesEveryPer
123
123
 
124
124
  return null;
125
125
  };
126
-
127
- export const curriedMapFrequencyToSellingPlan = (sellingPlans, frequenciesEveryPeriod) => frequency =>
128
- mapFrequencyToSellingPlan(sellingPlans, frequenciesEveryPeriod, frequency);
129
-
130
- export const getSafeSellingPlan = (sellingPlans, frequenciesEveryPeriod, frequency) => {
131
- if (isOgFrequency(frequency) && hasShopifySellingPlans(sellingPlans, frequenciesEveryPeriod)) {
132
- return mapFrequencyToSellingPlan(sellingPlans, frequenciesEveryPeriod, frequency);
133
- }
134
-
135
- return frequency;
136
- };
137
-
138
- export const curriedGetSafeSellingPlan = (sellingPlans, frequenciesEveryPeriod) => frequency =>
139
- getSafeSellingPlan(sellingPlans, frequenciesEveryPeriod, frequency);
package/src/make-api.js CHANGED
@@ -20,7 +20,6 @@ import { Modal } from './components/Modal';
20
20
  import { Select } from './components/Select';
21
21
  import { Tooltip } from './components/Tooltip';
22
22
  import { ConnectedFrequencyStatus } from './components/FrequencyStatus';
23
- import { ConnectedDefaultFrequencyText } from './components/DefaultFrequencyText';
24
23
  import * as testMode from './test-mode';
25
24
  import { api } from './core/api';
26
25
  import { environment, offer } from './core/reducer';
@@ -52,7 +51,6 @@ export default function makeApi(store) {
52
51
  customElements.define('og-upsell-modal', ConnectedUpsellModal);
53
52
  customElements.define('og-next-upcoming-order', ConnectedNextUpcomingOrder);
54
53
  customElements.define('og-price', ConnectedPrice);
55
- customElements.define('og-default-frequency-text', ConnectedDefaultFrequencyText);
56
54
  } catch (err) {
57
55
  console.info('OG WebComponents already registered, skipping.');
58
56
  }
@@ -1,51 +0,0 @@
1
- import { LitElement, html } from 'lit-element';
2
-
3
- import { connect } from '../core/connect';
4
- import { withProduct } from '../core/resolveProperties';
5
- import { makeProductDefaultFrequencySelector } from '../core/selectors';
6
- import { curriedGetSafeSellingPlan, curriedMapFrequencyToSellingPlan } from '../core/utils';
7
-
8
- export class DefaultFrequencyText extends withProduct(LitElement) {
9
- static get properties() {
10
- return {
11
- ...super.properties,
12
- config: { type: Object, attribute: false },
13
- productDefaultFrequency: { type: String, attribute: false },
14
- defaultFrequency: { type: String, attribute: true },
15
- frequency: { type: String, attribute: true }
16
- };
17
- }
18
-
19
- get shouldShowText() {
20
- const getSafeSellingPlan = curriedGetSafeSellingPlan(this.config.frequencies, this.config.frequenciesEveryPeriod);
21
- const mapFrequencyToSellingPlan = curriedMapFrequencyToSellingPlan(
22
- this.config.frequencies,
23
- this.config.frequenciesEveryPeriod
24
- );
25
- const safeSellingPlan = getSafeSellingPlan(this.frequency);
26
-
27
- return !!(
28
- this.productDefaultFrequency === safeSellingPlan ||
29
- (!this.productDefaultFrequency &&
30
- [
31
- mapFrequencyToSellingPlan(getSafeSellingPlan(this.config.defaultFrequency)),
32
- mapFrequencyToSellingPlan(getSafeSellingPlan(this.defaultFrequency))
33
- ].some(it => it === safeSellingPlan))
34
- );
35
- }
36
-
37
- render() {
38
- return this.shouldShowText
39
- ? html`
40
- <slot></slot>
41
- `
42
- : html``;
43
- }
44
- }
45
-
46
- export const mapStateToProps = (state, ownProps) => ({
47
- config: state.config || {},
48
- productDefaultFrequency: makeProductDefaultFrequencySelector((ownProps.product || {}).id)(state)
49
- });
50
-
51
- export const ConnectedDefaultFrequencyText = connect(mapStateToProps)(DefaultFrequencyText);