simpo-component-library 1.4.62 → 1.4.64

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.
@@ -3284,7 +3284,7 @@ class StorageServiceService {
3284
3284
  const response = transaction.objectStore(this.cartCollectionName).get(product.itemId);
3285
3285
  response.onsuccess = (cartResponse) => {
3286
3286
  console.log("Cart Resppnse : ", cartResponse);
3287
- if (cartResponse.target.result.length > 0) { }
3287
+ if (cartResponse.target.result) { }
3288
3288
  else {
3289
3289
  this.totalCartItems += 1;
3290
3290
  }
@@ -3294,6 +3294,7 @@ class StorageServiceService {
3294
3294
  addAllProductsToCart(products) {
3295
3295
  const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
3296
3296
  products.forEach((product) => {
3297
+ console.log(product + "info");
3297
3298
  const response = transaction.objectStore(this.cartCollectionName).put(product);
3298
3299
  });
3299
3300
  return transaction;
@@ -5653,12 +5654,42 @@ class CartComponent extends BaseSection {
5653
5654
  this.userDetails = null;
5654
5655
  this.userCart = null;
5655
5656
  this.USER_CART_ITEMS = null;
5656
- this.billdetails = {
5657
- "totalNetValue": 0,
5658
- "totalGrossValue": 0,
5659
- "totalTax": 0,
5660
- "totalOfferedValue": 0,
5661
- "deliveryCharges": 0
5657
+ this.cartInfo = {
5658
+ orderedItems: null,
5659
+ billdetails: {
5660
+ "totalNetValue": 0,
5661
+ "totalGrossValue": 0,
5662
+ "totalTax": 0,
5663
+ "totalOfferedValue": 0,
5664
+ "deliveryCharges": 0
5665
+ },
5666
+ platform: "WEB",
5667
+ cartType: "CART",
5668
+ userDetails: {
5669
+ "userId": "",
5670
+ "userName": "",
5671
+ "mobile": "",
5672
+ "email": "",
5673
+ "deliveryAddress": {
5674
+ "addressType": "",
5675
+ "receiverName": "",
5676
+ "receiverPhone": "",
5677
+ "countryName": "",
5678
+ "stateName": "",
5679
+ "cityName": "",
5680
+ "localityName": "",
5681
+ "addressLine1": "",
5682
+ "addressLine2": "",
5683
+ "landmark": "",
5684
+ "zipCode": "",
5685
+ "geolocation": {
5686
+ "latitude": 0,
5687
+ "longitude": 0
5688
+ },
5689
+ "stateCode": ""
5690
+ }
5691
+ },
5692
+ totalAmount: 0
5662
5693
  };
5663
5694
  }
5664
5695
  ngOnInit() {
@@ -5667,6 +5698,13 @@ class CartComponent extends BaseSection {
5667
5698
  });
5668
5699
  if (this.storageService.getUser()) {
5669
5700
  this.userDetails = this.storageService.getUser();
5701
+ this.cartInfo.userDetails = {
5702
+ "userId": this.userDetails?.userId,
5703
+ "userName": this.userDetails?.contact.name,
5704
+ "mobile": this.userDetails?.contact.mobile,
5705
+ "email": this.userDetails?.contact.email,
5706
+ "deliveryAddress": null,
5707
+ };
5670
5708
  this.restService.getUserItems(this.userDetails.userId, "CART").subscribe((response) => {
5671
5709
  const tempUserCart = response?.data?.orderedItems ?? [];
5672
5710
  localStorage.setItem('cartId', response.data?.cartId);
@@ -5674,53 +5712,55 @@ class CartComponent extends BaseSection {
5674
5712
  console.log(tempUserCart);
5675
5713
  console.log("ASYNC AWAIT TEST");
5676
5714
  this.storageService.addAllProductsToCart(tempUserCart).oncomplete = () => {
5677
- this.storageService.getUserCart().then((cartResponse) => {
5678
- cartResponse.onsuccess = (cartData) => {
5679
- console.log("cart Data", cartData);
5680
- this.USER_CART_ITEMS = cartData.target.result;
5681
- [...tempUserCart, ...this.USER_CART_ITEMS].forEach((item) => {
5682
- this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5683
- this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5684
- });
5685
- this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
5686
- this.responseData = { cartType: 'CART', totalAmount: this.billdetails.totalNetValue, orderedItems: [...tempUserCart, ...this.USER_CART_ITEMS], billdetails: this.billdetails };
5687
- console.log(this.responseData);
5688
- };
5715
+ console.log("completed");
5716
+ this.storageService.getUserCart().then((cartData) => {
5717
+ // cartResponse.onsuccess = (cartData: any) => {
5718
+ console.log("cart Data", cartData);
5719
+ this.USER_CART_ITEMS = cartData.result;
5720
+ [...tempUserCart, ...this.USER_CART_ITEMS].forEach((item) => {
5721
+ this.cartInfo.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5722
+ this.cartInfo.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5723
+ });
5724
+ this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue + this.cartInfo.billdetails.totalTax - this.cartInfo.billdetails.deliveryCharges;
5725
+ this.cartInfo.orderedItems = this.USER_CART_ITEMS;
5726
+ this.responseData = this.cartInfo;
5727
+ console.log(this.responseData);
5728
+ // }
5689
5729
  });
5690
5730
  };
5691
5731
  }
5692
5732
  else {
5693
- this.storageService.getUserCart().then((cartResponse) => {
5694
- cartResponse.onsuccess = (cartData) => {
5695
- console.log("cart Data", cartData);
5696
- this.USER_CART_ITEMS = cartData.target.result;
5697
- [...this.USER_CART_ITEMS].forEach((item) => {
5698
- this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5699
- this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5700
- });
5701
- this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
5702
- this.responseData = { cartType: 'CART', totalAmount: this.billdetails.totalNetValue, orderedItems: [...tempUserCart, ...this.USER_CART_ITEMS], billdetails: this.billdetails, userId: this.userDetails?.userId };
5703
- console.log(this.responseData);
5704
- this.restService.addItemToDB(this.responseData).subscribe((response) => {
5705
- localStorage.setItem('cartId', response.data?.cartId);
5706
- });
5707
- };
5733
+ this.storageService.getUserCart().then((cartData) => {
5734
+ // cartResponse.onsuccess = (cartData: any) => {
5735
+ console.log("cart Data", cartData);
5736
+ this.USER_CART_ITEMS = cartData.result;
5737
+ [...this.USER_CART_ITEMS].forEach((item) => {
5738
+ this.cartInfo.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5739
+ this.cartInfo.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5740
+ });
5741
+ this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue + this.cartInfo.billdetails.totalTax - this.cartInfo.billdetails.deliveryCharges;
5742
+ this.cartInfo.orderedItems = this.USER_CART_ITEMS;
5743
+ console.log(this.responseData);
5744
+ this.restService.addItemToDB(this.responseData).subscribe((response) => {
5745
+ localStorage.setItem('cartId', response.data?.cartId);
5746
+ });
5747
+ // }
5708
5748
  });
5709
5749
  }
5710
5750
  });
5711
5751
  }
5712
5752
  else {
5713
- this.storageService.getUserCart().then((cartResponse) => {
5714
- console.log(cartResponse);
5715
- cartResponse.onsuccess = (cartData) => {
5716
- this.USER_CART_ITEMS = cartData.target.result;
5717
- this.USER_CART_ITEMS.forEach((item) => {
5718
- this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5719
- this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5720
- });
5721
- this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
5722
- this.responseData = { cartType: 'CART', orderedItems: this.USER_CART_ITEMS, billdetails: this.billdetails, totalAmount: this.billdetails.totalNetValue, };
5723
- };
5753
+ this.storageService.getUserCart().then((cartData) => {
5754
+ // console.log(cartResponse);
5755
+ // cartResponse.onsuccess = (cartData: any) => {
5756
+ this.USER_CART_ITEMS = cartData.result;
5757
+ this.USER_CART_ITEMS.forEach((item) => {
5758
+ this.cartInfo.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5759
+ this.cartInfo.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5760
+ });
5761
+ this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue + this.cartInfo.billdetails.totalTax - this.cartInfo.billdetails.deliveryCharges;
5762
+ this.cartInfo.orderedItems = this.USER_CART_ITEMS;
5763
+ // }
5724
5764
  });
5725
5765
  // this.responseData = this.storageService.calculateBillingDetails();
5726
5766
  console.log(this.responseData);
@@ -5756,11 +5796,11 @@ class CartComponent extends BaseSection {
5756
5796
  if (this.USER_CART_ITEMS)
5757
5797
  this.USER_CART_ITEMS = this.USER_CART_ITEMS.filter((product) => product.id != item.itemId);
5758
5798
  response?.data?.orderedItems.forEach((item) => {
5759
- this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5760
- this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5799
+ this.cartInfo.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5800
+ this.cartInfo.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5761
5801
  });
5762
- this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
5763
- this.responseData = { cartType: 'CART', orderedItems: this.USER_CART_ITEMS, billdetails: this.billdetails, totalAmount: this.billdetails.totalNetValue, };
5802
+ this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue + this.cartInfo.billdetails.totalTax - this.cartInfo.billdetails.deliveryCharges;
5803
+ this.cartInfo.orderedItems = this.USER_CART_ITEMS;
5764
5804
  });
5765
5805
  }
5766
5806
  addToCart(item, type) {
@@ -5774,11 +5814,11 @@ class CartComponent extends BaseSection {
5774
5814
  this.cartService.addItemFromCartPage(item, this.responseData).subscribe((response) => {
5775
5815
  this.loadingItems = this.loadingItems.filter((idx) => idx != item.itemId);
5776
5816
  response?.data?.orderedItems.forEach((item) => {
5777
- this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5778
- this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5817
+ this.cartInfo.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
5818
+ this.cartInfo.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
5779
5819
  });
5780
- this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
5781
- this.responseData = { cartType: 'CART', orderedItems: this.USER_CART_ITEMS, billdetails: this.billdetails, totalAmount: this.billdetails.totalNetValue, };
5820
+ this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue + this.cartInfo.billdetails.totalTax - this.cartInfo.billdetails.deliveryCharges;
5821
+ this.cartInfo.orderedItems = this.USER_CART_ITEMS;
5782
5822
  });
5783
5823
  }
5784
5824
  proceedToPayment() {