@global.engg/switcher-lib 0.1.7 → 0.1.30
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/bundles/global.engg-switcher-lib.umd.js +190 -45
- package/bundles/global.engg-switcher-lib.umd.js.map +1 -1
- package/esm2015/lib/switcher.component.js +120 -19
- package/esm2015/lib/switcher.service.js +69 -28
- package/fesm2015/global.engg-switcher-lib.js +187 -45
- package/fesm2015/global.engg-switcher-lib.js.map +1 -1
- package/lib/switcher.component.d.ts +9 -0
- package/lib/switcher.service.d.ts +2 -0
- package/package.json +1 -1
|
@@ -173,15 +173,27 @@
|
|
|
173
173
|
});
|
|
174
174
|
};
|
|
175
175
|
AppSwitcherService.prototype.appSwitch = function (app, kyc_status) {
|
|
176
|
-
var _a, _b
|
|
176
|
+
var _a, _b;
|
|
177
177
|
this.sendGaEvent(app);
|
|
178
|
+
// moengage event
|
|
179
|
+
(_b = (_a = this.windowRef.nativeWindow) === null || _a === void 0 ? void 0 : _a.Moengage) === null || _b === void 0 ? void 0 : _b.track_event("product_navigation_icon_clicked", { icon_name: app, company_id: this.userData.company_id });
|
|
180
|
+
// Store window reference BEFORE delay to prevent popup blocking
|
|
181
|
+
var windowRef = this.windowRef.nativeWindow;
|
|
182
|
+
// Add delay after MoEngage tracking
|
|
183
|
+
// setTimeout(() => {
|
|
184
|
+
// }, 500); // 500ms delay
|
|
185
|
+
this.executeAppSwitch(app, kyc_status, windowRef);
|
|
186
|
+
};
|
|
187
|
+
AppSwitcherService.prototype.executeAppSwitch = function (app, kyc_status, windowRef) {
|
|
188
|
+
var _this = this;
|
|
189
|
+
var _a, _b, _c;
|
|
178
190
|
if (this.userData.allow_engage && app === 'engage') {
|
|
179
|
-
|
|
191
|
+
windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper?token=" + this.userData.token, '_blank');
|
|
180
192
|
}
|
|
181
193
|
else if (app === 'checkout') {
|
|
182
194
|
var url = "https://fastrr-dashboard.pickrr.com/dashboard?utm_source=sr_dashboard&utm_medium=appswitcher&utm_campaign=appswitcher01&utm_content=appswitcher01&cid=" + this.userData.company_id;
|
|
183
195
|
url = url + "&token=" + this.userData.token;
|
|
184
|
-
|
|
196
|
+
windowRef.open(url, '_blank');
|
|
185
197
|
// if ((this.isCheckoutAllowed(this.userData?.company_id) || this.userData.allow_checkout)) {
|
|
186
198
|
// url = `${url}&token=${this.userData.token}`
|
|
187
199
|
// window.open(url, '_blank');
|
|
@@ -190,26 +202,31 @@
|
|
|
190
202
|
// }
|
|
191
203
|
}
|
|
192
204
|
else if (this.userData.allow_fbs && app === 'fullfilment') {
|
|
193
|
-
|
|
205
|
+
windowRef.open(this.SR_CONSTANTS.SrfWebBaseUrl + "login?token=" + this.userData.token, '_blank');
|
|
194
206
|
}
|
|
195
207
|
else if (!this.userData.allow_fbs && app === 'fullfilment') {
|
|
196
|
-
|
|
208
|
+
windowRef.open(this.SR_CONSTANTS.FulfillmentWebBaseUrl + "?utm_source=panel&utm_medium=app_switcher&utm_campaign=SR-Panel-non-srf-switcher&token=" + this.userData.token, '_blank');
|
|
197
209
|
}
|
|
198
210
|
else if (app === 'rocketbox') {
|
|
199
211
|
if (this.userData.allow_rb_panel || this.userData.is_rb_user) {
|
|
200
|
-
window.location.href
|
|
212
|
+
// Use setTimeout for window.location.href redirects
|
|
213
|
+
setTimeout(function () {
|
|
214
|
+
window.location.href = _this.DOMAIN + "/rocketbox";
|
|
215
|
+
}, 500);
|
|
201
216
|
}
|
|
202
217
|
else {
|
|
203
|
-
|
|
218
|
+
setTimeout(function () {
|
|
219
|
+
window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
|
|
220
|
+
}, 500);
|
|
204
221
|
}
|
|
205
222
|
}
|
|
206
223
|
else if (((_a = this.userData) === null || _a === void 0 ? void 0 : _a.allow_sr_convert) &&
|
|
207
224
|
!((_b = this.userData) === null || _b === void 0 ? void 0 : _b.allow_engage) &&
|
|
208
225
|
app === 'sr_convert') {
|
|
209
|
-
|
|
226
|
+
windowRef.open(this.SR_CONSTANTS.WigzoWebBaseUrl + "/" + this.userData.token, '_blank');
|
|
210
227
|
}
|
|
211
228
|
else if (app === 'sr_genie') {
|
|
212
|
-
|
|
229
|
+
windowRef.open("https://ai-test.kartrocket.com/login?token=" + this.userData.token, '_blank');
|
|
213
230
|
}
|
|
214
231
|
else if (app === 'one_impression') {
|
|
215
232
|
// Calling one-impression and redirecting to new tab
|
|
@@ -219,10 +236,10 @@
|
|
|
219
236
|
this.fetchOpenInAppLink();
|
|
220
237
|
}
|
|
221
238
|
else if (app === 'wigzo') {
|
|
222
|
-
|
|
239
|
+
windowRef.open("https://app.wigzo.com/auth/shiprocket/login/" + this.userData.token, '_blank');
|
|
223
240
|
}
|
|
224
241
|
else if (app === 'omuni') {
|
|
225
|
-
|
|
242
|
+
windowRef.open("https://omuni.com/", '_blank');
|
|
226
243
|
// if (this.userData?.is_omuni2_user == 1) {
|
|
227
244
|
// this.httpService.get('omuni/switch').subscribe(
|
|
228
245
|
// (res) => {
|
|
@@ -241,59 +258,82 @@
|
|
|
241
258
|
// }
|
|
242
259
|
}
|
|
243
260
|
else if (app === 'trends') {
|
|
244
|
-
|
|
261
|
+
windowRef.open("https://trends.shiprocket.in/", '_blank');
|
|
245
262
|
}
|
|
246
263
|
else if (app === 'creditScore') {
|
|
247
264
|
if ((_c = this.userData) === null || _c === void 0 ? void 0 : _c.is_crif_enabled) {
|
|
248
|
-
|
|
265
|
+
windowRef.open("https://capital-web.shiprocket.in/crif-home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=crif_credit_score&utm_term=app_switcher_click&authToken=" + this.userData.token, '_blank');
|
|
249
266
|
}
|
|
250
267
|
else {
|
|
251
|
-
|
|
268
|
+
windowRef.open("https://www.shiprocket.in/capital/", '_blank');
|
|
252
269
|
}
|
|
253
270
|
}
|
|
254
271
|
else if (app === 'capital') {
|
|
255
|
-
|
|
272
|
+
windowRef.open("https://capital-web.shiprocket.in/home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=capital&utm_term=flexi_business_loan&authToken=" + this.userData.token, '_blank');
|
|
256
273
|
}
|
|
257
274
|
else if (app === 'marketing') {
|
|
258
|
-
window.location.href
|
|
275
|
+
// Use setTimeout for window.location.href redirects
|
|
276
|
+
setTimeout(function () {
|
|
277
|
+
window.location.href = _this.DOMAIN + "/seller/home";
|
|
278
|
+
}, 500);
|
|
259
279
|
}
|
|
260
280
|
else if (app === 'whatsapp_solutions') {
|
|
261
281
|
if (this.userData.allow_engage) {
|
|
262
|
-
|
|
282
|
+
windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper?token=" + this.userData.token, '_blank');
|
|
263
283
|
}
|
|
264
284
|
else {
|
|
265
|
-
|
|
285
|
+
windowRef.open("https://app-engage.shiprocket.in/auth/register", '_blank');
|
|
266
286
|
}
|
|
267
287
|
}
|
|
268
288
|
else if (app === 'internationalParcels') {
|
|
269
289
|
if (kyc_status == 0 || kyc_status == 1 || kyc_status == 2 || kyc_status == 4) {
|
|
270
|
-
window.location.href
|
|
290
|
+
// Use setTimeout for window.location.href redirects
|
|
291
|
+
setTimeout(function () {
|
|
292
|
+
window.location.href = _this.DOMAIN + "/seller/internationalDashboard/overview";
|
|
293
|
+
}, 500);
|
|
271
294
|
}
|
|
272
295
|
else {
|
|
273
|
-
|
|
296
|
+
setTimeout(function () {
|
|
297
|
+
window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
|
|
298
|
+
}, 500);
|
|
274
299
|
}
|
|
275
300
|
}
|
|
276
301
|
else if (app === 'i_rocketbox') {
|
|
277
|
-
window.location.href
|
|
302
|
+
// Use setTimeout for window.location.href redirects
|
|
303
|
+
setTimeout(function () {
|
|
304
|
+
window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
|
|
305
|
+
}, 500);
|
|
278
306
|
}
|
|
279
307
|
else if (app === 'brand_launch') {
|
|
280
|
-
window.location.href
|
|
308
|
+
// Use setTimeout for window.location.href redirects
|
|
309
|
+
setTimeout(function () {
|
|
310
|
+
window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
|
|
311
|
+
}, 500);
|
|
281
312
|
}
|
|
282
313
|
else if (app === 'express_parcel') {
|
|
283
|
-
window.location.href
|
|
314
|
+
// Use setTimeout for window.location.href redirects
|
|
315
|
+
setTimeout(function () {
|
|
316
|
+
window.location.href = _this.DOMAIN + "/seller/home";
|
|
317
|
+
}, 500);
|
|
284
318
|
}
|
|
285
319
|
else if (app === 'instant_deliveries') {
|
|
286
|
-
|
|
320
|
+
windowRef.open(this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper?token=" + this.userData.token, '_blank');
|
|
287
321
|
return;
|
|
288
322
|
}
|
|
289
323
|
else if (app === 'warehousing') {
|
|
290
|
-
|
|
324
|
+
windowRef.open("https://fulfillment.shiprocket.in/", '_blank');
|
|
291
325
|
}
|
|
292
326
|
else if (app == 'srocketbox') {
|
|
293
|
-
window.location.href
|
|
327
|
+
// Use setTimeout for window.location.href redirects
|
|
328
|
+
setTimeout(function () {
|
|
329
|
+
window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
|
|
330
|
+
}, 500);
|
|
294
331
|
}
|
|
295
332
|
else if (app == 'somuni') {
|
|
296
|
-
window.location.href
|
|
333
|
+
// Use setTimeout for window.location.href redirects
|
|
334
|
+
setTimeout(function () {
|
|
335
|
+
window.location.href = _this.DOMAIN + "/seller/home";
|
|
336
|
+
}, 500);
|
|
297
337
|
}
|
|
298
338
|
};
|
|
299
339
|
AppSwitcherService.prototype.sendGaEvent = function (event) {
|
|
@@ -388,6 +428,8 @@
|
|
|
388
428
|
}
|
|
389
429
|
this.send(category, eventName, label);
|
|
390
430
|
};
|
|
431
|
+
AppSwitcherService.prototype.moengageEvent = function (event) {
|
|
432
|
+
};
|
|
391
433
|
AppSwitcherService.prototype.send = function (eventCategory, eventAction, eventLabel) {
|
|
392
434
|
var _a, _b, _c;
|
|
393
435
|
var source = ((_a = document.cookie
|
|
@@ -456,6 +498,11 @@
|
|
|
456
498
|
this.isLoadingRecentProducts = false; // Start as false since we'll load from cache first
|
|
457
499
|
this.shouldShowRecentSection = false;
|
|
458
500
|
this.hasLoadedData = false; // Track if we've loaded data at least once
|
|
501
|
+
this.isApiCallInProgress = false; // Prevent duplicate API calls
|
|
502
|
+
this.apiRetryCount = 0; // Track API retry attempts
|
|
503
|
+
this.modalHasBeenOpened = false; // Track if modal has been opened at least once
|
|
504
|
+
this.skeletonMinDuration = 1000; // Minimum skeleton loader duration (1 second)
|
|
505
|
+
this.skeletonStartTime = 0; // Track when skeleton started showing
|
|
459
506
|
this.appSwitcherApps = {
|
|
460
507
|
shipping_fulfilment_india: [
|
|
461
508
|
{
|
|
@@ -717,10 +764,16 @@
|
|
|
717
764
|
}
|
|
718
765
|
SwitcherComponent.prototype.openModal = function (param) {
|
|
719
766
|
var _this = this;
|
|
720
|
-
var _a;
|
|
721
|
-
|
|
767
|
+
var _a, _b, _c, _d, _e;
|
|
768
|
+
if (param == 'mobile') {
|
|
769
|
+
(_b = (_a = this.windowRef.nativeWindow) === null || _a === void 0 ? void 0 : _a.Moengage) === null || _b === void 0 ? void 0 : _b.track_event("bottom_navigation_clicked", { "company_id": this.company_id, "button_name": 'Switcher' });
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
(_d = (_c = this.windowRef.nativeWindow) === null || _c === void 0 ? void 0 : _c.Moengage) === null || _d === void 0 ? void 0 : _d.track_event("button_clicked", { "company_id": this.company_id, "button_name": 'Switcher' });
|
|
773
|
+
}
|
|
722
774
|
this.isModalOpen = true;
|
|
723
775
|
this.showProducts = false;
|
|
776
|
+
this.modalHasBeenOpened = true; // Mark that modal has been opened
|
|
724
777
|
var sidebar = document.querySelector('app-sidebar');
|
|
725
778
|
if (sidebar) {
|
|
726
779
|
sidebar.setAttribute('style', 'display: none');
|
|
@@ -730,7 +783,7 @@
|
|
|
730
783
|
if (intercomWidget) {
|
|
731
784
|
intercomWidget.style.display = 'none';
|
|
732
785
|
}
|
|
733
|
-
// Only load data if we haven't loaded it before
|
|
786
|
+
// Only load data if we haven't loaded it before AND modal has been opened
|
|
734
787
|
if (!this.hasLoadedData) {
|
|
735
788
|
this.loadRecentProductsData();
|
|
736
789
|
}
|
|
@@ -739,7 +792,7 @@
|
|
|
739
792
|
}, 200);
|
|
740
793
|
if (param == 'mobile') {
|
|
741
794
|
this.userJson = JSON.parse(localStorage.getItem('ngStorage-USER') || localStorage.getItem('_userData') || '{}');
|
|
742
|
-
this.company_id = this.userJson != null ? (
|
|
795
|
+
this.company_id = this.userJson != null ? (_e = this.userJson) === null || _e === void 0 ? void 0 : _e.company_id : '';
|
|
743
796
|
this.appSwitcherService.send('All Products', 'All Products Mobile', 'Company Id: ' + this.company_id);
|
|
744
797
|
}
|
|
745
798
|
else if (param == 'desktop') {
|
|
@@ -769,14 +822,18 @@
|
|
|
769
822
|
_this.appSwitcherApps[category] = _this.appSwitcherApps[category].filter(function (app) { return !appsToRemove_1.includes(app.appName); });
|
|
770
823
|
});
|
|
771
824
|
}
|
|
772
|
-
//
|
|
773
|
-
this.loadRecentProductsData();
|
|
825
|
+
// CRITICAL: Do NOT load data here - only load when modal is explicitly opened
|
|
826
|
+
// this.loadRecentProductsData(); // This should NEVER be uncommented
|
|
827
|
+
console.log('SwitcherComponent initialized - NO API calls should happen until modal is opened');
|
|
774
828
|
};
|
|
775
829
|
SwitcherComponent.prototype.ngOnDestroy = function () {
|
|
776
830
|
this.windowRef.nativeWindow.removeEventListener('resize', this.resizeListener);
|
|
777
831
|
if (this.resizeTimeout) {
|
|
778
832
|
clearTimeout(this.resizeTimeout);
|
|
779
833
|
}
|
|
834
|
+
if (this.apiCallTimeout) {
|
|
835
|
+
clearTimeout(this.apiCallTimeout);
|
|
836
|
+
}
|
|
780
837
|
};
|
|
781
838
|
SwitcherComponent.prototype.checkScreenSize = function () {
|
|
782
839
|
var width = this.windowRef.nativeWindow.innerWidth;
|
|
@@ -809,6 +866,20 @@
|
|
|
809
866
|
return 'https://apiv2.shiprocket.co/v1/';
|
|
810
867
|
}
|
|
811
868
|
};
|
|
869
|
+
SwitcherComponent.prototype.isTokenValid = function () {
|
|
870
|
+
try {
|
|
871
|
+
var token = this.userData.token;
|
|
872
|
+
if (!token)
|
|
873
|
+
return false;
|
|
874
|
+
var payload = JSON.parse(atob(token.split('.')[1]));
|
|
875
|
+
var now = Math.floor(Date.now() / 1000);
|
|
876
|
+
return payload.exp > now;
|
|
877
|
+
}
|
|
878
|
+
catch (error) {
|
|
879
|
+
console.warn('Invalid JWT token:', error);
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
};
|
|
812
883
|
SwitcherComponent.prototype.analyticsevent = function (item) {
|
|
813
884
|
this.appSwitcherService.send('Switcher Service Selection', 'Recent Used Product', 'App: ' + item.displayName);
|
|
814
885
|
};
|
|
@@ -848,7 +919,11 @@
|
|
|
848
919
|
};
|
|
849
920
|
this._http.post(this.getBaseUrl() + "settings/company-service", data, { headers: headers }).subscribe(function (res) {
|
|
850
921
|
// API call complete, but we don't wait for it
|
|
851
|
-
|
|
922
|
+
console.log('POST API call successful for:', displayName);
|
|
923
|
+
}, function (error) {
|
|
924
|
+
// Log error but don't retry for POST calls
|
|
925
|
+
console.warn('POST API call failed for:', displayName, error);
|
|
926
|
+
});
|
|
852
927
|
// Handle UI updates and navigation independently with timeout
|
|
853
928
|
setTimeout(function () {
|
|
854
929
|
if (clickedApp) {
|
|
@@ -884,8 +959,38 @@
|
|
|
884
959
|
SwitcherComponent.prototype.loadRecentProductsData = function () {
|
|
885
960
|
// First, try to load from localStorage for immediate display
|
|
886
961
|
this.loadFromCache();
|
|
887
|
-
//
|
|
888
|
-
this.
|
|
962
|
+
// Only fetch from API if we don't have cached data
|
|
963
|
+
if (this.recentUsedProducts.length === 0) {
|
|
964
|
+
// Show skeleton loader while fetching from API
|
|
965
|
+
this.shouldShowRecentSection = true;
|
|
966
|
+
this.isLoadingRecentProducts = true;
|
|
967
|
+
this.skeletonStartTime = Date.now(); // Track when skeleton started
|
|
968
|
+
// Debounce API calls to prevent rapid successive calls
|
|
969
|
+
this.debouncedFetchFromAPI();
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
// We have cached data, just mark as loaded
|
|
973
|
+
this.hasLoadedData = true;
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
SwitcherComponent.prototype.debouncedFetchFromAPI = function () {
|
|
977
|
+
var _this = this;
|
|
978
|
+
// Clear previous timeout
|
|
979
|
+
if (this.apiCallTimeout) {
|
|
980
|
+
clearTimeout(this.apiCallTimeout);
|
|
981
|
+
}
|
|
982
|
+
// Debounce API calls by 500ms to prevent rapid successive calls
|
|
983
|
+
this.apiCallTimeout = setTimeout(function () {
|
|
984
|
+
_this.fetchRecentProductsFromAPI();
|
|
985
|
+
}, 500);
|
|
986
|
+
};
|
|
987
|
+
SwitcherComponent.prototype.hideSkeletonWithMinDuration = function () {
|
|
988
|
+
var _this = this;
|
|
989
|
+
var elapsedTime = Date.now() - this.skeletonStartTime;
|
|
990
|
+
var remainingTime = Math.max(0, this.skeletonMinDuration - elapsedTime);
|
|
991
|
+
setTimeout(function () {
|
|
992
|
+
_this.isLoadingRecentProducts = false;
|
|
993
|
+
}, remainingTime);
|
|
889
994
|
};
|
|
890
995
|
SwitcherComponent.prototype.loadFromCache = function () {
|
|
891
996
|
// Check if we have recent products stored in localStorage from previous sessions
|
|
@@ -945,15 +1050,40 @@
|
|
|
945
1050
|
};
|
|
946
1051
|
SwitcherComponent.prototype.fetchRecentProductsFromAPI = function () {
|
|
947
1052
|
var _this = this;
|
|
948
|
-
// Only
|
|
949
|
-
if (this.
|
|
950
|
-
|
|
1053
|
+
// CRITICAL: Only allow API calls when modal has been explicitly opened
|
|
1054
|
+
if (!this.modalHasBeenOpened) {
|
|
1055
|
+
console.warn('API call blocked: Modal has not been opened yet');
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
// Prevent duplicate API calls
|
|
1059
|
+
if (this.isApiCallInProgress || this.hasLoadedData) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
// Check if token is valid before making API call
|
|
1063
|
+
if (!this.isTokenValid()) {
|
|
1064
|
+
console.warn('Invalid or expired JWT token, skipping API call');
|
|
1065
|
+
this.isLoadingRecentProducts = false;
|
|
1066
|
+
this.hasLoadedData = true;
|
|
1067
|
+
this.shouldShowRecentSection = false;
|
|
1068
|
+
return;
|
|
951
1069
|
}
|
|
1070
|
+
// Check retry limit
|
|
1071
|
+
if (this.apiRetryCount >= 3) {
|
|
1072
|
+
console.log('Max API retries reached, stopping API calls');
|
|
1073
|
+
this.isLoadingRecentProducts = false;
|
|
1074
|
+
this.hasLoadedData = true;
|
|
1075
|
+
this.shouldShowRecentSection = false;
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
this.isApiCallInProgress = true;
|
|
1079
|
+
// Loading state is already set in loadRecentProductsData() if needed
|
|
952
1080
|
var headers = {
|
|
953
1081
|
'Content-Type': 'application/json',
|
|
954
1082
|
'Authorization': 'Bearer ' + this.userData.token
|
|
955
1083
|
};
|
|
956
1084
|
this._http.get(this.getBaseUrl() + "settings/company-service", { headers: headers }).subscribe(function (res) {
|
|
1085
|
+
// Success - reset retry count
|
|
1086
|
+
_this.apiRetryCount = 0;
|
|
957
1087
|
_this.appSwitchList = res.data;
|
|
958
1088
|
// Map the API response to recentUsedProducts
|
|
959
1089
|
var newRecentProducts = res.data.map(function (item) {
|
|
@@ -985,13 +1115,23 @@
|
|
|
985
1115
|
localStorage.removeItem('recentUsedProducts');
|
|
986
1116
|
}
|
|
987
1117
|
}
|
|
988
|
-
//
|
|
989
|
-
_this.
|
|
1118
|
+
// Hide skeleton with minimum duration to prevent flicker
|
|
1119
|
+
_this.hideSkeletonWithMinDuration();
|
|
990
1120
|
_this.hasLoadedData = true;
|
|
1121
|
+
_this.isApiCallInProgress = false;
|
|
991
1122
|
}, function (error) {
|
|
992
|
-
//
|
|
993
|
-
_this.
|
|
1123
|
+
// Increment retry count
|
|
1124
|
+
_this.apiRetryCount++;
|
|
1125
|
+
console.warn("API call failed (attempt " + _this.apiRetryCount + "/3):", error);
|
|
1126
|
+
// If 403 error, don't retry immediately
|
|
1127
|
+
if (error.status === 403) {
|
|
1128
|
+
console.log('403 Forbidden - stopping retries immediately');
|
|
1129
|
+
_this.apiRetryCount = 3; // Max out retries
|
|
1130
|
+
}
|
|
1131
|
+
// Hide skeleton with minimum duration even on error
|
|
1132
|
+
_this.hideSkeletonWithMinDuration();
|
|
994
1133
|
_this.hasLoadedData = true;
|
|
1134
|
+
_this.isApiCallInProgress = false;
|
|
995
1135
|
// Don't change shouldShowRecentSection if we have cached data
|
|
996
1136
|
if (_this.recentUsedProducts.length === 0) {
|
|
997
1137
|
_this.shouldShowRecentSection = false;
|
|
@@ -999,8 +1139,13 @@
|
|
|
999
1139
|
});
|
|
1000
1140
|
};
|
|
1001
1141
|
SwitcherComponent.prototype.getCompanyService = function () {
|
|
1002
|
-
// This method is kept for backward compatibility but
|
|
1003
|
-
this.
|
|
1142
|
+
// This method is kept for backward compatibility but only calls API if modal has been opened
|
|
1143
|
+
if (this.modalHasBeenOpened) {
|
|
1144
|
+
this.fetchRecentProductsFromAPI();
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
console.warn('getCompanyService() blocked: Modal has not been opened yet');
|
|
1148
|
+
}
|
|
1004
1149
|
};
|
|
1005
1150
|
return SwitcherComponent;
|
|
1006
1151
|
}());
|