@ordergroove/offers 2.27.3 → 2.27.6-alpha-PR-647-5.2

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.27.3",
3
+ "version": "2.27.6-alpha-PR-647-5.2+4c726ce4",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ordergroove/auth": "^2.3.0",
37
- "@ordergroove/offers-live-editor": "^0.5.0",
37
+ "@ordergroove/offers-live-editor": "^0.6.0",
38
38
  "lit-element": "^2.1.0",
39
39
  "lodash.memoize": "^4.1.2",
40
40
  "logical-expression-parser": "1.0.0",
@@ -43,7 +43,7 @@
43
43
  "throttle-debounce": "^2.1.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@ordergroove/offers-templates": "^0.4.12"
46
+ "@ordergroove/offers-templates": "^0.4.13-alpha-PR-647-5.148+4c726ce4"
47
47
  },
48
- "gitHead": "506e488aef1ca8a90dc56d9af659d5dafa0e51d8"
48
+ "gitHead": "4c726ce4839730891619b7233f1f17bc94f4f8d3"
49
49
  }
@@ -5,6 +5,7 @@ import { OptinStatus, mapStateToProps as mapStateToPropsOptinStatus } from './Op
5
5
  import { mapStateToProps, frequencyText } from './FrequencyStatus';
6
6
  import { connect } from '../core/connect';
7
7
  import { defaultFrequency } from '../core/props';
8
+ import { configSelector } from '../core/selectors';
8
9
 
9
10
  export class OptinSelect extends withChildOptions(OptinStatus) {
10
11
  static get properties() {
@@ -30,8 +31,14 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
30
31
  `;
31
32
  }
32
33
 
33
- get isSelected() {
34
- return this.subscribed ? this.frequency : 'optedOut';
34
+ get currentFrequency() {
35
+ if (!this.subscribed) {
36
+ return 'optedOut';
37
+ }
38
+ if (this.frequency) {
39
+ return this.frequency;
40
+ }
41
+ return this.defaultFrequency;
35
42
  }
36
43
 
37
44
  onOptinChange(value) {
@@ -43,27 +50,27 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
43
50
  }
44
51
 
45
52
  render() {
46
- const { options: childOptions, isSelected } = this.childOptions;
47
- let options = childOptions;
48
- if (!childOptions.length) {
53
+ const { options: childOptions } = this.childOptions;
54
+ let options;
55
+ if (this.frequencies?.length) {
49
56
  options = [
50
- {
51
- value: 'optedOut',
52
- text: html`
53
- <og-text key="offerOptOutLabel"></og-text>
54
- `
55
- },
56
- ...(this.frequencies || []).map(value => ({
57
+ ...([childOptions.find(option => option.value === 'optedOut')] || []),
58
+ ...this.frequencies.map((value, ix) => ({
57
59
  value,
58
- text: frequencyText(value, this.defaultFrequency)
60
+ text:
61
+ this.frequenciesText && ix in this.frequenciesText
62
+ ? this.frequenciesText[ix]
63
+ : frequencyText(value, this.defaultFrequency)
59
64
  }))
60
65
  ];
66
+ } else {
67
+ options = childOptions;
61
68
  }
62
69
 
63
70
  return html`
64
71
  <og-select
65
72
  .options="${options}"
66
- .selected="${isSelected}"
73
+ .selected="${this.currentFrequency}"
67
74
  .onChange="${({ target: { value } }) => this.onOptinChange(value)}"
68
75
  ></og-select>
69
76
  `;
@@ -73,7 +80,8 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
73
80
  export const ConnectedOptinSelect = connect(
74
81
  (state, ownProps) => ({
75
82
  ...mapStateToPropsOptinStatus(state, ownProps),
76
- ...mapStateToProps(state, ownProps)
83
+ ...mapStateToProps(state, ownProps),
84
+ ...configSelector(state, ownProps, 'frequencies')
77
85
  }),
78
86
  { productChangeFrequency, optoutProduct }
79
87
  )(OptinSelect);
package/src/make-api.js CHANGED
@@ -189,7 +189,7 @@ export default function makeApi(store) {
189
189
  Object.assign(window.OG, offers);
190
190
  Object.assign(offers.initialize, offers);
191
191
 
192
- offersLiveEditor();
192
+ offersLiveEditor(window.opener, offers);
193
193
 
194
194
  return offers;
195
195
  }