mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-12-22 19:55:12 +00:00
WIP: problems with best deals.
This commit is contained in:
parent
8eba80f7d4
commit
c88efc5484
|
@ -38,6 +38,7 @@ import { CopyrightComponent } from './components/copyright/copyright.component';
|
|||
import { GreetingInfoSliderComponent } from './components/greeting-info-slider/greeting-info-slider.component';
|
||||
import { KundenComponent } from './components/kunden/kunden.component';
|
||||
import { AboutUsComponent } from './components/about-us/about-us.component';
|
||||
import { ProfileComponent } from './components/profile/profile.component';
|
||||
|
||||
// For cookie popup
|
||||
const cookieConfig: NgcCookieConsentConfig = {
|
||||
|
@ -102,6 +103,7 @@ const cookieConfig: NgcCookieConsentConfig = {
|
|||
GreetingInfoSliderComponent,
|
||||
KundenComponent,
|
||||
AboutUsComponent,
|
||||
ProfileComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
|
|
@ -11,6 +11,7 @@ import {ImprintComponent} from './pages/imprint/imprint.component';
|
|||
import {PrivacyComponent} from './pages/privacy/privacy.component';
|
||||
import {SigninComponent} from "./components/auth/signin/signin.component";
|
||||
import {RegistrationComponent} from "./components/auth/registration/registration.component";
|
||||
import {ProfileComponent} from "./components/profile/profile.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{path: '', component: LandingpageComponent, pathMatch: 'full'},
|
||||
|
@ -21,6 +22,7 @@ const routes: Routes = [
|
|||
{path: 'signin', component: SigninComponent},
|
||||
{path: 'registration', component: RegistrationComponent},
|
||||
{path: "product-detail", component: ProductDetailPageComponent},
|
||||
{path: "profile", component: ProfileComponent},
|
||||
{path: '**', component: PageNotFoundPageComponent}
|
||||
];
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {Component, OnInit} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {ApiService} from "../../services/api.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-landingpage',
|
||||
|
@ -8,13 +9,16 @@ import {Router} from '@angular/router';
|
|||
})
|
||||
export class LandingpageComponent implements OnInit {
|
||||
searchInput: string;
|
||||
isLoggedIn = false;
|
||||
|
||||
constructor(
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private api: ApiService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
}
|
||||
|
||||
startedSearch(): void {
|
||||
|
@ -25,5 +29,4 @@ export class LandingpageComponent implements OnInit {
|
|||
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() =>
|
||||
this.router.navigate([uri], queryParams));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user