-
-
Rs.{{ product()?.actualPrice }}
-
Rs.{{ product()?.listPrice }}
-
+
+
+ Rs.{{ product()?.listPrice }}
+
+
Rs.{{ product()?.actualPrice }}
-
-
-
-
-
-
-
+
diff --git a/src/app/features/product/show-product/show-product.ts b/src/app/features/product/show-product/show-product.ts
index 881afb8..c923c86 100644
--- a/src/app/features/product/show-product/show-product.ts
+++ b/src/app/features/product/show-product/show-product.ts
@@ -3,6 +3,7 @@ import { ProductModel } from "../../../core/models/product.model";
import { ProductService } from "../services/product-service";
import { LucideAngularModule, Heart, ArrowRight, ArrowLeft } from "lucide-angular";
import { FavoriteButton } from "../../../shared/components/favorite-button/favorite-button";
+import { CartService } from "@app/core/services/cart-service";
@Component({
selector: "app-show-product",
@@ -17,6 +18,7 @@ export class ShowProduct {
ArrowRightIcon = ArrowRight;
ArrowLeftIcon = ArrowLeft;
productService = inject(ProductService);
+ cartService = inject(CartService);
product = signal
(null);
activeImageIndex: WritableSignal = signal(0);
totalImageCount: number = 0;
@@ -29,9 +31,14 @@ export class ShowProduct {
});
}
+ addToCart() {
+ this.cartService.addToCart({ productId: this.product()!.id, quantity: 1 }).subscribe();
+ }
+
nextImage() {
this.activeImageIndex.update((index) => (index + 1) % this.totalImageCount);
}
+
prevImage() {
this.activeImageIndex.update(
(index) =>
diff --git a/src/app/shared/components/cart/cart.ts b/src/app/shared/components/cart/cart.ts
index 7286b4f..121b0ef 100644
--- a/src/app/shared/components/cart/cart.ts
+++ b/src/app/shared/components/cart/cart.ts
@@ -26,9 +26,7 @@ export class Cart {
this.cartService
.updateCart(cartItem)
.pipe(finalize(() => this.isLoading.set(false)))
- .subscribe((cartdata) => {
- this.cart = cartdata;
- });
+ .subscribe();
}
removeProduct(productId: number) {
@@ -37,8 +35,6 @@ export class Cart {
this.cartService
.removeFromCart(productId)
.pipe(finalize(() => this.isLoading.set(false)))
- .subscribe((cartData) => {
- this.cart = cartData;
- });
+ .subscribe();
}
}