@salla.sa/twilight-components 1.6.7 → 1.6.9

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.
@@ -18875,7 +18875,7 @@ const SallaGifting = class {
18875
18875
  */
18876
18876
  async open() {
18877
18877
  this.modal.open();
18878
- return await salla.api.withoutNotifier(salla.product.getGiftDetails(this.productId)
18878
+ return await salla.api.withoutNotifier(() => salla.product.getGiftDetails(this.productId))
18879
18879
  .then((response) => {
18880
18880
  this.gift = response.data;
18881
18881
  this.senderName = this.gift.sender_name;
@@ -18885,7 +18885,7 @@ const SallaGifting = class {
18885
18885
  this.hasError = false;
18886
18886
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
18887
18887
  })
18888
- .finally(() => this.modal.stopLoading()));
18888
+ .finally(() => this.modal.stopLoading());
18889
18889
  }
18890
18890
  /**
18891
18891
  *
@@ -19361,7 +19361,7 @@ const SallaLocalizationModal = class {
19361
19361
  */
19362
19362
  async open() {
19363
19363
  this.modal.open();
19364
- return await salla.api.withoutNotifier(this.getLanguages()
19364
+ return await salla.api.withoutNotifier(() => this.getLanguages())
19365
19365
  .then(() => this.getCurrencies())
19366
19366
  .catch(e => {
19367
19367
  var _a, _b, _c, _d;
@@ -19369,9 +19369,7 @@ const SallaLocalizationModal = class {
19369
19369
  this.hasError = true;
19370
19370
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
19371
19371
  })
19372
- .finally(() => {
19373
- this.modal.stopLoading();
19374
- }));
19372
+ .finally(() => this.modal.stopLoading());
19375
19373
  }
19376
19374
  /**
19377
19375
  * Hide the component
@@ -20138,14 +20136,14 @@ const SallaOfferModal = class {
20138
20136
  async open(product_id) {
20139
20137
  //TODO:: make sure there is only one offer
20140
20138
  this.modal.open();
20141
- return salla.api.withoutNotifier(salla.product.offers(product_id)
20139
+ return salla.api.withoutNotifier(() => salla.product.offers(product_id))
20142
20140
  .then(response => this.showOffer(response.data[0]))
20143
20141
  .catch(e => {
20144
20142
  var _a, _b, _c, _d;
20145
20143
  this.hasError = true;
20146
20144
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
20147
20145
  })
20148
- .finally(() => setTimeout(() => { this.modal.stopLoading(); }, 1000)));
20146
+ .finally(() => setTimeout(() => this.modal.stopLoading(), 1000));
20149
20147
  }
20150
20148
  /**
20151
20149
  * Show offer details
@@ -20424,7 +20422,7 @@ const SallaProductSizeGuide = class {
20424
20422
  async open(product_id) {
20425
20423
  this.modal.setTitle(this.modal_title);
20426
20424
  this.modal.open();
20427
- return await salla.api.withoutNotifier(salla.product.getSizeGuides(product_id)
20425
+ return await salla.api.withoutNotifier(() => salla.product.getSizeGuides(product_id))
20428
20426
  .then((response) => {
20429
20427
  this.guides = response.data;
20430
20428
  })
@@ -20434,7 +20432,7 @@ const SallaProductSizeGuide = class {
20434
20432
  this.hasError = true;
20435
20433
  this.placeholder_description = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
20436
20434
  })
20437
- .finally(() => this.modal.stopLoading()));
20435
+ .finally(() => this.modal.stopLoading());
20438
20436
  }
20439
20437
  /**
20440
20438
  *
@@ -20585,7 +20583,7 @@ const SallaRatingModal = class {
20585
20583
  */
20586
20584
  async open() {
20587
20585
  this.modal.open();
20588
- return await salla.api.withoutNotifier(salla.rating.api.order(this.orderId)
20586
+ return await salla.api.withoutNotifier(() => salla.rating.api.order(this.orderId))
20589
20587
  .then(res => this.order = res.data)
20590
20588
  .catch(e => {
20591
20589
  var _a, _b, _c, _d;
@@ -20600,7 +20598,7 @@ const SallaRatingModal = class {
20600
20598
  setTimeout(() => {
20601
20599
  this.modal.stopLoading();
20602
20600
  }, 1000);
20603
- }));
20601
+ });
20604
20602
  }
20605
20603
  /**
20606
20604
  * Show the rating modal
@@ -74,21 +74,18 @@ const SallaScopees = class {
74
74
  this.mode = ModeType.DEFAULT;
75
75
  }
76
76
  this.modal.open();
77
- return await salla.api.withoutNotifier((mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
77
+ let callback = () => mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get();
78
+ return await salla.api.withoutNotifier(callback)
78
79
  .then((resp) => {
79
80
  if (mode == ModeType.AVAILABILITY) {
80
- this.setScopeValues(resp.data);
81
- }
82
- else {
83
- this.setScopeValues(resp.data.scopes);
81
+ return this.setScopeValues(resp.data);
84
82
  }
83
+ this.setScopeValues(resp.data.scopes);
85
84
  }).catch(e => {
86
85
  console.log(e);
87
86
  this.hasError = true;
88
87
  })
89
- .finally(() => {
90
- this.modal.stopLoading();
91
- }));
88
+ .finally(() => this.modal.stopLoading());
92
89
  }
93
90
  /**
94
91
  * Submit form to change exsiting scope.
@@ -64,7 +64,7 @@ export class SallaGifting {
64
64
  */
65
65
  async open() {
66
66
  this.modal.open();
67
- return await salla.api.withoutNotifier(salla.product.getGiftDetails(this.productId)
67
+ return await salla.api.withoutNotifier(() => salla.product.getGiftDetails(this.productId))
68
68
  .then((response) => {
69
69
  this.gift = response.data;
70
70
  this.senderName = this.gift.sender_name;
@@ -74,7 +74,7 @@ export class SallaGifting {
74
74
  this.hasError = false;
75
75
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
76
76
  })
77
- .finally(() => this.modal.stopLoading()));
77
+ .finally(() => this.modal.stopLoading());
78
78
  }
79
79
  /**
80
80
  *
@@ -46,7 +46,7 @@ export class SallaLocalizationModal {
46
46
  */
47
47
  async open() {
48
48
  this.modal.open();
49
- return await salla.api.withoutNotifier(this.getLanguages()
49
+ return await salla.api.withoutNotifier(() => this.getLanguages())
50
50
  .then(() => this.getCurrencies())
51
51
  .catch(e => {
52
52
  var _a, _b, _c, _d;
@@ -54,9 +54,7 @@ export class SallaLocalizationModal {
54
54
  this.hasError = true;
55
55
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
56
56
  })
57
- .finally(() => {
58
- this.modal.stopLoading();
59
- }));
57
+ .finally(() => this.modal.stopLoading());
60
58
  }
61
59
  /**
62
60
  * Hide the component
@@ -41,14 +41,14 @@ export class SallaOfferModal {
41
41
  async open(product_id) {
42
42
  //TODO:: make sure there is only one offer
43
43
  this.modal.open();
44
- return salla.api.withoutNotifier(salla.product.offers(product_id)
44
+ return salla.api.withoutNotifier(() => salla.product.offers(product_id))
45
45
  .then(response => this.showOffer(response.data[0]))
46
46
  .catch(e => {
47
47
  var _a, _b, _c, _d;
48
48
  this.hasError = true;
49
49
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
50
50
  })
51
- .finally(() => setTimeout(() => { this.modal.stopLoading(); }, 1000)));
51
+ .finally(() => setTimeout(() => this.modal.stopLoading(), 1000));
52
52
  }
53
53
  /**
54
54
  * Show offer details
@@ -20,7 +20,7 @@ export class SallaProductSizeGuide {
20
20
  async open(product_id) {
21
21
  this.modal.setTitle(this.modal_title);
22
22
  this.modal.open();
23
- return await salla.api.withoutNotifier(salla.product.getSizeGuides(product_id)
23
+ return await salla.api.withoutNotifier(() => salla.product.getSizeGuides(product_id))
24
24
  .then((response) => {
25
25
  this.guides = response.data;
26
26
  })
@@ -30,7 +30,7 @@ export class SallaProductSizeGuide {
30
30
  this.hasError = true;
31
31
  this.placeholder_description = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
32
32
  })
33
- .finally(() => this.modal.stopLoading()));
33
+ .finally(() => this.modal.stopLoading());
34
34
  }
35
35
  /**
36
36
  *
@@ -28,7 +28,7 @@ export class SallaRatingModal {
28
28
  */
29
29
  async open() {
30
30
  this.modal.open();
31
- return await salla.api.withoutNotifier(salla.rating.api.order(this.orderId)
31
+ return await salla.api.withoutNotifier(() => salla.rating.api.order(this.orderId))
32
32
  .then(res => this.order = res.data)
33
33
  .catch(e => {
34
34
  var _a, _b, _c, _d;
@@ -43,7 +43,7 @@ export class SallaRatingModal {
43
43
  setTimeout(() => {
44
44
  this.modal.stopLoading();
45
45
  }, 1000);
46
- }));
46
+ });
47
47
  }
48
48
  /**
49
49
  * Show the rating modal
@@ -55,21 +55,18 @@ export class SallaScopees {
55
55
  this.mode = ModeType.DEFAULT;
56
56
  }
57
57
  this.modal.open();
58
- return await salla.api.withoutNotifier((mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
58
+ let callback = () => mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get();
59
+ return await salla.api.withoutNotifier(callback)
59
60
  .then((resp) => {
60
61
  if (mode == ModeType.AVAILABILITY) {
61
- this.setScopeValues(resp.data);
62
- }
63
- else {
64
- this.setScopeValues(resp.data.scopes);
62
+ return this.setScopeValues(resp.data);
65
63
  }
64
+ this.setScopeValues(resp.data.scopes);
66
65
  }).catch(e => {
67
66
  console.log(e);
68
67
  this.hasError = true;
69
68
  })
70
- .finally(() => {
71
- this.modal.stopLoading();
72
- }));
69
+ .finally(() => this.modal.stopLoading());
73
70
  }
74
71
  /**
75
72
  * Submit form to change exsiting scope.
@@ -89,7 +89,7 @@ const SallaGifting$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
89
89
  */
90
90
  async open() {
91
91
  this.modal.open();
92
- return await salla.api.withoutNotifier(salla.product.getGiftDetails(this.productId)
92
+ return await salla.api.withoutNotifier(() => salla.product.getGiftDetails(this.productId))
93
93
  .then((response) => {
94
94
  this.gift = response.data;
95
95
  this.senderName = this.gift.sender_name;
@@ -99,7 +99,7 @@ const SallaGifting$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
99
99
  this.hasError = false;
100
100
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
101
101
  })
102
- .finally(() => this.modal.stopLoading()));
102
+ .finally(() => this.modal.stopLoading());
103
103
  }
104
104
  /**
105
105
  *
@@ -50,7 +50,7 @@ const SallaLocalizationModal$1 = /*@__PURE__*/ proxyCustomElement(class extends
50
50
  */
51
51
  async open() {
52
52
  this.modal.open();
53
- return await salla.api.withoutNotifier(this.getLanguages()
53
+ return await salla.api.withoutNotifier(() => this.getLanguages())
54
54
  .then(() => this.getCurrencies())
55
55
  .catch(e => {
56
56
  var _a, _b, _c, _d;
@@ -58,9 +58,7 @@ const SallaLocalizationModal$1 = /*@__PURE__*/ proxyCustomElement(class extends
58
58
  this.hasError = true;
59
59
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
60
60
  })
61
- .finally(() => {
62
- this.modal.stopLoading();
63
- }));
61
+ .finally(() => this.modal.stopLoading());
64
62
  }
65
63
  /**
66
64
  * Hide the component
@@ -69,14 +69,14 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
69
69
  async open(product_id) {
70
70
  //TODO:: make sure there is only one offer
71
71
  this.modal.open();
72
- return salla.api.withoutNotifier(salla.product.offers(product_id)
72
+ return salla.api.withoutNotifier(() => salla.product.offers(product_id))
73
73
  .then(response => this.showOffer(response.data[0]))
74
74
  .catch(e => {
75
75
  var _a, _b, _c, _d;
76
76
  this.hasError = true;
77
77
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
78
78
  })
79
- .finally(() => setTimeout(() => { this.modal.stopLoading(); }, 1000)));
79
+ .finally(() => setTimeout(() => this.modal.stopLoading(), 1000));
80
80
  }
81
81
  /**
82
82
  * Show offer details
@@ -32,7 +32,7 @@ const SallaProductSizeGuide$1 = /*@__PURE__*/ proxyCustomElement(class extends H
32
32
  async open(product_id) {
33
33
  this.modal.setTitle(this.modal_title);
34
34
  this.modal.open();
35
- return await salla.api.withoutNotifier(salla.product.getSizeGuides(product_id)
35
+ return await salla.api.withoutNotifier(() => salla.product.getSizeGuides(product_id))
36
36
  .then((response) => {
37
37
  this.guides = response.data;
38
38
  })
@@ -42,7 +42,7 @@ const SallaProductSizeGuide$1 = /*@__PURE__*/ proxyCustomElement(class extends H
42
42
  this.hasError = true;
43
43
  this.placeholder_description = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
44
44
  })
45
- .finally(() => this.modal.stopLoading()));
45
+ .finally(() => this.modal.stopLoading());
46
46
  }
47
47
  /**
48
48
  *
@@ -49,7 +49,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
49
49
  */
50
50
  async open() {
51
51
  this.modal.open();
52
- return await salla.api.withoutNotifier(salla.rating.api.order(this.orderId)
52
+ return await salla.api.withoutNotifier(() => salla.rating.api.order(this.orderId))
53
53
  .then(res => this.order = res.data)
54
54
  .catch(e => {
55
55
  var _a, _b, _c, _d;
@@ -64,7 +64,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
64
64
  setTimeout(() => {
65
65
  this.modal.stopLoading();
66
66
  }, 1000);
67
- }));
67
+ });
68
68
  }
69
69
  /**
70
70
  * Show the rating modal
@@ -77,21 +77,18 @@ const SallaScopees = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
77
77
  this.mode = ModeType.DEFAULT;
78
78
  }
79
79
  this.modal.open();
80
- return await salla.api.withoutNotifier((mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
80
+ let callback = () => mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get();
81
+ return await salla.api.withoutNotifier(callback)
81
82
  .then((resp) => {
82
83
  if (mode == ModeType.AVAILABILITY) {
83
- this.setScopeValues(resp.data);
84
- }
85
- else {
86
- this.setScopeValues(resp.data.scopes);
84
+ return this.setScopeValues(resp.data);
87
85
  }
86
+ this.setScopeValues(resp.data.scopes);
88
87
  }).catch(e => {
89
88
  console.log(e);
90
89
  this.hasError = true;
91
90
  })
92
- .finally(() => {
93
- this.modal.stopLoading();
94
- }));
91
+ .finally(() => this.modal.stopLoading());
95
92
  }
96
93
  /**
97
94
  * Submit form to change exsiting scope.
@@ -18871,7 +18871,7 @@ const SallaGifting = class {
18871
18871
  */
18872
18872
  async open() {
18873
18873
  this.modal.open();
18874
- return await salla.api.withoutNotifier(salla.product.getGiftDetails(this.productId)
18874
+ return await salla.api.withoutNotifier(() => salla.product.getGiftDetails(this.productId))
18875
18875
  .then((response) => {
18876
18876
  this.gift = response.data;
18877
18877
  this.senderName = this.gift.sender_name;
@@ -18881,7 +18881,7 @@ const SallaGifting = class {
18881
18881
  this.hasError = false;
18882
18882
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
18883
18883
  })
18884
- .finally(() => this.modal.stopLoading()));
18884
+ .finally(() => this.modal.stopLoading());
18885
18885
  }
18886
18886
  /**
18887
18887
  *
@@ -19357,7 +19357,7 @@ const SallaLocalizationModal = class {
19357
19357
  */
19358
19358
  async open() {
19359
19359
  this.modal.open();
19360
- return await salla.api.withoutNotifier(this.getLanguages()
19360
+ return await salla.api.withoutNotifier(() => this.getLanguages())
19361
19361
  .then(() => this.getCurrencies())
19362
19362
  .catch(e => {
19363
19363
  var _a, _b, _c, _d;
@@ -19365,9 +19365,7 @@ const SallaLocalizationModal = class {
19365
19365
  this.hasError = true;
19366
19366
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
19367
19367
  })
19368
- .finally(() => {
19369
- this.modal.stopLoading();
19370
- }));
19368
+ .finally(() => this.modal.stopLoading());
19371
19369
  }
19372
19370
  /**
19373
19371
  * Hide the component
@@ -20134,14 +20132,14 @@ const SallaOfferModal = class {
20134
20132
  async open(product_id) {
20135
20133
  //TODO:: make sure there is only one offer
20136
20134
  this.modal.open();
20137
- return salla.api.withoutNotifier(salla.product.offers(product_id)
20135
+ return salla.api.withoutNotifier(() => salla.product.offers(product_id))
20138
20136
  .then(response => this.showOffer(response.data[0]))
20139
20137
  .catch(e => {
20140
20138
  var _a, _b, _c, _d;
20141
20139
  this.hasError = true;
20142
20140
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
20143
20141
  })
20144
- .finally(() => setTimeout(() => { this.modal.stopLoading(); }, 1000)));
20142
+ .finally(() => setTimeout(() => this.modal.stopLoading(), 1000));
20145
20143
  }
20146
20144
  /**
20147
20145
  * Show offer details
@@ -20420,7 +20418,7 @@ const SallaProductSizeGuide = class {
20420
20418
  async open(product_id) {
20421
20419
  this.modal.setTitle(this.modal_title);
20422
20420
  this.modal.open();
20423
- return await salla.api.withoutNotifier(salla.product.getSizeGuides(product_id)
20421
+ return await salla.api.withoutNotifier(() => salla.product.getSizeGuides(product_id))
20424
20422
  .then((response) => {
20425
20423
  this.guides = response.data;
20426
20424
  })
@@ -20430,7 +20428,7 @@ const SallaProductSizeGuide = class {
20430
20428
  this.hasError = true;
20431
20429
  this.placeholder_description = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
20432
20430
  })
20433
- .finally(() => this.modal.stopLoading()));
20431
+ .finally(() => this.modal.stopLoading());
20434
20432
  }
20435
20433
  /**
20436
20434
  *
@@ -20581,7 +20579,7 @@ const SallaRatingModal = class {
20581
20579
  */
20582
20580
  async open() {
20583
20581
  this.modal.open();
20584
- return await salla.api.withoutNotifier(salla.rating.api.order(this.orderId)
20582
+ return await salla.api.withoutNotifier(() => salla.rating.api.order(this.orderId))
20585
20583
  .then(res => this.order = res.data)
20586
20584
  .catch(e => {
20587
20585
  var _a, _b, _c, _d;
@@ -20596,7 +20594,7 @@ const SallaRatingModal = class {
20596
20594
  setTimeout(() => {
20597
20595
  this.modal.stopLoading();
20598
20596
  }, 1000);
20599
- }));
20597
+ });
20600
20598
  }
20601
20599
  /**
20602
20600
  * Show the rating modal
@@ -70,21 +70,18 @@ const SallaScopees = class {
70
70
  this.mode = ModeType.DEFAULT;
71
71
  }
72
72
  this.modal.open();
73
- return await salla.api.withoutNotifier((mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
73
+ let callback = () => mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get();
74
+ return await salla.api.withoutNotifier(callback)
74
75
  .then((resp) => {
75
76
  if (mode == ModeType.AVAILABILITY) {
76
- this.setScopeValues(resp.data);
77
- }
78
- else {
79
- this.setScopeValues(resp.data.scopes);
77
+ return this.setScopeValues(resp.data);
80
78
  }
79
+ this.setScopeValues(resp.data.scopes);
81
80
  }).catch(e => {
82
81
  console.log(e);
83
82
  this.hasError = true;
84
83
  })
85
- .finally(() => {
86
- this.modal.stopLoading();
87
- }));
84
+ .finally(() => this.modal.stopLoading());
88
85
  }
89
86
  /**
90
87
  * Submit form to change exsiting scope.
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as s,h as e,H as t}from"./p-1503d976.js";import{S as l}from"./p-475ef754.js";var i;!function(s){s.DEFAULT="default",s.AVAILABILITY="availability"}(i||(i={}));const a=class{constructor(e){s(this,e),this.translationLoaded=!1,this.mode=i.DEFAULT,this.scopes=[],this.originalScopesList=[],this.isOpenedBefore=salla.storage.get("branch-choosed-before"),this.hasError=!1,this.selection="optional",this.searchDisplayLimit=6,this.getFormTitle=()=>{var s;return(null===(s=this.originalScopesList)||void 0===s?void 0:s.length)<2?"":this.mode===i.DEFAULT?salla.lang.get("blocks.scope.shopping_from_another_branch"):salla.lang.get("blocks.scope.search_for_availability_in_other_branches")},salla.event.on("scopes::open",(({mode:s=null,product_id:e=null})=>{this.open(s,e)})),salla.lang.onLoaded((()=>{this.translationLoaded=!0}))}async close(){var s;return await(null===(s=this.modal)||void 0===s?void 0:s.close())}async open(s=i.DEFAULT,e=null){return this.setScopeValues([]),this.mode=void 0!==s&&[i.AVAILABILITY,i.DEFAULT].includes(s)?s:i.DEFAULT,this.modal.open(),await salla.api.withoutNotifier((()=>s==i.AVAILABILITY?salla.scope.getProductAvailability(e):salla.scope.get())).then((e=>{if(s==i.AVAILABILITY)return this.setScopeValues(e.data);this.setScopeValues(e.data.scopes)})).catch((s=>{console.log(s),this.hasError=!0})).finally((()=>this.modal.stopLoading()))}async handleSubmit(){let s={id:this.current_scope.id};return this.changeBtn.load(),await salla.scope.change(s).then((()=>{salla.storage.set("branch-choosed-before",!0),salla.storage.set("scope",{type:this.current_scope.type,id:this.current_scope.id});var s=new URL(window.location.href);s.searchParams.set("scope",this.current_scope.id),window.location.href=s.toString(),window.location.replace(s.toString())})).catch((s=>console.log(s))).finally((()=>{this.changeBtn.stop()}))}setScopeValues(s){this.scopes=s,this.originalScopesList=s,1==s.length?(this.current_scope=s[0],this.selected_scope=s[0]):(this.current_scope=s.find((s=>s.selected)),this.selected_scope=s.find((s=>s.selected)))}handleSearchFieldTyping(s){let e=s.target.value.toLocaleLowerCase();this.scopes=e?this.originalScopesList.filter((s=>s.name.toLowerCase().includes(e))):this.originalScopesList}handleScopeSelection(s){this.current_scope=this.scopes.find((e=>e.id==s.target.value))}placeholderContent(){return e("salla-placeholder",{alignment:"center",class:"s-scopes-placeholder"},e("span",{slot:"title"},salla.lang.get("blocks.scope.branch_looking_for_not_found")),e("span",{slot:"description"},salla.lang.get("blocks.scope.our_services_not_available_in_this_branch")))}defaultContent(){return[e("div",{class:"s-scopes-container s-scrollbar"},this.scopes.map((s=>e("div",{class:"s-scopes-input-wrap","data-selection":this.selection},e("input",{id:`${this.selection} + '_scope_' + ${s.id}`,name:"lang",type:"radio",value:s.id,onChange:s=>this.handleScopeSelection(s),class:"s-scopes-input",checked:!!this.current_scope&&this.current_scope.id==s.id}),e("label",{htmlFor:`${this.selection} + '_scope_' + ${s.id}`,class:"s-scopes-label s-scopes-clickable"},e("span",null,s.name)))))),this.footerContent()]}availabilityContent(){return e("div",{class:"s-scopes-container"},this.scopes.map((s=>{var t,l,a,o,h,c;return e("div",{class:"s-scopes-input-wrap","data-selection":this.selection},e("h2",{class:{"s-scopes-label":!0,"s-scopes-clickable":this.mode===i.DEFAULT}},e("span",null,s.name)),e("h2",{style:{color:null===(l=null===(t=s)||void 0===t?void 0:t.availability)||void 0===l?void 0:l.color},class:`s-scopes-${null===(o=null===(a=s)||void 0===a?void 0:a.availability)||void 0===o?void 0:o.key}`},null===(c=null===(h=s)||void 0===h?void 0:h.availability)||void 0===c?void 0:c.label))})))}footerContent(){return e("div",{class:"s-scopes-footer"},e("slot",{name:"footer"},e("salla-button",{ref:s=>this.changeBtn=s,disabled:!this.current_scope,onClick:()=>this.handleSubmit(),class:"s-scopes-submit","loader-position":"center",width:"wide"},salla.lang.get("common.elements.confirm"))))}render(){return e(t,null,e("salla-modal",{ref:s=>this.modal=s,isClosable:!(!this.isOpenedBefore&&"optional"!=this.selection),class:"s-scopes-modal",isLoading:!0,"has-skeleton":!0},e("div",{slot:"loading"},e("div",{class:"s-scopes-skeleton"},e("salla-list-tile",{class:"s-scopes-header"},e("div",{slot:"icon",class:"s-scopes-header-icon"},e("salla-skeleton",{type:"circle"})),e("div",{slot:"title",class:"s-scopes-header-title mb-5"},e("salla-skeleton",{height:"15px",width:"50%"})),e("div",{slot:"subtitle",class:"s-scopes-header-subtitle"},e("salla-skeleton",{height:"10px"}),e("salla-skeleton",{height:"10px",width:"75%"}))),e("div",{class:"s-scopes-skeleton-search"},e("salla-skeleton",{height:"10px",width:"50%"}),e("salla-skeleton",{height:"30px",width:"100%"})),e("div",{class:"s-scopes-skeleton-scopes"},e("salla-skeleton",{height:"10px",width:"30%"}),e("salla-skeleton",{height:"10px",width:"25%"}),e("salla-skeleton",{height:"10px",width:"30%"}),e("salla-skeleton",{height:"10px",width:"25%"}),e("salla-skeleton",{height:"10px",width:"30%"}),e("salla-skeleton",{height:"10px",width:"25%"}),e("salla-skeleton",{height:"10px",width:"30%"}),e("salla-skeleton",{height:"10px",width:"25%"})),e("div",{class:"s-scopes-skeleton-btn"},e("salla-skeleton",{height:"40px",width:"100%"})))),e("salla-list-tile",{class:this.originalScopesList.length?"s-scopes-header block":"s-hidden"},e("div",{slot:"icon",class:"s-scopes-header-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>store-alt</title>\n<path d="M6.667 24h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333zM31.86 10.071l-4-8c-0.227-0.452-0.688-0.737-1.193-0.737h-21.333c-0.505 0-0.967 0.285-1.193 0.737l-4 8c-0.092 0.184-0.14 0.389-0.14 0.596v18.667c0 0.737 0.597 1.333 1.333 1.333h29.333c0.736 0 1.333-0.596 1.333-1.333v-18.667c0-0.207-0.048-0.412-0.14-0.596zM6.157 4h19.685l3.333 6.667h-26.352zM24 28h-5.333v-9.333h5.333zM29.333 28h-2.667v-10.667c0-0.737-0.597-1.333-1.333-1.333h-8c-0.736 0-1.333 0.596-1.333 1.333v10.667h-13.333v-14.667h26.667zM6.667 18.667h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n'}),e("div",{slot:"title",class:"s-scopes-header-title"},salla.lang.get("blocks.scope.you_are_browse_store_from")),e("div",{slot:"subtitle",class:"s-scopes-header-subtitle"},this.selected_scope?this.selected_scope.name:"")),e("div",{class:"s-scopes-wrap"},!!this.originalScopesList.length&&e("h4",{class:"s-scopes-title"},this.getFormTitle()),this.originalScopesList.length>this.searchDisplayLimit?e("div",{class:"s-scopes-search-wrapper"},e("div",{class:"s-scopes-search-icon",innerHTML:l}),e("input",{type:"text",class:"s-scopes-search-input",onInput:s=>this.handleSearchFieldTyping(s),enterkeyhint:"search",placeholder:salla.lang.get("blocks.scope.searching_for_a_branch")})):"",this.hasError||this.scopes.length<2?this.placeholderContent():this.mode===i.DEFAULT?this.defaultContent():this.availabilityContent())))}componentDidLoad(){this.isOpenedBefore||"mandatory"!=this.selection||this.open()}};a.style=".s-scopes-availability-content{display:flex;justify-content:center;align-items:center}.s-scopes-placeholder{flex:0 0 85%}";export{a as salla_scopes}