Compare commits

...

6 Commits

11 changed files with 126 additions and 18 deletions

View File

@ -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,

View File

@ -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}
]; ];

View File

@ -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;

View File

@ -9,18 +9,18 @@
<!-- Portfolio Grid Items--> <!-- Portfolio Grid Items-->
<div class="row justify-content-center"> <div class="row justify-content-center">
<!-- Portfolio Item 1--> <!-- Portfolio Item 1-->
<div class="col-md-4 mx-auto my-5" *ngFor="let product of products" (click)="clickedProduct(product)"> <div class="col-md-4 mx-auto my-5" *ngFor="let productId of bestDealsProductIds" (click)="clickedProduct(productId)">
<div class="bbb_deals_wrapper"> <div class="bbb_deals_wrapper">
<div class="bbb_deals_image"><img src="https://www.mueller-patrick.tech/betterzon/images/{{product.image_guid}}.jpg" alt=""></div> <div class="bbb_deals_image"><img src="https://www.mueller-patrick.tech/betterzon/images/{{productsPricesMap[productId]?.product.image_guid}}.jpg" alt=""></div>
<div class="bbb_deals_content"> <div class="bbb_deals_content">
<div class="bbb_deals_info_line d-flex flex-row justify-content-start"> <div class="bbb_deals_info_line d-flex flex-row justify-content-start">
<div class="bbb_deals_item_name">{{product.name}}</div> <div class="bbb_deals_item_name">{{productsPricesMap[productId]?.product.name}}</div>
</div> </div>
<div class="bbb_deals_info_line d-flex flex-row justify-content-start"> <div class="bbb_deals_info_line d-flex flex-row justify-content-start">
<div class="bbb_deals_item_category">Amazon: <span id="bbb_deals_item_price_a"><strike>{{product.price}}$</strike></span></div> <div class="bbb_deals_item_category">Amazon: <span id="bbb_deals_item_price_a"><strike>{{productsPricesMap[productId]?.amazonPrice.price_in_cents}}$</strike></span></div>
</div> </div>
<div class="bbb_deals_info_line d-flex flex-row justify-content-start"> <div class="bbb_deals_info_line d-flex flex-row justify-content-start">
<div class="bbb_deals_item_category">Plantshub: <span id="bbb_deals_item_price_b">599,00$</span></div> <div class="bbb_deals_item_category">Plantshub: <span id="bbb_deals_item_price_b">{{productsPricesMap[productId]?.lowestPrice.price_in_cents}}</span></div>
</div> </div>
<div class="available_bar"> <div class="available_bar">
<span style="width:17%"></span> <span style="width:17%"></span>

View File

@ -11,6 +11,9 @@ import {ActivatedRoute, Router} from '@angular/router';
export class HotDealsWidgetComponent implements OnInit { export class HotDealsWidgetComponent implements OnInit {
products: Product[] = []; products: Product[] = [];
bestDealsProductIds = [];
amazonPrices = [];
productsPricesMap: any = {};
@Input() numberOfProducts: number; @Input() numberOfProducts: number;
@Input() showProductPicture: boolean; @Input() showProductPicture: boolean;
@Input() searchQuery: string; @Input() searchQuery: string;
@ -24,12 +27,13 @@ export class HotDealsWidgetComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
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;
@ -43,26 +47,59 @@ export class HotDealsWidgetComponent implements OnInit {
switch (this.type) { switch (this.type) {
case 'search': { case 'search': {
this.getSearchedProducts();
break; break;
} }
default: { default: {
this.getProducts(); this.getProductsByIds();
this.getAmazonPricesForBestDeals();
break; break;
} }
} }
} }
getProducts(): void { getProductsByIds(): void {
this.apiService.getProducts().subscribe(products => this.products = products); this.apiService.getProductsByIds(this.bestDealsProductIds).subscribe(
products => {
products.forEach(product => {
this.productsPricesMap [product.product_id].product = product;
});
}
);
}
getBestDeals(): void {
this.apiService.getBestDeals(9).subscribe(
deals => {
deals.forEach(deal => {
this.bestDealsProductIds.push(deal.product_id);
this.productsPricesMap [deal.product_id] = {lowestPrice: deal}
});
this.loadParams();
}
);
}
getAmazonPricesForBestDeals(): void{
this.bestDealsProductIds.forEach(id => {
this.apiService.getAmazonPrice(id).subscribe(
price => {
this.amazonPrices.push(price);
this.productsPricesMap[price.product_id].amazonPrice = price;
}
);
}
);
console.log(this.amazonPrices);
} }
getSearchedProducts(): void { getSearchedProducts(): void {
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products); this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products);
} }
clickedProduct(product: Product): void { clickedProduct(productId: string): void {
this.router.navigate([('/product/' + product.product_id)]); this.router.navigate([('/product/' + productId)]);
} }

View File

@ -0,0 +1,15 @@
<div class="container" *ngIf="currentUser; else loggedOut">
<p>
<strong>e-mail</strong>
{{ currentUser.email}}
</p>
<p>
<strong>username:</strong>
{{ currentUser.username}}
</p>
</div>
<ng-template #loggedOut>
Please login.
</ng-template>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProfileComponent } from './profile.component';
describe('ProfileComponent', () => {
let component: ProfileComponent;
let fixture: ComponentFixture<ProfileComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProfileComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ProfileComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
import {ApiService} from "../../services/api.service";
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.css']
})
export class ProfileComponent implements OnInit {
currentUser: any;
obj:any
constructor(private api: ApiService ) { }
ngOnInit(): void {
this.api.getUserInfo().subscribe(
user=> {
this.currentUser = user
console.log(this.currentUser);
},
);
}
}

View File

@ -15,6 +15,7 @@
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#unsere-kunden">Unsere Kunden</a></li> <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#unsere-kunden">Unsere Kunden</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/signin">Anmelden</a></li> <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/signin">Anmelden</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/registration">Konto Erstellen</a></li> <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/registration">Konto Erstellen</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/registration">Log Out</a></li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -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));
} }
} }