Skip to content

Commit 07d393e

Browse files
committed
Fixed user profile
1 parent 71ae823 commit 07d393e

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

frontend/src/app/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import { CarouselComponent } from './components/carousel/carousel.component';
2424

2525

2626

27-
2827
@NgModule({
29-
declarations: [AppComponent, LoginComponent, HeadComponent, NewsComponent, NavBarComponent, FooterComponent, NewsTemplateComponent,VideogameCatalogComponent, ShowNewsComponent, HomeComponent, UserProfile,VideogameCardComponent, CarouselComponent],
28+
declarations: [UserProfile,AppComponent, LoginComponent, HeadComponent, NewsComponent, NavBarComponent, FooterComponent, NewsTemplateComponent,VideogameCatalogComponent, ShowNewsComponent, HomeComponent, UserProfile,VideogameCardComponent, CarouselComponent],
3029
imports: [BrowserModule, FormsModule, HttpClientModule, routing, FormsModule,RouterModule, NgbModule],
3130
bootstrap: [AppComponent]
3231
})

frontend/src/app/app.routing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const appRoutes = [
1717
{ path: 'userProfile', component: UserProfile},
1818
{ path: 'videogamecatalog', component: VideogameCatalogComponent },
1919
{ path: 'videogame/:id', component: VideogameDetailComponent },
20-
{ path: '', redirectTo: 'home', pathMatch: 'full' }
20+
{ path: '**', redirectTo: 'home', pathMatch: 'full' }
2121

2222
]
2323

frontend/src/app/components/user/userProfile.component.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
55
import { Usero } from './../../models/usero.model';
66
import { UseroService } from '../../services/usero.service';
77
import { LoginService } from '../../services/login.service';
8-
import { Videogame } from 'src/app/models/videogame.model';
8+
import { Videogame } from '../../models/videogame.model';
99

1010
@Component({
1111
selector: 'userProfile',
@@ -19,20 +19,24 @@ export class UserProfile {
1919
file: any;
2020
removeImage? :boolean;
2121

22-
constructor(private router: Router, activatedRoute: ActivatedRoute,public useroService: UseroService, public loginservice : LoginService) {
23-
const id = activatedRoute.snapshot.params['id'];
22+
constructor(private router: Router,public useroService: UseroService, public loginservice : LoginService) {
23+
const id:number = 2;
2424
if (id) {
2525
useroService.getUser(id).subscribe(
26-
(user: Usero) => user = user,
27-
(error: any) => console.error(error)
26+
user => this.user = user as Usero,
27+
error => console.error(error)
2828
);
2929
}
30-
useroService.getVideogames(this.user).subscribe(
31-
(videogame: Videogame[]) => videogame = videogame,
32-
(error: any) => console.error(error)
33-
);
30+
31+
3432
}
3533

34+
ngOnInit(){
35+
this.useroService.getVideogames(this.user).subscribe(
36+
videogame => this.videogame = videogame as Videogame[],
37+
error => console.error(error)
38+
);
39+
}
3640

3741
save(){
3842
this.useroService.updateUser(this.user).subscribe(

frontend/src/app/services/usero.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { News } from '../models/news.model';
66
import { Observable, throwError } from 'rxjs';
77
import { catchError } from 'rxjs/operators';
88

9-
const BASE_URL = '/api/users';
9+
const BASE_URL = '/api/users/';
1010

1111
@Injectable({ providedIn: 'root' })
1212
export class UseroService {

0 commit comments

Comments
 (0)