simpo-component-library 1.9.1 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/lib/ecommerce/sections/cart/cart.component.mjs +43 -10
- package/fesm2022/simpo-component-library.mjs +42 -9
- package/fesm2022/simpo-component-library.mjs.map +1 -1
- package/lib/directive/background-directive.d.ts +1 -1
- package/lib/directive/button-directive.directive.d.ts +1 -1
- package/lib/directive/color.directive.d.ts +1 -1
- package/lib/ecommerce/sections/cart/cart.component.d.ts +6 -2
- package/lib/sections/pricing-section/pricing-section.component.d.ts +1 -1
- package/package.json +1 -1
- package/simpo-component-library-1.9.3.tgz +0 -0
- package/simpo-component-library-1.9.1.tgz +0 -0
@@ -4586,22 +4586,24 @@ class CartComponent extends BaseSection {
|
|
4586
4586
|
this.couponDialogRef = null;
|
4587
4587
|
}
|
4588
4588
|
ngOnInit() {
|
4589
|
-
this._eventService.showLoadingScreen.subscribe((response) => {
|
4589
|
+
this.loadingSubscription = this._eventService.showLoadingScreen.subscribe((response) => {
|
4590
4590
|
this.isLoading = response;
|
4591
4591
|
if (!this.isLoading) {
|
4592
4592
|
this.getIndexDBData();
|
4593
4593
|
}
|
4594
4594
|
});
|
4595
|
-
if (this.storageService.getUser()) {
|
4596
|
-
|
4597
|
-
}
|
4598
|
-
|
4599
|
-
|
4600
|
-
|
4601
|
-
}
|
4595
|
+
// if (this.storageService.getUser()) {
|
4596
|
+
// this.updateUserCart();
|
4597
|
+
// } else {
|
4598
|
+
// this.getIndexDBData();
|
4599
|
+
// console.log(this.responseData);
|
4600
|
+
// }
|
4602
4601
|
console.log(this.responseData);
|
4603
4602
|
this.styles = this.data?.styles;
|
4604
4603
|
}
|
4604
|
+
ngOnDestroy() {
|
4605
|
+
this.loadingSubscription?.unsubscribe();
|
4606
|
+
}
|
4605
4607
|
updateUserCart() {
|
4606
4608
|
const deliveryOption = JSON.parse(localStorage.getItem("deliveryOptions") ?? "{}");
|
4607
4609
|
this.userDetails = this.storageService.getUser();
|
@@ -4617,7 +4619,8 @@ class CartComponent extends BaseSection {
|
|
4617
4619
|
this.cartInfo["cartId"] = response.data?.[0]?.cartId;
|
4618
4620
|
this.getCouponList();
|
4619
4621
|
if (response.data?.[0]?.orderedItems?.length > 0) {
|
4620
|
-
this.
|
4622
|
+
this.mergeOrderItems(tempUserCart);
|
4623
|
+
this.storageService.addAllProductsToCart(this.cartInfo.orderedItems).oncomplete = () => {
|
4621
4624
|
this.storageService.getUserCart().then((cartResponse) => {
|
4622
4625
|
cartResponse.onsuccess = (cartData) => {
|
4623
4626
|
if (!(localStorage.getItem("couponId") == "undefined" || localStorage.getItem("couponId") == "null"))
|
@@ -4683,6 +4686,34 @@ class CartComponent extends BaseSection {
|
|
4683
4686
|
}
|
4684
4687
|
});
|
4685
4688
|
}
|
4689
|
+
// updateUserCart2() {
|
4690
|
+
// const deliveryOption = JSON.parse(localStorage.getItem("deliveryOptions") ?? "{}");
|
4691
|
+
// this.userDetails = this.storageService.getUser() as User;
|
4692
|
+
// this.cartInfo.userDetails = {
|
4693
|
+
// "userId": this.userDetails?.userId,
|
4694
|
+
// "userName": this.userDetails?.contact.name,
|
4695
|
+
// "mobile": this.userDetails?.contact.mobile,
|
4696
|
+
// "email": this.userDetails?.contact.email,
|
4697
|
+
// }
|
4698
|
+
// this.restService.getUserItems(this.userDetails.userId, "CART").subscribe((response: any) => {
|
4699
|
+
// const tempUserCart = response?.data?.[0]?.orderedItems ?? [];
|
4700
|
+
// this.mergeOrderItems(tempUserCart);
|
4701
|
+
// })
|
4702
|
+
// }
|
4703
|
+
mergeOrderItems(syncedItems) {
|
4704
|
+
for (let product of syncedItems) {
|
4705
|
+
let itemFound = false;
|
4706
|
+
for (let cartItem of this.cartInfo.orderedItems) {
|
4707
|
+
if (cartItem.varientId === product.varientId) {
|
4708
|
+
itemFound = true;
|
4709
|
+
cartItem.quantity += product.quantity;
|
4710
|
+
}
|
4711
|
+
}
|
4712
|
+
if (!itemFound) {
|
4713
|
+
this.cartInfo.orderedItems.push(product);
|
4714
|
+
}
|
4715
|
+
}
|
4716
|
+
}
|
4686
4717
|
getCouponList() {
|
4687
4718
|
if (!this.cartInfo.cartId && !(localStorage.getItem("cartId") == "undefined" || localStorage.getItem("cartId") == "null"))
|
4688
4719
|
this.cartInfo.cartId = localStorage.getItem("cartId");
|
@@ -4737,6 +4768,8 @@ class CartComponent extends BaseSection {
|
|
4737
4768
|
console.log(this.cartInfo.billdetails.totalNetValue, this.cartInfo.billdetails.totalTax, this.cartInfo.billdetails.deliveryCharges);
|
4738
4769
|
this.cartInfo.totalAmount = this.cartInfo.billdetails.totalNetValue + this.getTaxAmount() + this.cartInfo.billdetails.deliveryCharges;
|
4739
4770
|
this.cartInfo.orderedItems = this.USER_CART_ITEMS;
|
4771
|
+
if (this.storageService.getUser())
|
4772
|
+
this.updateUserCart();
|
4740
4773
|
this.responseData = this.cartInfo;
|
4741
4774
|
};
|
4742
4775
|
});
|