Skip to content

Commit 10b3cb5

Browse files
committed
user profile save no funciona
1 parent bad7e16 commit 10b3cb5

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

backend/gamelink/src/main/java/urjc/gamelink/Controllers/UserRestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public ResponseEntity<Usero> createUser(Usero user, @RequestParam String passwor
8686

8787
// Modifies a user
8888
@PutMapping("/{id}")
89-
public ResponseEntity<Usero> updateUser(@PathVariable long id, Usero updatedUser)
89+
public ResponseEntity<Usero> updateUser(@PathVariable long id, @RequestParam Usero updatedUser)
9090
throws SQLException {
9191

9292
if (us.exist(id)) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ <h3>"{{user.lastName}}"</h3>
2828
<div class="row mt-3">
2929

3030
<div class="col-md-12"><label class="labels">Nombre de usuario</label>
31-
<input name="nick" type="text" class="form-control" placeholder="RodPerez" [(ngModel)]="user.nick">
31+
<input name="nick" type="text" class="form-control" placeholder="RodPerez" [(ngModel)]="user.nick" value="user.nick">
3232
</div>
3333

3434
<div class="col-md-12"><label class="labels">Email</label>
3535
<input name="email" type="email" class="form-control" placeholder="[email protected]"
36-
[(ngModel)]="user.email">
36+
[(ngModel)]="user.email" value="user.email">
3737
</div>
3838

3939
<div class="col-md-12"><label class="labels">Número de tarjeta</label>
4040
<input *ngIf="user.creditCard" name="creditCard" type="text" class="form-control" placeholder="123456789A"
41-
[(ngModel)]="user.creditCard">
41+
[(ngModel)]="user.creditCard" value="user.creditCard">
4242
</div>
4343

4444
<div class="col-md-12">

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class UserProfile {
2222
constructor(private router: Router, activatedRoute: ActivatedRoute, public useroService: UseroService, public loginservice: LoginService) {
2323
const id = loginservice.currentUser()?.id;
2424
if (id) {
25-
useroService.getUser(id).subscribe(
25+
useroService.getMe().subscribe(
2626
(user) => this.user = user as Usero,
2727
(error: any) => console.error(error)
2828
);
@@ -43,27 +43,23 @@ export class UserProfile {
4343
(user: any) => this.uploadImage(user as Usero),
4444
(error: string) => alert('Error al guardar los datos: ' + error)
4545
);
46-
this.useroService.getVideogames(this.user).subscribe(
47-
videogame => this.videogame = videogame as Videogame[],
48-
error => console.error(error)
49-
);
5046
}
5147
cancel() {
5248
window.history.back();
5349
}
5450

5551
uploadImage(user: Usero): void {
56-
const image = this.file.nativeElement.files[0];
57-
if (image) {
58-
let formData = new FormData();
59-
formData.append("imageFile", image);
60-
this.useroService.setUserImage(user, formData).subscribe(
61-
(_: any) => this.afterUploadImage(),
62-
(error: string) => alert('Error al actualizar o subir la imagen: ' + error)
63-
);
64-
} else {
65-
this.afterUploadImage();
66-
}
52+
// const image = this.file.nativeElement.files[0];
53+
// if (image) {
54+
// let formData = new FormData();
55+
// formData.append("imageFile", image);
56+
// this.useroService.setUserImage(user, formData).subscribe(
57+
// (_: any) => this.afterUploadImage(),
58+
// (error: string) => alert('Error al actualizar o subir la imagen: ' + error)
59+
// );
60+
// } else {
61+
// this.afterUploadImage();
62+
// }
6763
}
6864

6965
private afterUploadImage() {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export class UseroService {
3030
}
3131

3232
getVideogames(user: Usero) {
33-
return this.http.get(BASE_URL + '/purchases' + user.id).pipe(
33+
return this.http.get(BASE_URL + 'purchases/' + user.id).pipe(
3434
catchError((error: any) => this.handleError(error))
3535
);
3636
}
3737

3838
getUserReadNews(id: number | string) {
39-
return this.http.get(BASE_URL + '/purchases' + id).pipe(
39+
return this.http.get(BASE_URL + 'purchases/' + id).pipe(
4040
catchError((error: any) => this.handleError(error))
4141
);
4242
}
@@ -48,7 +48,7 @@ export class UseroService {
4848
}
4949

5050
getMe() {
51-
return this.http.get(BASE_URL + '/me').pipe(
51+
return this.http.get(BASE_URL + 'me').pipe(
5252
catchError((error: any) => this.handleError(error))
5353
);
5454
}
@@ -91,7 +91,7 @@ export class UseroService {
9191

9292
/*------------------PASSWORD METHODS------------------*/
9393
updatePassword(user: Usero) {
94-
return this.http.put(BASE_URL + user.id + 'password', user).pipe(
94+
return this.http.put(BASE_URL + user.id + '/password', user).pipe(
9595
catchError((error: any) => this.handleError(error))
9696
);
9797
}

0 commit comments

Comments
 (0)