From 6b30360219eaddc229803ef627ba1c7678e3910f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20L=C3=A1szl=C3=B3?= <rlacko99@gmail.com> Date: Tue, 11 May 2021 22:38:45 +0200 Subject: [PATCH] KST-13: Accept user --- src/app/core/users/users.component.html | 17 +++++++++++++++-- src/app/core/users/users.component.ts | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/app/core/users/users.component.html b/src/app/core/users/users.component.html index 3e16379..f852c42 100644 --- a/src/app/core/users/users.component.html +++ b/src/app/core/users/users.component.html @@ -9,8 +9,21 @@ <div class='border-top mt-3 pt-3' *ngIf='!users'> Nincs </div> - <div class='border-top mt-3 pt-3' *ngFor='let user of users; TrackBy: trackById'> - {{user.fullName}} - {{user.email}} + <div class='border-top mt-3 pt-3 d-flex justify-content-between' *ngFor='let user of users; TrackBy: trackById'> + <div> + <div> + {{user.fullName}} - {{user.schacc}} + </div> + <div> + {{user.email}} + </div> + </div> + <div> + {{user.isApproved ? "Elfogadott": "Jelentkezett"}} + <button class='btn btn-link' *ngIf='!user.isApproved' + (click)='approve(user.id)'>Elfogadás + </button> + </div> </div> </div> <div class='mt-3'> diff --git a/src/app/core/users/users.component.ts b/src/app/core/users/users.component.ts index 9d05e5e..8f299db 100644 --- a/src/app/core/users/users.component.ts +++ b/src/app/core/users/users.component.ts @@ -17,15 +17,24 @@ export class UsersComponent implements OnInit { constructor(private usersService: UsersService) {} ngOnInit(): void { - this.usersService.listUsers().subscribe((u) => { - this.users = u; - this.isLoading = false; - }, error => { - this.isLoading = false; - }); + this.usersService.listUsers().subscribe( + (u) => { + this.users = u; + this.isLoading = false; + }, + (error) => { + this.isLoading = false; + } + ); } public trackById(index: number, item: User): number { return item.id; } + + approve(userId: number): void { + this.usersService.approveUser(userId).subscribe((u) => { + window.location.reload(); + }); + } } -- GitLab