simpo-component-library 1.4.36 → 1.4.37

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.
@@ -3272,10 +3272,11 @@ var UserFavourite = {
3272
3272
  };
3273
3273
 
3274
3274
  class StorageServiceService {
3275
- constructor(eventService, cookieService, restService) {
3275
+ constructor(eventService, cookieService, restService, storageService) {
3276
3276
  this.eventService = eventService;
3277
3277
  this.cookieService = cookieService;
3278
3278
  this.restService = restService;
3279
+ this.storageService = storageService;
3279
3280
  this.databaseName = "USER";
3280
3281
  this.databaseVersion = 1;
3281
3282
  this.cartCollectionName = "USER_CART";
@@ -3336,14 +3337,23 @@ class StorageServiceService {
3336
3337
  updateAllData() {
3337
3338
  const userDetails = this.getUser();
3338
3339
  if (userDetails) {
3340
+ this.eventService.showLoadingScreen.emit(true);
3339
3341
  forkJoin([
3340
3342
  this.restService.getUserItems(userDetails.userId, "CART"),
3341
3343
  this.restService.getUserItems(userDetails.userId, "WISHLIST")
3342
3344
  ]).subscribe(([cartResponse]) => {
3343
- // cartResponse.data.forEach((item: OrderedItems)=> {
3344
- // storageService.addProductToCart(item);
3345
- // })
3346
- this.storeDataToJSON();
3345
+ console.log("Cart Response : ", cartResponse);
3346
+ UserCart.orderedItems = [];
3347
+ UserFavourite.orderedItems = [];
3348
+ cartResponse[0].data?.forEach((item) => {
3349
+ this.storageService.addProductToCart(item);
3350
+ UserCart.orderedItems.push(item);
3351
+ });
3352
+ cartResponse[1].data?.forEach((item) => {
3353
+ this.storageService.addProductToWishlist(item);
3354
+ UserFavourite.orderedItems.push(item);
3355
+ });
3356
+ this.eventService.showLoadingScreen.emit(false);
3347
3357
  });
3348
3358
  }
3349
3359
  else {
@@ -3394,8 +3404,9 @@ class StorageServiceService {
3394
3404
  return JSON.parse(this.cookieService.get("user"));
3395
3405
  }
3396
3406
  catch (exception) { }
3407
+ return null;
3397
3408
  }
3398
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, deps: [{ token: EventsService }, { token: i2$3.CookieService }, { token: RestService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3409
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, deps: [{ token: EventsService }, { token: i2$3.CookieService }, { token: RestService }, { token: StorageServiceService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3399
3410
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, providedIn: 'root' }); }
3400
3411
  }
3401
3412
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, decorators: [{
@@ -3403,7 +3414,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
3403
3414
  args: [{
3404
3415
  providedIn: 'root'
3405
3416
  }]
3406
- }], ctorParameters: () => [{ type: EventsService }, { type: i2$3.CookieService }, { type: RestService }] });
3417
+ }], ctorParameters: () => [{ type: EventsService }, { type: i2$3.CookieService }, { type: RestService }, { type: StorageServiceService }] });
3407
3418
 
3408
3419
  class AuthenticateUserComponent {
3409
3420
  constructor(matData, restService, router, matDialog, storageService, dialogRef, _eventService) {
@@ -3530,7 +3541,7 @@ class NavbarSectionComponent {
3530
3541
  this.router.navigate(['/whislist']);
3531
3542
  }
3532
3543
  goToAccount() {
3533
- if (this.cookieService.get("user")) {
3544
+ if (this.storageService.getUser()) {
3534
3545
  this.router.navigate(['/profile']);
3535
3546
  }
3536
3547
  else {
@@ -5686,17 +5697,19 @@ class CartComponent extends BaseSection {
5686
5697
  this._eventService.showLoadingScreen.subscribe((response) => {
5687
5698
  this.isLoading = response;
5688
5699
  });
5689
- if (this.cookieService.get("user")) {
5690
- const userDetails = JSON.parse(this.cookieService.get("user"));
5700
+ if (this.storageService.getUser()) {
5701
+ const userDetails = this.storageService.getUser();
5691
5702
  console.log("user deatils", userDetails);
5703
+ UserInfo.user.addressDetailsList = userDetails.addressDetailsList;
5692
5704
  UserCart.userDetails = { ...UserCart.userDetails, ...UserInfo.user.contact, userId: userDetails.userId };
5693
5705
  this.cartService.storeDataToServer().subscribe((response) => {
5694
5706
  console.log("a: ", UserCart, this.responseData, response);
5695
- UserCart.billdetails = response[0].data.billdetails;
5696
- UserCart.cartId = response[0].data.cartId;
5697
- UserCart.orderedItems = response[0].data.orderedItems;
5707
+ if (response[0].data) {
5708
+ UserCart.billdetails = response[0].data.billdetails;
5709
+ UserCart.cartId = response[0].data.cartId;
5710
+ UserCart.orderedItems = response[0].data.orderedItems;
5711
+ }
5698
5712
  this.responseData = this.storageService.calculateBillingDetails();
5699
- this.styles = this.data?.styles;
5700
5713
  });
5701
5714
  }
5702
5715
  else {
@@ -5704,6 +5717,7 @@ class CartComponent extends BaseSection {
5704
5717
  this.responseData = this.storageService.calculateBillingDetails();
5705
5718
  console.log(this.responseData);
5706
5719
  }
5720
+ this.styles = this.data?.styles;
5707
5721
  }
5708
5722
  // userDetails: any;
5709
5723
  // getUserInfo() {
@@ -5715,7 +5729,7 @@ class CartComponent extends BaseSection {
5715
5729
  // })
5716
5730
  // }
5717
5731
  proceedToCheckout() {
5718
- if (this.cookieService.get("user")) {
5732
+ if (this.storageService.getUser()) {
5719
5733
  this.currentTab = "ADDRESS";
5720
5734
  }
5721
5735
  else {
@@ -5750,11 +5764,11 @@ class CartComponent extends BaseSection {
5750
5764
  this.responseData = this.storageService.calculateBillingDetails();
5751
5765
  }
5752
5766
  proceedToPayment() {
5753
- if (!this.cookieService.get("user")) {
5767
+ if (!this.storageService.getUser()) {
5754
5768
  console.log("User not logged In");
5755
5769
  return;
5756
5770
  }
5757
- const userDetail = JSON.parse(this.cookieService.get("user"));
5771
+ const userDetail = this.storageService.getUser();
5758
5772
  console.log("User Details", userDetail);
5759
5773
  const address = UserInfo.user.addressDetailsList[0];
5760
5774
  const payload = {
@@ -5769,6 +5783,7 @@ class CartComponent extends BaseSection {
5769
5783
  }
5770
5784
  };
5771
5785
  this.restService.createPaymentToken(payload).subscribe((response) => {
5786
+ console.log(response);
5772
5787
  });
5773
5788
  }
5774
5789
  get getAddressList() {