@esolve/ng-esolve-connect 0.29.4 → 0.29.5
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/esm2020/lib/coupons/esolve-coupons.service.mjs +41 -13
- package/fesm2015/esolve-ng-esolve-connect.mjs +39 -11
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +39 -11
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/coupons/esolve-coupons.service.d.ts +6 -1
- package/package.json +1 -1
|
@@ -2579,7 +2579,8 @@ class EsolveCoupon {
|
|
|
2579
2579
|
;
|
|
2580
2580
|
|
|
2581
2581
|
class EsolveCouponsService {
|
|
2582
|
-
constructor(config, http, cookieService) {
|
|
2582
|
+
constructor(platformId, config, http, cookieService) {
|
|
2583
|
+
this.platformId = platformId;
|
|
2583
2584
|
this.config = config;
|
|
2584
2585
|
this.http = http;
|
|
2585
2586
|
this.cookieService = cookieService;
|
|
@@ -2589,6 +2590,7 @@ class EsolveCouponsService {
|
|
|
2589
2590
|
this.validation_error = new Subject();
|
|
2590
2591
|
this.setStorageKey();
|
|
2591
2592
|
this.coupons_cache = this.retrieveCache();
|
|
2593
|
+
this.is_browser = isPlatformBrowser(this.platformId);
|
|
2592
2594
|
}
|
|
2593
2595
|
onValidationError() {
|
|
2594
2596
|
return this.validation_error.asObservable();
|
|
@@ -2666,11 +2668,10 @@ class EsolveCouponsService {
|
|
|
2666
2668
|
this.deleteCoupons();
|
|
2667
2669
|
}
|
|
2668
2670
|
retrieveCache() {
|
|
2669
|
-
if (this.cookieService.check(this.storage_key) ||
|
|
2670
|
-
localStorage.getItem(this.storage_key)) {
|
|
2671
|
+
if (this.cookieService.check(this.storage_key) || this.getBackup()) {
|
|
2671
2672
|
let coupons_json = this.cookieService.get(this.storage_key);
|
|
2672
|
-
if (coupons_json === ''
|
|
2673
|
-
|
|
2673
|
+
if (coupons_json === '') {
|
|
2674
|
+
const local_store_data = this.getBackup();
|
|
2674
2675
|
if (local_store_data) {
|
|
2675
2676
|
coupons_json = local_store_data;
|
|
2676
2677
|
}
|
|
@@ -2688,9 +2689,7 @@ class EsolveCouponsService {
|
|
|
2688
2689
|
if (this.coupons_cache.size > 0) {
|
|
2689
2690
|
const coupons_json = this.jsonEncodeMap(this.coupons_cache);
|
|
2690
2691
|
this.cookieService.set(this.storage_key, coupons_json, undefined, '/');
|
|
2691
|
-
|
|
2692
|
-
localStorage.setItem(this.storage_key, coupons_json);
|
|
2693
|
-
}
|
|
2692
|
+
this.setBackup(coupons_json);
|
|
2694
2693
|
}
|
|
2695
2694
|
else {
|
|
2696
2695
|
this.deleteCoupons();
|
|
@@ -2699,9 +2698,34 @@ class EsolveCouponsService {
|
|
|
2699
2698
|
deleteCoupons() {
|
|
2700
2699
|
this.coupons_cache.clear();
|
|
2701
2700
|
this.cookieService.delete(this.storage_key, '/');
|
|
2702
|
-
|
|
2703
|
-
|
|
2701
|
+
this.removeBackup();
|
|
2702
|
+
}
|
|
2703
|
+
getBackup() {
|
|
2704
|
+
if (!this.is_browser) {
|
|
2705
|
+
return null;
|
|
2706
|
+
}
|
|
2707
|
+
if (!localStorage) {
|
|
2708
|
+
return null;
|
|
2704
2709
|
}
|
|
2710
|
+
return localStorage.getItem(this.storage_key);
|
|
2711
|
+
}
|
|
2712
|
+
setBackup(data) {
|
|
2713
|
+
if (!this.is_browser) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
if (!localStorage) {
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2719
|
+
localStorage.setItem(this.storage_key, data);
|
|
2720
|
+
}
|
|
2721
|
+
removeBackup() {
|
|
2722
|
+
if (!this.is_browser) {
|
|
2723
|
+
return;
|
|
2724
|
+
}
|
|
2725
|
+
if (!localStorage) {
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
localStorage.removeItem(this.storage_key);
|
|
2705
2729
|
}
|
|
2706
2730
|
addCoupon(id, key) {
|
|
2707
2731
|
if (!this.coupons_cache.has(id)) {
|
|
@@ -2757,7 +2781,7 @@ class EsolveCouponsService {
|
|
|
2757
2781
|
return coupons;
|
|
2758
2782
|
}
|
|
2759
2783
|
}
|
|
2760
|
-
EsolveCouponsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2784
|
+
EsolveCouponsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, deps: [{ token: PLATFORM_ID }, { token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2761
2785
|
EsolveCouponsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, providedIn: 'root' });
|
|
2762
2786
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, decorators: [{
|
|
2763
2787
|
type: Injectable,
|
|
@@ -2765,6 +2789,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
2765
2789
|
providedIn: 'root',
|
|
2766
2790
|
}]
|
|
2767
2791
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2792
|
+
type: Inject,
|
|
2793
|
+
args: [PLATFORM_ID]
|
|
2794
|
+
}] }, { type: undefined, decorators: [{
|
|
2768
2795
|
type: Inject,
|
|
2769
2796
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2770
2797
|
}] }, { type: i1$2.HttpClient }, { type: EsolveCookieService }]; } });
|
|
@@ -5611,3 +5638,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
5611
5638
|
|
|
5612
5639
|
export { ESOLVE_CONNECT_CONFIG, EsolveAccountConfirmationResult, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveCoupon, EsolveCouponsService, EsolveDependantItem, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveSupplier, EsolveSuppliersService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveVaultItem, EsolveVaultItemResult, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule };
|
|
5613
5640
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|
|
5641
|
+
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|