@ordergroove/offers 2.27.6 → 2.27.7

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.6",
3
+ "version": "2.27.7",
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,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "@ordergroove/offers-templates": "^0.4.13"
47
47
  },
48
- "gitHead": "feff65dfd7c912f7be69e48d68ce403ac0cf24aa"
48
+ "gitHead": "09226ede168eae0ac25625557615c4c6a6dfc247"
49
49
  }
@@ -31,8 +31,14 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
31
31
  `;
32
32
  }
33
33
 
34
- get isSelected() {
35
- 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;
36
42
  }
37
43
 
38
44
  onOptinChange(value) {
@@ -44,7 +50,7 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
44
50
  }
45
51
 
46
52
  render() {
47
- const { options: childOptions, isSelected } = this.childOptions;
53
+ const { options: childOptions } = this.childOptions;
48
54
  let options;
49
55
  if (this.frequencies?.length) {
50
56
  options = [
@@ -63,13 +69,21 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
63
69
  }))
64
70
  ];
65
71
  } else {
66
- options = childOptions;
72
+ options = [
73
+ {
74
+ value: 'optedOut',
75
+ text: html`
76
+ <og-text key="offerOptOutLabel"></og-text>
77
+ `
78
+ },
79
+ ...childOptions
80
+ ];
67
81
  }
68
82
 
69
83
  return html`
70
84
  <og-select
71
85
  .options="${options}"
72
- .selected="${isSelected}"
86
+ .selected="${this.currentFrequency}"
73
87
  .onChange="${({ target: { value } }) => this.onOptinChange(value)}"
74
88
  ></og-select>
75
89
  `;