Skip to content

Commit 7b206f8

Browse files
Merge branch 'develop' into feature/bertapasamontes-onboarding
2 parents f8ad23f + 6095783 commit 7b206f8

File tree

14 files changed

+41
-11
lines changed

14 files changed

+41
-11
lines changed

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<router-outlet></router-outlet>
1+
<app-mentor-login (loginSuccess)="onLoginSuccess($event)"></app-mentor-login><router-outlet></router-outlet>

src/app/app.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ import { Component } from '@angular/core'
66
})
77
export 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+
}

src/app/app.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import localeCa from '@angular/common/locales/ca'
2121
import localeEn from '@angular/common/locales/en'
2222
import { registerLocaleData } from '@angular/common'
2323

24+
import { MentorLoginComponent } from './modules/mentor/mentor-login/mentor-login.component';
25+
2426
registerLocaleData(localeEs, 'es')
2527
registerLocaleData(localeCa, 'ca')
2628
registerLocaleData(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,

src/app/core/layout/header/desktop-nav/desktop-nav.component.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,4 @@
2626
{{'modules.challenge.header.login' | translate}}
2727
</button>
2828
}
29-
30-
<app-mentor-login (loginSuccess)="onLoginSuccess($event)"></app-mentor-login>
31-
3229
</div>

src/app/core/layout/header/mobile-nav/mobile-nav.component.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@
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"

src/app/modules/challenge/components/challenge-header/challenge-header.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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>

src/app/modules/challenge/components/challenge-header/challenge-header.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,10 @@ h3 {
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
}

src/app/modules/challenge/components/challenge-header/challenge-header.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

src/app/shared/components/challenge-card/challenge-card.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
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 {

src/app/shared/components/challenge-card/challenge-card.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)