mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-22 14:23:57 +00:00
wip: profile
This commit is contained in:
parent
012de346e8
commit
a6a5b58e25
|
@ -23,8 +23,12 @@
|
||||||
{{product?.short_description}}
|
{{product?.short_description}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="priceAlarm" (click)="setPriceAlarm()">
|
<div class="priceAlarm" *ngIf="!isLoggedIn" routerLink="/signin">
|
||||||
Set Price Alarm
|
Login to set a price alarm
|
||||||
|
</div>
|
||||||
|
<div class="priceAlarm" *ngIf="isLoggedIn">
|
||||||
|
<input type="search" id="s" name="price" [(ngModel)]="price">
|
||||||
|
<div (click)="setPriceAlarm()">Set Price Alarm</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bestPriceContainer">
|
<div class="bestPriceContainer">
|
||||||
<div class="bestPrice">
|
<div class="bestPrice">
|
||||||
|
|
|
@ -34,6 +34,8 @@ export class ProductDetailsComponent implements OnInit {
|
||||||
vendorMap = {};
|
vendorMap = {};
|
||||||
@ViewChild('chart') chart: ChartComponent;
|
@ViewChild('chart') chart: ChartComponent;
|
||||||
public chartOptions: ChartOptions;
|
public chartOptions: ChartOptions;
|
||||||
|
isLoggedIn: boolean;
|
||||||
|
price: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService
|
private apiService: ApiService
|
||||||
|
@ -44,6 +46,9 @@ export class ProductDetailsComponent implements OnInit {
|
||||||
this.getProduct();
|
this.getProduct();
|
||||||
this.getVendors();
|
this.getVendors();
|
||||||
this.getPrices();
|
this.getPrices();
|
||||||
|
if (this.apiService.getSessionInfoFromLocalStorage().session_id != "") {
|
||||||
|
this.isLoggedIn = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getProduct(): void {
|
getProduct(): void {
|
||||||
|
@ -119,8 +124,10 @@ export class ProductDetailsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
setPriceAlarm() {
|
setPriceAlarm() {
|
||||||
this.apiService.createPriceAlarms(this.productId, 9).subscribe(
|
this.apiService.createPriceAlarms(this.productId, this.price*100).subscribe(
|
||||||
alarms => console.log(alarms)
|
alarms => console.log(alarms)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="align-items-center align-content-center col-md-3 border-left mt-1">
|
<div class="align-items-center align-content-center col-md-3 border-left mt-1">
|
||||||
<div class="d-flex flex-row align-items-center">
|
<div class="d-flex flex-row align-items-center">
|
||||||
<h4 class="mr-1">${{product.price}}</h4>
|
<h4 class="mr-1">${{pricesMap[product.product_id]?.price_in_cents/100}}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex flex-column mt-4"><button class="btn btn-primary btn-sm" type="button" (click)="clickedProduct(product)">Details</button>
|
<div class="d-flex flex-column mt-4"><button class="btn btn-primary btn-sm" type="button" (click)="clickedProduct(product)">Details</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {ActivatedRoute, Router} from '@angular/router';
|
||||||
})
|
})
|
||||||
export class ProductListComponent implements OnInit {
|
export class ProductListComponent implements OnInit {
|
||||||
products: Product[] = [];
|
products: Product[] = [];
|
||||||
|
pricesMap: any = {};
|
||||||
@Input() numberOfProducts: number;
|
@Input() numberOfProducts: number;
|
||||||
@Input() showProductPicture: boolean;
|
@Input() showProductPicture: boolean;
|
||||||
@Input() searchQuery: string;
|
@Input() searchQuery: string;
|
||||||
|
@ -53,9 +54,27 @@ export class ProductListComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
getProducts(): void {
|
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 {
|
getSearchedProducts(): void {
|
||||||
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products);
|
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)]);
|
this.router.navigate([('/product/' + product.product_id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Produkt</th>
|
<th>Produkt</th>
|
||||||
<th>Preis</th>
|
<th>Preis</th>
|
||||||
|
<th>Ändern</th>
|
||||||
<th>Löschen</th>
|
<th>Löschen</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr *ngFor="let alarm of alarms">
|
<tr *ngFor="let alarm of alarms">
|
||||||
|
@ -88,7 +89,10 @@
|
||||||
{{alarm.defined_price/100}}
|
{{alarm.defined_price/100}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<img class="delete" src="../assets/images/Delete_icon-icons.com_55931.png" (click)="delete()">
|
<img class="delete" src="../assets/images/Delete_icon-icons.com_55931.png" (click)="delete(alarm.alarm_id)">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<img class="delete" src="../assets/images/Delete_icon-icons.com_55931.png" (click)="delete(alarm.alarm_id)">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -50,7 +50,9 @@ export class ProfileComponent implements OnInit {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete() {
|
delete(id:number): void {
|
||||||
|
this.api.deletePriceAlarm(id).subscribe(
|
||||||
|
res => window.location.reload()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user