simpo-component-library 1.4.18 → 1.4.19

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.
@@ -96,6 +96,7 @@ class EventsService {
96
96
  this.placeOrder = new EventEmitter();
97
97
  this.featureCollectionList = new EventEmitter();
98
98
  this.environmentType = new EventEmitter();
99
+ this.showLoadingScreen = new EventEmitter();
99
100
  }
100
101
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: EventsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
101
102
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: EventsService, providedIn: 'root' }); }
@@ -3223,7 +3224,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
3223
3224
  }], ctorParameters: () => [{ type: RestService }, { type: i2$2.Router }, { type: i3.MatDialogRef }] });
3224
3225
 
3225
3226
  class StorageServiceService {
3226
- constructor() {
3227
+ constructor(eventService) {
3228
+ this.eventService = eventService;
3227
3229
  this.databaseName = "USER";
3228
3230
  this.databaseVersion = 1;
3229
3231
  this.cartCollectionName = "USER_CART";
@@ -3235,10 +3237,16 @@ class StorageServiceService {
3235
3237
  this.createDataBase();
3236
3238
  }
3237
3239
  async createDataBase() {
3238
- const request = window.indexedDB.open(this.databaseName, 1);
3240
+ const request = await window.indexedDB.open(this.databaseName, 1);
3241
+ this.eventService.showLoadingScreen.emit(true);
3239
3242
  request.onerror = () => { };
3240
3243
  request.onsuccess = async (event) => {
3241
3244
  this.database = await event.target.result;
3245
+ const request = await this.getUserCart();
3246
+ request.onsuccess = async (response) => {
3247
+ this.eventService.showLoadingScreen.emit(false);
3248
+ UserCart.orderedItems = await response.target.result;
3249
+ };
3242
3250
  };
3243
3251
  request.onupgradeneeded = (event) => {
3244
3252
  this.database = event.target.result;
@@ -3247,10 +3255,18 @@ class StorageServiceService {
3247
3255
  this.userCollectionRef = this.database.createObjectStore(this.userCollectionName, { keyPath: "userId" });
3248
3256
  };
3249
3257
  }
3258
+ async storeDataToJSON() {
3259
+ this.eventService.showLoadingScreen.emit(true);
3260
+ const request = await this.getUserCart();
3261
+ request.onsuccess = async (response) => {
3262
+ this.eventService.showLoadingScreen.emit(false);
3263
+ UserCart.orderedItems = await response.target.result;
3264
+ };
3265
+ }
3250
3266
  // CART SERVICE
3251
3267
  async getUserCart() {
3252
- const request = await this.cartCollectionRef?.getAll();
3253
- return request;
3268
+ const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
3269
+ return await transaction.objectStore(this.cartCollectionName).getAll();
3254
3270
  }
3255
3271
  addProductToCart(product) {
3256
3272
  const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
@@ -3290,7 +3306,7 @@ class StorageServiceService {
3290
3306
  const user = localStorage.getItem("user") ?? "{}";
3291
3307
  return JSON.parse(user);
3292
3308
  }
3293
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3309
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, deps: [{ token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3294
3310
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, providedIn: 'root' }); }
3295
3311
  }
3296
3312
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, decorators: [{
@@ -3298,7 +3314,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
3298
3314
  args: [{
3299
3315
  providedIn: 'root'
3300
3316
  }]
3301
- }], ctorParameters: () => [] });
3317
+ }], ctorParameters: () => [{ type: EventsService }] });
3302
3318
 
3303
3319
  class AuthenticateUserComponent {
3304
3320
  constructor(matData, restService, router, matDialog, storageService, dialogRef) {
@@ -4762,8 +4778,7 @@ class OrderedItems {
4762
4778
  }
4763
4779
 
4764
4780
  class CartService {
4765
- constructor(restService, storageService) {
4766
- this.restService = restService;
4781
+ constructor(storageService) {
4767
4782
  this.storageService = storageService;
4768
4783
  }
4769
4784
  addItemToCart(product) {
@@ -4848,6 +4863,7 @@ class CartService {
4848
4863
  }
4849
4864
  getItemByIdx(itemId, type) {
4850
4865
  const productIdx = this.getItemIdxJSON(itemId, type);
4866
+ console.log(type, productIdx);
4851
4867
  const json = (type == "FAVOURITE") ? UserFavourite : UserCart;
4852
4868
  if (productIdx >= 0)
4853
4869
  return json.orderedItems[productIdx];
@@ -4862,6 +4878,9 @@ class CartService {
4862
4878
  // this.restService.addItemToDB(UserFavourites).subscribe((response)=> {});
4863
4879
  }
4864
4880
  storeDBToJSON() {
4881
+ // this.storageService.getUserCart().then((response)=> {
4882
+ //
4883
+ // })
4865
4884
  // const userId = UserDetails.user?.userId;
4866
4885
  // if (!userId)
4867
4886
  // return;
@@ -4876,7 +4895,7 @@ class CartService {
4876
4895
  // UserFavourites.totalAmount = response.totalAmount;
4877
4896
  // })
4878
4897
  }
4879
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, deps: [{ token: RestService }, { token: StorageServiceService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4898
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, deps: [{ token: StorageServiceService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4880
4899
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, providedIn: 'root' }); }
4881
4900
  }
4882
4901
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, decorators: [{
@@ -4884,7 +4903,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
4884
4903
  args: [{
4885
4904
  providedIn: 'root',
4886
4905
  }]
4887
- }], ctorParameters: () => [{ type: RestService }, { type: StorageServiceService }] });
4906
+ }], ctorParameters: () => [{ type: StorageServiceService }] });
4888
4907
 
4889
4908
  class FeaturedProductsComponent extends BaseSection {
4890
4909
  constructor(platformId, _eventService, restService, router, cartService) {
@@ -5101,11 +5120,11 @@ class ProductDescComponent extends BaseSection {
5101
5120
  if (this.responseData) {
5102
5121
  const cartItem = this.cartService.getItemByIdx(this.responseData?.itemId, "CART");
5103
5122
  const favItem = this.cartService.getItemByIdx(this.responseData?.itemId, "FAVOURITE");
5104
- response.quantity = 0;
5123
+ this.responseData.quantity = 0;
5105
5124
  if (cartItem)
5106
- response.quantity = cartItem.quantity;
5125
+ this.responseData.quantity = cartItem.quantity;
5107
5126
  if (favItem)
5108
- response.quantity = favItem.quantity;
5127
+ this.responseData.quantity = favItem.quantity;
5109
5128
  this.currentImg = this.responseData?.itemImages[0].imgUrl;
5110
5129
  this.getProductByCategory();
5111
5130
  }
@@ -5561,10 +5580,10 @@ class CartComponent extends BaseSection {
5561
5580
  // userDetails: any;
5562
5581
  // getUserInfo() {
5563
5582
  // const userId = "dc915bd4-fa6f-446e-bce2-440b6804af22";
5564
- // debugger;
5583
+ //
5565
5584
  // return this.restService.getUserInfo(userId).subscribe((response: any)=> {
5566
5585
  // this.userDetails = response.data;
5567
- // debugger;
5586
+ //
5568
5587
  // })
5569
5588
  // }
5570
5589
  proceedToCheckout() {