diff --git a/Frontend/src/app/components/product-details/product-details.component.ts b/Frontend/src/app/components/product-details/product-details.component.ts
index 1ccae5a..e7588c2 100644
--- a/Frontend/src/app/components/product-details/product-details.component.ts
+++ b/Frontend/src/app/components/product-details/product-details.component.ts
@@ -34,6 +34,8 @@ export class ProductDetailsComponent implements OnInit {
vendorMap = {};
@ViewChild('chart') chart: ChartComponent;
public chartOptions: ChartOptions;
+ isLoggedIn: boolean;
+ price: any;
constructor(
private apiService: ApiService
@@ -44,6 +46,9 @@ export class ProductDetailsComponent implements OnInit {
this.getProduct();
this.getVendors();
this.getPrices();
+ if (this.apiService.getSessionInfoFromLocalStorage().session_id != "") {
+ this.isLoggedIn = true;
+ }
}
getProduct(): void {
@@ -119,8 +124,10 @@ export class ProductDetailsComponent implements OnInit {
}
setPriceAlarm() {
- this.apiService.createPriceAlarms(this.productId, 9).subscribe(
+ this.apiService.createPriceAlarms(this.productId, this.price*100).subscribe(
alarms => console.log(alarms)
)
}
+
+
}
diff --git a/Frontend/src/app/components/product-list/product-list.component.html b/Frontend/src/app/components/product-list/product-list.component.html
index f5186c8..5c26ab9 100644
--- a/Frontend/src/app/components/product-list/product-list.component.html
+++ b/Frontend/src/app/components/product-list/product-list.component.html
@@ -16,7 +16,7 @@
-
${{product.price}}
+ ${{pricesMap[product.product_id]?.price_in_cents/100}}
diff --git a/Frontend/src/app/components/product-list/product-list.component.ts b/Frontend/src/app/components/product-list/product-list.component.ts
index 94bab8a..5fe6432 100644
--- a/Frontend/src/app/components/product-list/product-list.component.ts
+++ b/Frontend/src/app/components/product-list/product-list.component.ts
@@ -10,6 +10,7 @@ import {ActivatedRoute, Router} from '@angular/router';
})
export class ProductListComponent implements OnInit {
products: Product[] = [];
+ pricesMap: any = {};
@Input() numberOfProducts: number;
@Input() showProductPicture: boolean;
@Input() searchQuery: string;
@@ -53,9 +54,27 @@ export class ProductListComponent implements OnInit {
}
getProducts(): void {
- this.apiService.getProducts().subscribe(products => this.products = products);
+ this.apiService.getProducts().subscribe(products => {
+ this.products = products;
+ this.getPrices();
+ });
}
+ getPrices(): void {
+ const productIds: number[] = [];
+ this.products.forEach(
+ product => productIds.push(product.product_id)
+ )
+ this.apiService.getProductsByIds(productIds).subscribe(
+ prices => {
+ prices.forEach(price => {
+ this.pricesMap[price.product_id] = price;
+ })
+ }
+ )
+ }
+
+
getSearchedProducts(): void {
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products);
}
@@ -64,4 +83,5 @@ export class ProductListComponent implements OnInit {
this.router.navigate([('/product/' + product.product_id)]);
}
+
}
diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html
index 9c9f0a6..4d94c9f 100644
--- a/Frontend/src/app/components/profile/profile.component.html
+++ b/Frontend/src/app/components/profile/profile.component.html
@@ -78,6 +78,7 @@
Produkt |
Preis |
+ Ändern |
Löschen |
@@ -88,7 +89,10 @@
{{alarm.defined_price/100}}
-
+
+ |
+
+
|
diff --git a/Frontend/src/app/components/profile/profile.component.ts b/Frontend/src/app/components/profile/profile.component.ts
index 02eb9af..4e9402a 100644
--- a/Frontend/src/app/components/profile/profile.component.ts
+++ b/Frontend/src/app/components/profile/profile.component.ts
@@ -50,7 +50,9 @@ export class ProfileComponent implements OnInit {
)
}
- delete() {
-
+ delete(id:number): void {
+ this.api.deletePriceAlarm(id).subscribe(
+ res => window.location.reload()
+ )
}
}