WIP: Proceed with frontend implementation

This commit is contained in:
Simon Grimme
2022-07-22 12:54:39 +02:00
parent 38028b7e49
commit a06dfa7c47
14 changed files with 96 additions and 50 deletions
@@ -1,4 +1,8 @@
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {DetectedGameDto} from "../../models/dtos/DetectedGameDto";
import {GamesService} from "../../services/games.service";
import {HttpErrorResponse} from "@angular/common/http";
@Component({
selector: 'app-game-detail-view',
@@ -7,7 +11,24 @@ import { Component, OnInit } from '@angular/core';
})
export class GameDetailViewComponent implements OnInit {
constructor() { }
game!: DetectedGameDto;
constructor(private route: ActivatedRoute,
private router: Router,
private gamesService: GamesService) {
this.route.params.subscribe( params => {
this.gamesService.getGame(params['slug']).subscribe({
next: game => this.game = game,
error: error => {
if(error.status === 404) {
this.router.navigate(['/library']);
} else {
console.error(error);
}
}
});
});
}
ngOnInit(): void {
}