diff --git a/src/app/modules/profile/profile-info/profile-info.component.html b/src/app/modules/profile/profile-info/profile-info.component.html index c05549ab10bef560460b30b6c2a237bf8efb8bad..9f0a467dcdff3a50130541eee01e847a7b35f9db 100644 --- a/src/app/modules/profile/profile-info/profile-info.component.html +++ b/src/app/modules/profile/profile-info/profile-info.component.html @@ -1,33 +1,34 @@ <div class="question-marks"> + <mat-icon *ngIf="isLogged" (click)="logOut()">logout</mat-icon> <h1>Your profile</h1> <div class="content"> <h3>Your stats</h3> <div class="container"> <div class="grid-profile"> <div class="profile_info"> - <img src="https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png" - alt="profile picture" /> + <img + src="https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png" + alt="profile picture" + /> <h3>User Name</h3> </div> <hr /> <div class="profile_stats"> - <img src="https://img.uxcel.com/tags/key-performance-indicator-kpi-1698250709411-2x.jpg" - alt="stats" /> + <img + src="https://img.uxcel.com/tags/key-performance-indicator-kpi-1698250709411-2x.jpg" + alt="stats" + /> </div> </div> </div> - <h3>Not logged in</h3> - <div class="grid"> - <app-sign *ngIf="!isLogged"></app-sign> - </div> + <app-sign *ngIf="!isLogged"></app-sign> <div *ngIf="isLogged"> <h3>Your quizzes</h3> <div class="grid"> <!-- <form [formGroup]="form" (ngSubmit)="submitForm()"> --> <form> <div class="form-group"> - <input type="text" class="inputRecherche" placeholder="Search a quiz..." - formControlName="quizName" /> + <input type="text" class="inputRecherche" placeholder="Search a quiz..." /> </div> </form> <div class="container"> @@ -41,4 +42,4 @@ </div> </div> </div> -</div> \ No newline at end of file +</div> diff --git a/src/app/modules/profile/profile-info/profile-info.component.ts b/src/app/modules/profile/profile-info/profile-info.component.ts index 851e21509d01e98edab3cc9baeb7ddd3814e37eb..c7212073701a734eb8d3aa18228c1b1b77a8b7a2 100644 --- a/src/app/modules/profile/profile-info/profile-info.component.ts +++ b/src/app/modules/profile/profile-info/profile-info.component.ts @@ -37,6 +37,11 @@ export class ProfileInfoComponent implements OnInit { } newQuiz() { - this.router.navigate(['/create-custom-quiz']); + this.router.navigate(['/profile/create-custom-quiz']); + } + + logOut() { + this.userSerivce.logout().subscribe(); + this.router.navigate(['/']); } } diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index 1dfdc805dad05bd17bee69e840a31ba47e3aa8e3..8116f417e595f53348628399d42d9c43c71f7c58 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -23,4 +23,8 @@ export class UserService { public getMe() { return this.http.get(`${this.apiUrl}/user/me`, { withCredentials: true }); } + + public logout() { + return this.http.post(`${this.apiUrl}/auth/logout`, {}, { withCredentials: true }); + } }