From c8cbc53c914ece1d0f9c699e367d6a509eeb3351 Mon Sep 17 00:00:00 2001 From: Jegor Date: Mon, 7 Jun 2021 09:59:07 +0200 Subject: [PATCH] kunden component is done. --- .../components/kunden/kunden.component.css | 0 .../components/kunden/kunden.component.html | 38 +++++++++++ .../kunden/kunden.component.spec.ts | 25 +++++++ .../app/components/kunden/kunden.component.ts | 67 +++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 Frontend/src/app/components/kunden/kunden.component.css create mode 100644 Frontend/src/app/components/kunden/kunden.component.html create mode 100644 Frontend/src/app/components/kunden/kunden.component.spec.ts create mode 100644 Frontend/src/app/components/kunden/kunden.component.ts diff --git a/Frontend/src/app/components/kunden/kunden.component.css b/Frontend/src/app/components/kunden/kunden.component.css new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/src/app/components/kunden/kunden.component.html b/Frontend/src/app/components/kunden/kunden.component.html new file mode 100644 index 0000000..0012423 --- /dev/null +++ b/Frontend/src/app/components/kunden/kunden.component.html @@ -0,0 +1,38 @@ +
+
+ +

SIE VERTRAUEN UNS

+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
diff --git a/Frontend/src/app/components/kunden/kunden.component.spec.ts b/Frontend/src/app/components/kunden/kunden.component.spec.ts new file mode 100644 index 0000000..3977b33 --- /dev/null +++ b/Frontend/src/app/components/kunden/kunden.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { KundenComponent } from './kunden.component'; + +describe('KundenComponent', () => { + let component: KundenComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ KundenComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(KundenComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/src/app/components/kunden/kunden.component.ts b/Frontend/src/app/components/kunden/kunden.component.ts new file mode 100644 index 0000000..416be2e --- /dev/null +++ b/Frontend/src/app/components/kunden/kunden.component.ts @@ -0,0 +1,67 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {ApiService} from '../../services/api.service'; +import {Product} from '../../models/product'; +import {ActivatedRoute, Router} from '@angular/router'; + +@Component({ + selector: 'app-kunden', + templateUrl: './kunden.component.html', + styleUrls: ['./kunden.component.css'] +}) +export class KundenComponent implements OnInit { + products: Product[] = []; + @Input() numberOfProducts: number; + @Input() showProductPicture: boolean; + @Input() searchQuery: string; + @Input() type: string; + + constructor( + private apiService: ApiService, + private router: Router, + private route: ActivatedRoute + ) { + } + + ngOnInit(): void { + this.loadParams(); + } + + loadParams(): void { + if (!this.numberOfProducts) { + this.numberOfProducts = 10; + } + if (!this.showProductPicture) { + this.showProductPicture = false; + } + if (!this.searchQuery) { + this.searchQuery = ''; + } + if (!this.type) { + this.type = ''; + } + + switch (this.type) { + case 'search': { + this.getSearchedProducts(); + break; + } + default: { + this.getProducts(); + break; + } + } + } + + getProducts(): void { + this.apiService.getProducts().subscribe(products => this.products = products); + } + + getSearchedProducts(): void { + this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products); + } + + clickedProduct(product: Product): void { + this.router.navigate([('/product/' + product.product_id)]); + } + +}