diff --git a/Frontend/src/app/app.module.ts b/Frontend/src/app/app.module.ts index 5635d5f..5da2756 100644 --- a/Frontend/src/app/app.module.ts +++ b/Frontend/src/app/app.module.ts @@ -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, diff --git a/Frontend/src/app/app.routing.ts b/Frontend/src/app/app.routing.ts index 8008c5b..58ddb59 100644 --- a/Frontend/src/app/app.routing.ts +++ b/Frontend/src/app/app.routing.ts @@ -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} ]; diff --git a/Frontend/src/app/components/auth/signin/signin.component.ts b/Frontend/src/app/components/auth/signin/signin.component.ts index e39ac56..dee46ed 100644 --- a/Frontend/src/app/components/auth/signin/signin.component.ts +++ b/Frontend/src/app/components/auth/signin/signin.component.ts @@ -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; diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts index 031dc53..3f5d6d4 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts @@ -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 { diff --git a/Frontend/src/app/pages/landingpage/landingpage.component.ts b/Frontend/src/app/pages/landingpage/landingpage.component.ts index d62ca82..cf3deac 100644 --- a/Frontend/src/app/pages/landingpage/landingpage.component.ts +++ b/Frontend/src/app/pages/landingpage/landingpage.component.ts @@ -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)); } - }