simpo-component-library 1.4.54 → 1.4.57
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/esm2022/lib/ecommerce/sections/cart/cart.component.mjs +62 -31
- package/esm2022/lib/ecommerce/sections/featured-products/featured-products.component.mjs +7 -3
- package/esm2022/lib/services/cart.service.mjs +4 -4
- package/fesm2022/simpo-component-library.mjs +70 -35
- package/fesm2022/simpo-component-library.mjs.map +1 -1
- package/lib/ecommerce/sections/cart/cart.component.d.ts +1 -0
- package/lib/services/cart.service.d.ts +1 -1
- package/package.json +1 -1
- package/simpo-component-library-1.4.57.tgz +0 -0
- package/simpo-component-library-1.4.47.tgz +0 -0
- package/simpo-component-library-1.4.48.tgz +0 -0
- package/simpo-component-library-1.4.49.tgz +0 -0
- package/simpo-component-library-1.4.50.tgz +0 -0
- package/simpo-component-library-1.4.51.tgz +0 -0
- package/simpo-component-library-1.4.52.tgz +0 -0
- package/simpo-component-library-1.4.53.tgz +0 -0
- package/simpo-component-library-1.4.54.tgz +0 -0
|
@@ -4811,7 +4811,7 @@ class CartService {
|
|
|
4811
4811
|
this.storageService = storageService;
|
|
4812
4812
|
this.restService = restService;
|
|
4813
4813
|
}
|
|
4814
|
-
addItemFromCartPage(product) {
|
|
4814
|
+
addItemFromCartPage(product, userCart) {
|
|
4815
4815
|
if (product.quantity) {
|
|
4816
4816
|
// let productIdx: number = -1;
|
|
4817
4817
|
// UserCart.orderedItems.forEach((item: OrderedItems, idx)=> {
|
|
@@ -4819,12 +4819,12 @@ class CartService {
|
|
|
4819
4819
|
// productIdx = idx;
|
|
4820
4820
|
// });
|
|
4821
4821
|
this.storageService.addProductToCart(product);
|
|
4822
|
-
|
|
4822
|
+
return this.restService.addItemToDB(userCart);
|
|
4823
4823
|
}
|
|
4824
4824
|
else {
|
|
4825
4825
|
// remove item from cart
|
|
4826
4826
|
this.removeItemFromCart(product);
|
|
4827
|
-
|
|
4827
|
+
return this.restService.addItemToDB(userCart);
|
|
4828
4828
|
}
|
|
4829
4829
|
}
|
|
4830
4830
|
addItemToCart(product) {
|
|
@@ -4980,10 +4980,14 @@ class FeaturedProductsComponent extends BaseSection {
|
|
|
4980
4980
|
this.cartService.addItemToCart(product);
|
|
4981
4981
|
}
|
|
4982
4982
|
toggleItemToFav(product, type) {
|
|
4983
|
-
if (type == 'ADD')
|
|
4983
|
+
if (type == 'ADD') {
|
|
4984
|
+
product.whislist = true;
|
|
4984
4985
|
this.cartService.addItemToFavourite(product);
|
|
4985
|
-
|
|
4986
|
+
}
|
|
4987
|
+
else {
|
|
4988
|
+
product.whislist = false;
|
|
4986
4989
|
this.cartService.removeItemFromFavourite(product);
|
|
4990
|
+
}
|
|
4987
4991
|
}
|
|
4988
4992
|
proceedToProductDesc(productId) {
|
|
4989
4993
|
this.router.navigate([`details`], { queryParams: { id: productId } });
|
|
@@ -5659,15 +5663,15 @@ class CartComponent extends BaseSection {
|
|
|
5659
5663
|
this.userDetails = null;
|
|
5660
5664
|
this.userCart = null;
|
|
5661
5665
|
this.USER_CART_ITEMS = null;
|
|
5662
|
-
|
|
5663
|
-
ngOnInit() {
|
|
5664
|
-
const billdetails = {
|
|
5666
|
+
this.billdetails = {
|
|
5665
5667
|
"totalNetValue": 0,
|
|
5666
5668
|
"totalGrossValue": 0,
|
|
5667
5669
|
"totalTax": 0,
|
|
5668
5670
|
"totalOfferedValue": 0,
|
|
5669
5671
|
"deliveryCharges": 0
|
|
5670
5672
|
};
|
|
5673
|
+
}
|
|
5674
|
+
ngOnInit() {
|
|
5671
5675
|
this._eventService.showLoadingScreen.subscribe((response) => {
|
|
5672
5676
|
this.isLoading = response;
|
|
5673
5677
|
});
|
|
@@ -5675,21 +5679,41 @@ class CartComponent extends BaseSection {
|
|
|
5675
5679
|
this.userDetails = this.storageService.getUser();
|
|
5676
5680
|
this.restService.getUserItems(this.userDetails.userId, "CART").subscribe((response) => {
|
|
5677
5681
|
const tempUserCart = response?.data?.orderedItems ?? [];
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5682
|
+
if (response.data) {
|
|
5683
|
+
localStorage.setItem('cartId', response.data?.cartId);
|
|
5684
|
+
console.log(tempUserCart);
|
|
5685
|
+
this.storageService.getUserCart().then((cartResponse) => {
|
|
5686
|
+
cartResponse.onsuccess = (cartData) => {
|
|
5687
|
+
console.log("cart Data", cartData);
|
|
5688
|
+
this.USER_CART_ITEMS = cartData.target.result;
|
|
5689
|
+
[...tempUserCart, ...this.USER_CART_ITEMS].forEach((item) => {
|
|
5690
|
+
this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
|
|
5691
|
+
this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
|
|
5692
|
+
});
|
|
5693
|
+
this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
|
|
5694
|
+
this.responseData = { orderedItems: [...tempUserCart, ...this.USER_CART_ITEMS], billdetails: this.billdetails };
|
|
5695
|
+
console.log(this.responseData);
|
|
5696
|
+
};
|
|
5697
|
+
});
|
|
5698
|
+
}
|
|
5699
|
+
else {
|
|
5700
|
+
this.storageService.getUserCart().then((cartResponse) => {
|
|
5701
|
+
cartResponse.onsuccess = (cartData) => {
|
|
5702
|
+
console.log("cart Data", cartData);
|
|
5703
|
+
this.USER_CART_ITEMS = cartData.target.result;
|
|
5704
|
+
[...this.USER_CART_ITEMS].forEach((item) => {
|
|
5705
|
+
this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
|
|
5706
|
+
this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
|
|
5707
|
+
});
|
|
5708
|
+
this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
|
|
5709
|
+
this.responseData = { orderedItems: [...tempUserCart, ...this.USER_CART_ITEMS], billdetails: this.billdetails, userId: this.userDetails?.userId };
|
|
5710
|
+
console.log(this.responseData);
|
|
5711
|
+
this.restService.addItemToDB(this.responseData).subscribe((response) => {
|
|
5712
|
+
localStorage.setItem('cartId', response.data?.cartId);
|
|
5713
|
+
});
|
|
5714
|
+
};
|
|
5715
|
+
});
|
|
5716
|
+
}
|
|
5693
5717
|
});
|
|
5694
5718
|
}
|
|
5695
5719
|
else {
|
|
@@ -5698,11 +5722,11 @@ class CartComponent extends BaseSection {
|
|
|
5698
5722
|
cartResponse.onsuccess = (cartData) => {
|
|
5699
5723
|
this.USER_CART_ITEMS = cartData.target.result;
|
|
5700
5724
|
this.USER_CART_ITEMS.forEach((item) => {
|
|
5701
|
-
billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
|
|
5702
|
-
billdetails.totalTax += (item.price * (item.itemTax ?? 1));
|
|
5725
|
+
this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
|
|
5726
|
+
this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
|
|
5703
5727
|
});
|
|
5704
|
-
billdetails.totalNetValue = billdetails.totalGrossValue + billdetails.totalTax - billdetails.deliveryCharges;
|
|
5705
|
-
this.responseData = { orderedItems: this.USER_CART_ITEMS, billdetails };
|
|
5728
|
+
this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
|
|
5729
|
+
this.responseData = { orderedItems: this.USER_CART_ITEMS, billdetails: this.billdetails };
|
|
5706
5730
|
};
|
|
5707
5731
|
});
|
|
5708
5732
|
// this.responseData = this.storageService.calculateBillingDetails();
|
|
@@ -5733,10 +5757,16 @@ class CartComponent extends BaseSection {
|
|
|
5733
5757
|
removeItem(item) {
|
|
5734
5758
|
item.quantity = 0;
|
|
5735
5759
|
this.loadingItems.push(item.itemId);
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5760
|
+
this.cartService.addItemFromCartPage(item, this.responseData).subscribe((response) => {
|
|
5761
|
+
this.loadingItems = this.loadingItems.filter((idx) => idx != item.itemId);
|
|
5762
|
+
// this.responseData = this.storageService.calculateBillingDetails();
|
|
5763
|
+
response?.data?.orderedItems.forEach((item) => {
|
|
5764
|
+
this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
|
|
5765
|
+
this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
|
|
5766
|
+
});
|
|
5767
|
+
this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
|
|
5768
|
+
this.responseData = { orderedItems: this.USER_CART_ITEMS, billdetails: this.billdetails };
|
|
5769
|
+
});
|
|
5740
5770
|
}
|
|
5741
5771
|
addToCart(item, type) {
|
|
5742
5772
|
if (type == 'ADD') {
|
|
@@ -5746,10 +5776,15 @@ class CartComponent extends BaseSection {
|
|
|
5746
5776
|
item.quantity -= 1;
|
|
5747
5777
|
}
|
|
5748
5778
|
this.loadingItems.push(item.itemId);
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5779
|
+
this.cartService.addItemFromCartPage(item, this.responseData).subscribe((response) => {
|
|
5780
|
+
this.loadingItems = this.loadingItems.filter((idx) => idx != item.itemId);
|
|
5781
|
+
response?.data?.orderedItems.forEach((item) => {
|
|
5782
|
+
this.billdetails.totalGrossValue += (item.price * (item.quantity ?? 1));
|
|
5783
|
+
this.billdetails.totalTax += (item.price * (item.itemTax ?? 1));
|
|
5784
|
+
});
|
|
5785
|
+
this.billdetails.totalNetValue = this.billdetails.totalGrossValue + this.billdetails.totalTax - this.billdetails.deliveryCharges;
|
|
5786
|
+
this.responseData = { orderedItems: this.USER_CART_ITEMS, billdetails: this.billdetails };
|
|
5787
|
+
});
|
|
5753
5788
|
}
|
|
5754
5789
|
proceedToPayment() {
|
|
5755
5790
|
if (!this.storageService.getUser()) {
|