mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2026-05-26 04:28:05 +00:00
WIP: problems with best deals.
This commit is contained in:
@@ -18,7 +18,6 @@ export class SigninComponent implements OnInit {
|
||||
private isSignUpFailed: boolean;
|
||||
private errorMessage: '';
|
||||
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private api: ApiService,
|
||||
@@ -43,10 +42,9 @@ export class SigninComponent implements OnInit {
|
||||
this.api.loginUser(this.loginForm.value.username, this.loginForm.value.password)
|
||||
.subscribe(
|
||||
data => {
|
||||
this.router.navigate(['']);
|
||||
this.isSuccessful = true;
|
||||
this.isSignUpFailed = false;
|
||||
this.api.saveSessionInfoToLocalStorage(data);
|
||||
this.router.navigate(['']);
|
||||
},
|
||||
err => {
|
||||
this.errorMessage = err.error.message;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {ActivatedRoute, Router} from '@angular/router';
|
||||
export class HotDealsWidgetComponent implements OnInit {
|
||||
|
||||
products: Product[] = [];
|
||||
bestDealsProductIds = [];
|
||||
@Input() numberOfProducts: number;
|
||||
@Input() showProductPicture: boolean;
|
||||
@Input() searchQuery: string;
|
||||
@@ -24,12 +25,14 @@ export class HotDealsWidgetComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
this.loadParams();
|
||||
this.getBestDeals();
|
||||
}
|
||||
|
||||
loadParams(): void {
|
||||
if (!this.numberOfProducts) {
|
||||
this.numberOfProducts = 10;
|
||||
this.numberOfProducts = 9;
|
||||
}
|
||||
if (!this.showProductPicture) {
|
||||
this.showProductPicture = false;
|
||||
@@ -47,14 +50,27 @@ export class HotDealsWidgetComponent implements OnInit {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.getProducts();
|
||||
this.getProductsByIds();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getProducts(): void {
|
||||
this.apiService.getProducts().subscribe(products => this.products = products);
|
||||
getProductsByIds(): void {
|
||||
this.apiService.getProductsByIds(this.bestDealsProductIds).subscribe(
|
||||
products => this.products = products
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
getBestDeals(): void {
|
||||
this.apiService.getBestDeals(9).subscribe(
|
||||
deals => {
|
||||
deals.forEach(deal => {
|
||||
this.bestDealsProductIds.push(deal.product_id);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getSearchedProducts(): void {
|
||||
|
||||
Reference in New Issue
Block a user