Skip to content

Commit 765d77a

Browse files
committed
fix rating of program by expert id
1 parent 6f14027 commit 765d77a

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

projects/social_platform/src/app/office/program/models/project-rate.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ProjectRatingCriterion } from "./project-rating-criterion"; // Assuming
2020
* @param {number} industry - ID отрасли проекта
2121
* @param {ProjectRatingCriterion[]} criterias - Массив критериев для оценки
2222
* @param {boolean} isScored - Флаг, указывающий, оценен ли проект текущим пользователем
23+
* @private {number | null} scoredExpertId - Флаг, что оценил
2324
*/
2425
export interface ProjectRate {
2526
id: number;
@@ -33,4 +34,5 @@ export interface ProjectRate {
3334
industry: number;
3435
criterias: ProjectRatingCriterion[];
3536
scored: boolean;
37+
scoredExpertId: number | null;
3638
}

projects/social_platform/src/app/office/program/shared/rating-card/rating-card.component.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { RouterLink } from "@angular/router";
3838
import { TagComponent } from "@ui/components/tag/tag.component";
3939
import { ModalComponent } from "@ui/components/modal/modal.component";
4040
import { ProgramDataService } from "@office/program/services/program-data.service";
41+
import { AuthService } from "@auth/services";
42+
import { User } from "@auth/models/user.model";
4143

4244
/**
4345
* Компонент карточки оценки проекта
@@ -103,6 +105,7 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
103105
public industryService: IndustryService,
104106
private projectRatingService: ProjectRatingService,
105107
private readonly programDataService: ProgramDataService,
108+
private readonly authService: AuthService,
106109
private breakpointObserver: BreakpointObserver,
107110
private cdRef: ChangeDetectorRef
108111
) {}
@@ -122,6 +125,8 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
122125
_currentIndex = signal<number>(0);
123126
_projects = signal<ProjectRate[]>([]);
124127

128+
profile = signal<User | null>(null);
129+
125130
form = new FormControl();
126131

127132
submitLoading = signal(false);
@@ -166,6 +171,14 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
166171
.subscribe();
167172

168173
this.subscriptions$().push(program$);
174+
175+
const profileId$ = this.authService.profile.subscribe({
176+
next: profile => {
177+
this.profile.set(profile);
178+
},
179+
});
180+
181+
this.subscriptions$().push(profileId$);
169182
}
170183

171184
ngAfterViewInit(): void {
@@ -232,12 +245,23 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
232245
return !this.programDateFinished();
233246
}
234247

248+
get isCurrentUserExpert(): boolean {
249+
const currentProfile = this.profile();
250+
const project = this.project;
251+
252+
if (!currentProfile || !project) return false;
253+
254+
return project.scored && project.scoredExpertId === currentProfile.id;
255+
}
256+
235257
get showRatingForm(): boolean {
236258
return !this.projectRated() && this.canEdit;
237259
}
238260

239261
get showRatedWithEdit(): boolean {
240-
return (this.projectRated() || this.projectConfirmed()) && this.canEdit;
262+
return (
263+
(this.projectRated() || this.projectConfirmed()) && this.canEdit && this.isCurrentUserExpert
264+
);
241265
}
242266

243267
get showConfirmedState(): boolean {

0 commit comments

Comments
 (0)