mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-14 02:23:58 +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 { GreetingInfoSliderComponent } from './components/greeting-info-slider/greeting-info-slider.component';
|
||||||
import { KundenComponent } from './components/kunden/kunden.component';
|
import { KundenComponent } from './components/kunden/kunden.component';
|
||||||
import { AboutUsComponent } from './components/about-us/about-us.component';
|
import { AboutUsComponent } from './components/about-us/about-us.component';
|
||||||
|
import { ProfileComponent } from './components/profile/profile.component';
|
||||||
|
|
||||||
// For cookie popup
|
// For cookie popup
|
||||||
const cookieConfig: NgcCookieConsentConfig = {
|
const cookieConfig: NgcCookieConsentConfig = {
|
||||||
|
@ -102,6 +103,7 @@ const cookieConfig: NgcCookieConsentConfig = {
|
||||||
GreetingInfoSliderComponent,
|
GreetingInfoSliderComponent,
|
||||||
KundenComponent,
|
KundenComponent,
|
||||||
AboutUsComponent,
|
AboutUsComponent,
|
||||||
|
ProfileComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {ImprintComponent} from './pages/imprint/imprint.component';
|
||||||
import {PrivacyComponent} from './pages/privacy/privacy.component';
|
import {PrivacyComponent} from './pages/privacy/privacy.component';
|
||||||
import {SigninComponent} from "./components/auth/signin/signin.component";
|
import {SigninComponent} from "./components/auth/signin/signin.component";
|
||||||
import {RegistrationComponent} from "./components/auth/registration/registration.component";
|
import {RegistrationComponent} from "./components/auth/registration/registration.component";
|
||||||
|
import {ProfileComponent} from "./components/profile/profile.component";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{path: '', component: LandingpageComponent, pathMatch: 'full'},
|
{path: '', component: LandingpageComponent, pathMatch: 'full'},
|
||||||
|
@ -21,6 +22,7 @@ const routes: Routes = [
|
||||||
{path: 'signin', component: SigninComponent},
|
{path: 'signin', component: SigninComponent},
|
||||||
{path: 'registration', component: RegistrationComponent},
|
{path: 'registration', component: RegistrationComponent},
|
||||||
{path: "product-detail", component: ProductDetailPageComponent},
|
{path: "product-detail", component: ProductDetailPageComponent},
|
||||||
|
{path: "profile", component: ProfileComponent},
|
||||||
{path: '**', component: PageNotFoundPageComponent}
|
{path: '**', component: PageNotFoundPageComponent}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ export class SigninComponent implements OnInit {
|
||||||
private isSignUpFailed: boolean;
|
private isSignUpFailed: boolean;
|
||||||
private errorMessage: '';
|
private errorMessage: '';
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private api: ApiService,
|
private api: ApiService,
|
||||||
|
@ -43,10 +42,9 @@ export class SigninComponent implements OnInit {
|
||||||
this.api.loginUser(this.loginForm.value.username, this.loginForm.value.password)
|
this.api.loginUser(this.loginForm.value.username, this.loginForm.value.password)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.router.navigate(['']);
|
|
||||||
this.isSuccessful = true;
|
this.isSuccessful = true;
|
||||||
this.isSignUpFailed = false;
|
this.isSignUpFailed = false;
|
||||||
this.api.saveSessionInfoToLocalStorage(data);
|
this.router.navigate(['']);
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
this.errorMessage = err.error.message;
|
this.errorMessage = err.error.message;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {ActivatedRoute, Router} from '@angular/router';
|
||||||
export class HotDealsWidgetComponent implements OnInit {
|
export class HotDealsWidgetComponent implements OnInit {
|
||||||
|
|
||||||
products: Product[] = [];
|
products: Product[] = [];
|
||||||
|
bestDealsProductIds = [];
|
||||||
@Input() numberOfProducts: number;
|
@Input() numberOfProducts: number;
|
||||||
@Input() showProductPicture: boolean;
|
@Input() showProductPicture: boolean;
|
||||||
@Input() searchQuery: string;
|
@Input() searchQuery: string;
|
||||||
|
@ -24,12 +25,14 @@ export class HotDealsWidgetComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.loadParams();
|
this.loadParams();
|
||||||
|
this.getBestDeals();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadParams(): void {
|
loadParams(): void {
|
||||||
if (!this.numberOfProducts) {
|
if (!this.numberOfProducts) {
|
||||||
this.numberOfProducts = 10;
|
this.numberOfProducts = 9;
|
||||||
}
|
}
|
||||||
if (!this.showProductPicture) {
|
if (!this.showProductPicture) {
|
||||||
this.showProductPicture = false;
|
this.showProductPicture = false;
|
||||||
|
@ -47,14 +50,27 @@ export class HotDealsWidgetComponent implements OnInit {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
this.getProducts();
|
this.getProductsByIds();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getProducts(): void {
|
getProductsByIds(): void {
|
||||||
this.apiService.getProducts().subscribe(products => this.products = products);
|
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 {
|
getSearchedProducts(): void {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
|
import {ApiService} from "../../services/api.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-landingpage',
|
selector: 'app-landingpage',
|
||||||
|
@ -8,13 +9,16 @@ import {Router} from '@angular/router';
|
||||||
})
|
})
|
||||||
export class LandingpageComponent implements OnInit {
|
export class LandingpageComponent implements OnInit {
|
||||||
searchInput: string;
|
searchInput: string;
|
||||||
|
isLoggedIn = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router
|
private router: Router,
|
||||||
|
private api: ApiService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startedSearch(): void {
|
startedSearch(): void {
|
||||||
|
@ -25,5 +29,4 @@ export class LandingpageComponent implements OnInit {
|
||||||
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() =>
|
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() =>
|
||||||
this.router.navigate([uri], queryParams));
|
this.router.navigate([uri], queryParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user