diff --git a/.gitignore b/.gitignore index d9eb71a..05644c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ ~$*.pptx node_modules +.idea diff --git a/itenium-socks/angular.json b/itenium-socks/angular.json index e7cfa50..f61caf2 100644 --- a/itenium-socks/angular.json +++ b/itenium-socks/angular.json @@ -100,5 +100,8 @@ } } } + }, + "cli": { + "analytics": false } } diff --git a/itenium-socks/src/app/socks/sock.component.html b/itenium-socks/src/app/socks/sock.component.html index b40f9d2..9e7302c 100644 --- a/itenium-socks/src/app/socks/sock.component.html +++ b/itenium-socks/src/app/socks/sock.component.html @@ -15,6 +15,11 @@
+
+ +
diff --git a/itenium-socks/src/app/socks/sock.component.ts b/itenium-socks/src/app/socks/sock.component.ts index 1618e41..2f14559 100644 --- a/itenium-socks/src/app/socks/sock.component.ts +++ b/itenium-socks/src/app/socks/sock.component.ts @@ -1,8 +1,9 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Sock } from './sock.model'; import { SocksService } from './socks.service'; import { AsyncPipe, NgIf, TitleCasePipe } from '@angular/common'; +import { ActivatedRoute, Router } from "@angular/router"; @Component({ selector: 'app-sock', @@ -10,25 +11,33 @@ import { AsyncPipe, NgIf, TitleCasePipe } from '@angular/common'; imports: [NgIf, AsyncPipe, TitleCasePipe], templateUrl: './sock.component.html' }) -export class SockComponent { +export class SockComponent implements OnInit { + sockId: number = -1; sock$!: Observable; - constructor(private socksService: SocksService) {} + constructor(private socksService: SocksService, + private route: ActivatedRoute, + private router: Router) { + } ngOnInit(): void { - // HACK: This is not the way to get the sockId!! - const sockId = +window.location.pathname.split('/')[2]; - this.sock$ = this.socksService.getById(sockId); + this.route.url.subscribe(url => { + this.sockId = this.route.snapshot.params['id']; + this.sock$ = this.socksService.getById(this.sockId); + }) } buy(): void { - const sockId = +window.location.pathname.split('/')[2]; - this.socksService.buySocks(sockId).subscribe(); + this.socksService.buySocks(this.sockId).subscribe(); } addReview(): void { // TODO: Bind the form! - const sockId = +window.location.pathname.split('/')[2]; - this.socksService.addReview(sockId, 'my review', 5).subscribe(); + this.socksService.addReview(this.sockId, 'my review', 5).subscribe(); + } + + goToNextSock() { + let nextSockId = +this.sockId + 1; + this.router.navigate(["/socks", nextSockId]); } } diff --git a/itenium-socks/src/styles.scss b/itenium-socks/src/styles.scss index 3cc7a27..e98adaf 100644 --- a/itenium-socks/src/styles.scss +++ b/itenium-socks/src/styles.scss @@ -407,6 +407,18 @@ a:focus { } +.next-item { + display: inline-block; + padding: 10px 40px; + background-color: #f000ff; + color: #f5ca1e; + border: 1px solid #f000ff; + border-radius: 5px; + -webkit-transition: all .3s; + transition: all .3s; + margin-top: 25px; + text-transform: uppercase; +} .buy-socks { display: inline-block;