File tree Expand file tree Collapse file tree 14 files changed +41
-11
lines changed
shared/components/challenge-card Expand file tree Collapse file tree 14 files changed +41
-11
lines changed Original file line number Diff line number Diff line change 1- < router-outlet > </ router-outlet >
1+ < app-mentor-login (loginSuccess) =" onLoginSuccess($event) " > </ app-mentor-login > < router-outlet > </ router-outlet >
Original file line number Diff line number Diff line change @@ -6,4 +6,12 @@ import { Component } from '@angular/core'
66} )
77export class AppComponent {
88 title = 'ita-challenges'
9- }
9+
10+ isLoggedIn :boolean = false
11+
12+ onLoginSuccess ( success : boolean ) : void {
13+ if ( success ) {
14+ this . isLoggedIn = success
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import localeCa from '@angular/common/locales/ca'
2121import localeEn from '@angular/common/locales/en'
2222import { registerLocaleData } from '@angular/common'
2323
24+ import { MentorLoginComponent } from './modules/mentor/mentor-login/mentor-login.component' ;
25+
2426registerLocaleData ( localeEs , 'es' )
2527registerLocaleData ( localeCa , 'ca' )
2628registerLocaleData ( localeEn , 'en' )
@@ -35,6 +37,7 @@ export function HttpLoaderFactory (http: HttpClient): any {
3537 ] ,
3638 bootstrap : [ AppComponent ] ,
3739 imports : [ BrowserModule ,
40+ MentorLoginComponent ,
3841 AppRoutingModule ,
3942 BrowserAnimationsModule ,
4043 CoreModule ,
Original file line number Diff line number Diff line change 2626 {{'modules.challenge.header.login' | translate}}
2727 </ button >
2828 }
29-
30- < app-mentor-login (loginSuccess) ="onLoginSuccess($event) "> </ app-mentor-login >
31-
3229</ div >
Original file line number Diff line number Diff line change 5252 </ div >
5353 </ div >
5454</ div >
55-
56- < app-mentor-login (loginSuccess) ="onLoginSuccess($event) "> </ app-mentor-login >
5755
58-
5956< nav class ="navbar navbar-expand-md align-items-center ">
6057
6158 < button class ="navbar-toggler " type ="button " data-bs-toggle ="collapse " data-bs-target ="#navbarToggle "
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ <h3 class="ms-2">{{title | dynamicTranslate}}</h3>
4242 < span class ="stat " [ngbTooltip] ="'tooltips.favorites' | translate " (click) ="toggleFavorite() " style ="cursor: pointer; ">
4343 < img *ngIf ="!isFavorite " src ="assets/img/icon/heart.svg " alt ="Add to favorites ">
4444 < img *ngIf ="isFavorite " src ="assets/img/icon/heart-filled.svg " alt ="Remove from favorites ">
45- {{favorites_count}}
45+ < span class =" txt " > {{favorites_count}}</ span >
4646 </ span >
4747 < span class ="stat " [ngbTooltip] ="'tooltips.creationDate' | translate ">
4848 < img src ="assets/img/icon/clock.svg " alt ="Date ">
@@ -55,7 +55,8 @@ <h3 class="ms-2">{{title | dynamicTranslate}}</h3>
5555 < ng-container *ngIf ="!solutionSent; else solutionSentMessage ">
5656 < button *ngIf ="!challengeStarted " class ="btn btn-sm btn-primary " (click) ="onStartChallenge() "> {{'modules.challenge.header.buttonStart' | translate }}</ button >
5757 < button *ngIf ="challengeStarted " class ="btn btn-sm btn-primary " (click) ="saveChallenge() "> {{'modules.challenge.header.buttonSaveChallenge' | translate }}</ button >
58- < button *ngIf ="challengeStarted " class ="btn btn-sm btn-primary " (click) ="openSendSolutionModal() "> {{'modules.challenge.header.buttonSendSolution' | translate }}</ button >
58+ < button *ngIf ="challengeStarted " class ="btn btn-sm btn-primary " (click) ="openSendSolutionModal() "> {{'modules.challenge.header.buttonSendSolution' | translate }}</ button >
59+ < button *ngIf ="userRole === 'ADMIN' " class ="btn btn-sm btn-primary "> {{ 'modules.challenge.header.buttonEditChallenge' | translate }}</ button >
5960 </ ng-container >
6061
6162 <!-- Si ya se envió la solución -->
@@ -65,6 +66,7 @@ <h3 class="ms-2">{{title | dynamicTranslate}}</h3>
6566 < img src ="assets/img/icon/tick-pink.svg " alt ="tick icon ">
6667 </ div >
6768 </ ng-template >
69+
6870 </ div >
6971
7072</ div >
Original file line number Diff line number Diff line change 8989 vertical-align : middle ;
9090 margin-right : 4px ;
9191 }
92+ }
93+
94+ .stats .stat .txt {
95+ display : inline-block ;
96+ min-width : 24px ;
97+ text-align : center ;
9298}
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ export class ChallengeHeaderComponent implements OnInit {
2525 private readonly solutionService = inject ( SolutionService )
2626 private readonly authService = inject ( AuthService ) ;
2727 public userId : string | null = null ;
28+ public userRole : string | null = null ;
29+
2830 challengeTab = ChallengeTab ;
2931
3032 @Input ( ) title = ''
@@ -80,6 +82,11 @@ export class ChallengeHeaderComponent implements OnInit {
8082 }
8183 } ) ;
8284
85+ this . authService . getUserRole ( ) . subscribe ( role => {
86+ this . userRole = role
87+ } )
88+
89+ // Verifica si el reto ya ha comenzado
8390 if ( this . challengeStarted ) {
8491 this . activeId = ChallengeTab . SOLUTIONS
8592 }
Original file line number Diff line number Diff line change 6767 line-height : 16px ;
6868 font-weight : 600 ;
6969 color : $gray-3 ;
70+
71+ .txt {
72+ display : inline-block ;
73+ min-width : 20px ;
74+ text-align : center ;
75+ }
7076}
7177
7278.favorite-icon {
Original file line number Diff line number Diff line change @@ -50,5 +50,6 @@ export class ChallengeCardComponent implements OnInit {
5050 toggleFavorite ( event : MouseEvent ) : void {
5151 event . stopPropagation ( )
5252 this . isFavorite = ! this . isFavorite
53+ this . favorites_count = this . isFavorite ? this . favorites_count + 1 : Math . max ( 0 , this . favorites_count - 1 )
5354 }
5455}
You can’t perform that action at this time.
0 commit comments